diff --git a/paper/run/config/paper-global.yml b/paper/run/config/paper-global.yml index d28ab738a..21524efe3 100644 --- a/paper/run/config/paper-global.yml +++ b/paper/run/config/paper-global.yml @@ -122,6 +122,7 @@ unsupported-settings: allow-headless-pistons: false allow-permanent-block-break-exploits: false allow-piston-duplication: false + allow-tripwire-disarming-exploits: false allow-unsafe-end-portal-teleportation: false compression-format: ZLIB perform-username-validation: true diff --git a/paper/run/server.properties b/paper/run/server.properties index c547ab7b5..7dcc74bf3 100644 --- a/paper/run/server.properties +++ b/paper/run/server.properties @@ -1,5 +1,5 @@ #Minecraft server properties -#Fri Mar 08 12:37:41 GMT-03:00 2024 +#Sat Apr 06 16:10:24 GMT-03:00 2024 enable-jmx-monitoring=false rcon.port=25575 level-seed= diff --git a/paper/src/main/java/com/badbones69/crazycrates/api/FileManager.java b/paper/src/main/java/com/badbones69/crazycrates/api/FileManager.java index 46456ed7e..80048056c 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/api/FileManager.java +++ b/paper/src/main/java/com/badbones69/crazycrates/api/FileManager.java @@ -12,9 +12,9 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -23,12 +23,12 @@ public class FileManager { @NotNull private final CrazyCrates plugin = CrazyCrates.get(); - private final Map files = new HashMap<>(); + private final Map files = new ConcurrentHashMap<>(); private final List homeFolders = new ArrayList<>(); private final List customFiles = new ArrayList<>(); - private final Map jarHomeFolders = new HashMap<>(); - private final Map autoGenerateFiles = new HashMap<>(); - private final Map configurations = new HashMap<>(); + private final Map jarHomeFolders = new ConcurrentHashMap<>(); + private final Map autoGenerateFiles = new ConcurrentHashMap<>(); + private final Map configurations = new ConcurrentHashMap<>(); private final Logger logger = this.plugin.getLogger(); private final boolean isLogging = this.plugin.isLogging(); @@ -343,7 +343,7 @@ public void reloadAllFiles() { * @return A list of crate names. */ public List getAllCratesNames() { - List files = new ArrayList<>(); + List fileList = new ArrayList<>(); File crateDirectory = new File(this.plugin.getDataFolder(), "/crates"); @@ -361,7 +361,7 @@ public List getAllCratesNames() { for (String name : folder) { if (!name.endsWith(".yml")) continue; - files.add(name.replaceAll(".yml", "")); + fileList.add(name.replaceAll(".yml", "")); } } } @@ -371,11 +371,11 @@ public List getAllCratesNames() { for (String name : file) { if (!name.endsWith(".yml")) continue; - files.add(name.replaceAll(".yml", "")); + fileList.add(name.replaceAll(".yml", "")); } } - return Collections.unmodifiableList(files); + return Collections.unmodifiableList(fileList); } /** @@ -473,14 +473,16 @@ public FileConfiguration getFile() { * Saves the file from the loaded state to the file system. */ public void saveFile() { - this.fileManager.saveFile(this); + Bukkit.getAsyncScheduler().runNow(this.plugin, task -> this.fileManager.saveFile(this)); } /** * Overrides the loaded state file and loads the file systems file. */ public void reloadFile() { - if (getFileName().endsWith(".yml")) this.fileManager.reloadFile(this); + if (getFileName().endsWith(".yml")) { + this.fileManager.reloadFile(this); + } } } diff --git a/paper/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java b/paper/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java index f36a34ffa..917973c41 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java +++ b/paper/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java @@ -54,10 +54,10 @@ public void onCrateOpen(PlayerInteractEvent e) { Player player = e.getPlayer(); if (e.getHand() == EquipmentSlot.OFF_HAND) { - if (this.plugin.getCrateManager().isKey(player.getInventory().getItemInOffHand())) { - e.setCancelled(true); - player.updateInventory(); - } +// if (this.plugin.getCrateManager().isKey(player.getInventory().getItemInOffHand())) { +// e.setCancelled(true); +// player.updateInventory(); +// } return; } @@ -94,15 +94,17 @@ public void onCrateOpen(PlayerInteractEvent e) { } } else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { // Checks if the item in their hand is a key and if so it stops them from right-clicking with it. - ItemStack key = player.getInventory().getItemInMainHand(); - boolean keyInHand = this.crateManager.isKey(key); - - if (!keyInHand) keyInHand = this.crateManager.isKey(player.getEquipment().getItemInOffHand()); - - if (keyInHand) { - e.setCancelled(true); - player.updateInventory(); - } +// ItemStack key = player.getInventory().getItemInMainHand(); +// boolean keyInHand = this.crateManager.isKey(key); +// +// if (!keyInHand) { +// keyInHand = this.crateManager.isKey(player.getEquipment().getItemInOffHand()); +// } +// +// if (keyInHand) { +// e.setCancelled(true); +// player.updateInventory(); +// } //Checks to see if the clicked block is a physical crate. CrateLocation crateLocation = null; @@ -134,7 +136,7 @@ public void onCrateOpen(PlayerInteractEvent e) { if (!event.isCancelled()) { boolean hasKey = false; - boolean isPhysical = false; +// boolean isPhysical = false; boolean useQuickCrateAgain = false; String keyName = crate.getKeyName(); @@ -152,13 +154,15 @@ public void onCrateOpen(PlayerInteractEvent e) { return; } - if (crate.getCrateType() != CrateType.crate_on_the_go && keyInHand && this.crateManager.isKeyFromCrate(key, crate) && this.config.getProperty(ConfigKeys.physical_accepts_physical_keys)) { +// if (crate.getCrateType() != CrateType.crate_on_the_go && keyInHand && this.crateManager.isKeyFromCrate(key, crate) && this.config.getProperty(ConfigKeys.physical_accepts_physical_keys)) { +// hasKey = true; +// isPhysical = true; +// } + + if (this.config.getProperty(ConfigKeys.physical_accepts_virtual_keys) && this.plugin.getCrazyHandler().getUserManager().getVirtualKeys(player.getUniqueId(), crate.getName()) >= 1) { hasKey = true; - isPhysical = true; } - if (this.config.getProperty(ConfigKeys.physical_accepts_virtual_keys) && this.plugin.getCrazyHandler().getUserManager().getVirtualKeys(player.getUniqueId(), crate.getName()) >= 1) hasKey = true; - if (hasKey) { // Checks if the player uses the quick crate again. if (this.crateManager.isInOpeningList(player) && this.crateManager.getOpeningCrate(player).getCrateType() == CrateType.quick_crate && this.crateManager.isCrateInUse(player) && this.crateManager.getCrateInUseLocation(player).equals(crateLocation.getLocation())) { @@ -186,17 +190,21 @@ public void onCrateOpen(PlayerInteractEvent e) { this.plugin.getCrateManager().endQuickCrate(player, crateLocation.getLocation(), crate, true); } - KeyType keyType = isPhysical ? KeyType.physical_key : KeyType.virtual_key; + KeyType keyType = KeyType.virtual_key; // Only cosmic crate type uses this method. - if (crate.getCrateType() == CrateType.cosmic) this.crateManager.addPlayerKeyType(player, keyType); + if (crate.getCrateType() == CrateType.cosmic) { + this.crateManager.addPlayerKeyType(player, keyType); + } this.crateManager.addPlayerToOpeningList(player, crate); this.crateManager.openCrate(player, crate, keyType, crateLocation.getLocation(), false,true); } else { if (crate.getCrateType() != CrateType.crate_on_the_go) { - if (this.config.getProperty(ConfigKeys.knock_back)) knockBack(player, clickedBlock.getLocation()); + if (this.config.getProperty(ConfigKeys.knock_back)) { + knockBack(player, clickedBlock.getLocation()); + } if (this.config.getProperty(ConfigKeys.need_key_sound_toggle)) { player.playSound(player.getLocation(), Sound.valueOf(this.config.getProperty(ConfigKeys.need_key_sound)), SoundCategory.PLAYERS, 1f, 1f);