From ae64b1d2a21441847a97e76867689e615785fa80 Mon Sep 17 00:00:00 2001 From: xGinko Date: Wed, 29 Nov 2023 21:03:08 +0100 Subject: [PATCH] fix IllegalStateException --- AnarchyExploitFixesFolia/pom.xml | 4 +- .../commands/AEFCommand.java | 6 +- .../chunklimits/FallingBlockLimit.java | 68 +++++++++---------- AnarchyExploitFixesLegacy/pom.xml | 2 +- README.md | 1 - pom.xml | 5 +- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/AnarchyExploitFixesFolia/pom.xml b/AnarchyExploitFixesFolia/pom.xml index c938f47c9..68118dc12 100644 --- a/AnarchyExploitFixesFolia/pom.xml +++ b/AnarchyExploitFixesFolia/pom.xml @@ -6,7 +6,7 @@ me.moomoo.anarchyexploitfixes AnarchyExploitFixes - 2.5.2 + 2.6.0-SNAPSHOT Folia @@ -88,7 +88,7 @@ dev.folia folia-api - 1.20.1-R0.1-SNAPSHOT + 1.20.2-R0.1-SNAPSHOT provided diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/AEFCommand.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/AEFCommand.java index 041791a8d..7545185c6 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/AEFCommand.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/commands/AEFCommand.java @@ -65,10 +65,8 @@ public void reloadCommand( final CommandSender sender ) { sender.sendMessage(Component.text("Reloading AnarchyExploitFixes...").color(NamedTextColor.WHITE)); - plugin.getServer().getGlobalRegionScheduler().run(plugin, reloadPlugin -> { - plugin.reloadPlugin(); - sender.sendMessage(Component.text("Reload complete.").color(NamedTextColor.GREEN)); - }); + plugin.reloadPlugin(); + sender.sendMessage(Component.text("Reload complete.").color(NamedTextColor.GREEN)); } @CommandMethod("aef lag ") diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/FallingBlockLimit.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/FallingBlockLimit.java index a02d81a79..d1de39926 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/FallingBlockLimit.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/modules/chunklimits/FallingBlockLimit.java @@ -69,55 +69,53 @@ public void disable() { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) private void onBlockPhysics(BlockPhysicsEvent event) { Chunk chunk = event.getBlock().getChunk(); - if (checkedChunks.getIfPresent(chunk) == null) { - int count = 0; - boolean removed_falling = false; - - for (Entity entity : chunk.getEntities()) { - if (entity.getType().equals(EntityType.FALLING_BLOCK)) { - count++; - if (count > maxFallingGravityBlockPerChunk) { - entity.getScheduler().run(plugin, kill -> entity.remove(), null); - removed_falling = true; - } + if (checkedChunks.getIfPresent(chunk) != null) return; + + int count = 0; + boolean removed_falling = false; + + for (Entity entity : chunk.getEntities()) { + if (entity.getType().equals(EntityType.FALLING_BLOCK)) { + count++; + if (count > maxFallingGravityBlockPerChunk) { + entity.getScheduler().run(plugin, kill -> entity.remove(), null); + removed_falling = true; } } + } - if (logIsEnabled && removed_falling) moduleLog(Level.INFO, name(), - "Removed falling blocks at " + event.getSourceBlock().getLocation() - + ", because reached limit of " + maxFallingGravityBlockPerChunk + " falling gravity blocks per chunk" - ); + if (logIsEnabled && removed_falling) moduleLog(Level.INFO, name(), + "Removed falling blocks at " + event.getSourceBlock().getLocation() + + ", because reached limit of " + maxFallingGravityBlockPerChunk + " falling gravity blocks per chunk" + ); - checkedChunks.put(chunk, true); - } + checkedChunks.put(chunk, true); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) private void onChangeBlock(EntityChangeBlockEvent event) { if (!event.getEntityType().equals(EntityType.FALLING_BLOCK)) return; - Chunk chunk = event.getBlock().getChunk(); + if (checkedChunks.getIfPresent(chunk) != null) return; + + int count = 0; + boolean removed_falling = false; - if (checkedChunks.getIfPresent(chunk) == null) { - int count = 0; - boolean removed_falling = false; - - for (Entity entity : chunk.getEntities()) { - if (entity.getType().equals(EntityType.FALLING_BLOCK)) { - count++; - if (count > maxFallingGravityBlockPerChunk) { - entity.getScheduler().run(plugin, kill -> entity.remove(), null); - removed_falling = true; - } + for (Entity entity : chunk.getEntities()) { + if (entity.getType().equals(EntityType.FALLING_BLOCK)) { + count++; + if (count > maxFallingGravityBlockPerChunk) { + entity.getScheduler().run(plugin, kill -> entity.remove(), null); + removed_falling = true; } } + } - if (logIsEnabled && removed_falling) moduleLog(Level.INFO, name(), - "Removed falling blocks at " + event.getBlock().getLocation() - + ", because reached limit of " + maxFallingGravityBlockPerChunk + " falling gravity blocks per chunk" - ); + if (logIsEnabled && removed_falling) moduleLog(Level.INFO, name(), + "Removed falling blocks at " + event.getBlock().getLocation() + + ", because reached limit of " + maxFallingGravityBlockPerChunk + " falling gravity blocks per chunk" + ); - checkedChunks.put(chunk, true); - } + checkedChunks.put(chunk, true); } } \ No newline at end of file diff --git a/AnarchyExploitFixesLegacy/pom.xml b/AnarchyExploitFixesLegacy/pom.xml index 66caa80df..fe872c11d 100644 --- a/AnarchyExploitFixesLegacy/pom.xml +++ b/AnarchyExploitFixesLegacy/pom.xml @@ -6,7 +6,7 @@ me.moomoo.anarchyexploitfixes AnarchyExploitFixes - 2.5.2 + 2.6.0-SNAPSHOT Legacy diff --git a/README.md b/README.md index 4e16e0314..3284963b3 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ These commands can only be executed from console or by opped players. * /aef lag - artificially lag the server for testing. Every time you run the command the server freezes for 1 second by default, add milliseconds to the end of the command for custom time. * /aef version - Plugin version. -* /aef kickphrase phrase - Kick players that have said a certain phrase (case insensitive). ## Donate diff --git a/pom.xml b/pom.xml index 0249acaee..1f4185e0b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.moomoo.anarchyexploitfixes AnarchyExploitFixes - 2.5.2 + 2.6.0-SNAPSHOT AnarchyExploitFixesFolia AnarchyExploitFixesLegacy @@ -45,13 +45,14 @@ false ${project.name}-${project.version} - true *:* LICENSE + module-info.class META-INF/MANIFEST.MF + META-INF/LICENSE META-INF/LICENSE.txt META-INF/NOTICE.txt META-INF/maven/de.tr7zw/functional-annotations/pom.properties