diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java index 33009bdce..a86cdcbcb 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java @@ -32,7 +32,7 @@ public void enable() { @Override public boolean shouldEnable() { - return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", false, "Prevents hacked clients running .plugins to find out what plugins the server is using"); + return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", true, "Prevents hacked clients running .plugins to find out what plugins the server is using"); } @Override diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/BanPlayerHeads.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/BanPlayerHeads.java index da0fc7d36..31b0baf74 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/BanPlayerHeads.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/BanPlayerHeads.java @@ -24,7 +24,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.SkullMeta; import static me.moomoo.anarchyexploitfixes.utils.ItemUtils.isShulkerBox; @@ -34,14 +33,12 @@ public class BanPlayerHeads implements AnarchyExploitFixesModule, Listener { private ScheduledTask periodicInvCheck; private Listener hopperListener; private final boolean enableStrictPrevention, removeIllegalShulkers, preventHopperBypass; - private final ItemStack PLAYER_HEAD; private final long checkPeriod; public BanPlayerHeads() { shouldEnable(); this.plugin = AnarchyExploitFixes.getInstance(); Config config = AnarchyExploitFixes.getConfiguration(); - this.PLAYER_HEAD = new ItemStack(Material.PLAYER_HEAD, 1); config.addComment("illegals.player-heads.remove-items.enable", "This deletes playerheads with and without owners"); this.preventHopperBypass = config.getBoolean("illegals.player-heads.remove-items.prevent-hopper32k-mechanic", false, """ Prevents Hopper32k mechanic of placing a shulker containing illegals on top of a hopper and using the illegal\s @@ -70,8 +67,8 @@ public void enable() { this.hopperListener = new Listener() { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) private void onInventoryMove(InventoryMoveItemEvent event) { - ItemStack hopperItem = event.getItem(); - if (hopperItem.isSimilar(PLAYER_HEAD) || ((SkullMeta) hopperItem.getItemMeta()).hasOwner()) { + final Material material = event.getItem().getType(); + if (material.equals(Material.PLAYER_HEAD) || material.equals(Material.PLAYER_WALL_HEAD)) { event.setCancelled(true); } } @@ -102,7 +99,8 @@ public void disable() { private void removePlayerHeadItemIfPresent(ItemStack item) { if (item == null) return; - if (item.getType().equals(PLAYER_HEAD.getType()) && (item.isSimilar(PLAYER_HEAD) || ((SkullMeta) item.getItemMeta()).hasOwner())) { + final Material material = item.getType(); + if (material.equals(Material.PLAYER_HEAD) || material.equals(Material.PLAYER_WALL_HEAD)) { item.subtract(item.getAmount()); } @@ -115,10 +113,10 @@ private void removePlayerHeadItemIfPresent(ItemStack item) { private boolean shulkerContainsIllegalHead(ShulkerBox shulkerBox) { for (ItemStack shulkerContentItem : shulkerBox.getInventory()) { - if (shulkerContentItem != null && shulkerContentItem.getType().equals(PLAYER_HEAD.getType())) { - if (shulkerContentItem.isSimilar(PLAYER_HEAD) || ((SkullMeta) shulkerContentItem.getItemMeta()).hasOwner()) { - return true; - } + if (shulkerContentItem == null) continue; + final Material material = shulkerContentItem.getType(); + if (material.equals(Material.PLAYER_HEAD) || material.equals(Material.PLAYER_WALL_HEAD)) { + return true; } } return false; @@ -148,11 +146,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) private void onBlockPlace(BlockPlaceEvent event) { - if (removeIllegalShulkers) { - Block placedBlock = event.getBlockPlaced(); - if (isShulkerBox(placedBlock.getType()) && shulkerContainsIllegalHead((ShulkerBox) placedBlock.getState())) { - placedBlock.setType(Material.AIR); - } + if (!removeIllegalShulkers) return; + Block placedBlock = event.getBlockPlaced(); + if (isShulkerBox(placedBlock.getType()) && shulkerContainsIllegalHead((ShulkerBox) placedBlock.getState())) { + placedBlock.setType(Material.AIR); } } diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/PreventPlacingPlayerHeads.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/PreventPlacingPlayerHeads.java index eb6595c06..89122bc53 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/PreventPlacingPlayerHeads.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/illegals/items/playerheads/PreventPlacingPlayerHeads.java @@ -7,7 +7,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; public class PreventPlacingPlayerHeads implements AnarchyExploitFixesModule, Listener { @@ -42,10 +41,9 @@ public void disable() { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void onBlockPlace(PlayerInteractEvent event) { - if ( - event.getAction().equals(Action.RIGHT_CLICK_BLOCK) - && event.getMaterial().equals(Material.PLAYER_HEAD) - ) { + if (event.getAction().isLeftClick()) return; + final Material material = event.getMaterial(); + if (material.equals(Material.PLAYER_HEAD) || material.equals(Material.PLAYER_WALL_HEAD)) { event.setCancelled(true); } } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java index 0eacd1a76..9f42ea753 100644 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/modules/chat/PreventPluginScanning.java @@ -31,7 +31,7 @@ public void enable() { @Override public boolean shouldEnable() { - return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", false, "Prevents hacked clients running .plugins to find out what plugins the server is using"); + return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", true, "Prevents hacked clients running .plugins to find out what plugins the server is using"); } private static boolean isSuspectedScanPacket(String buffer) {