Skip to content

Commit

Permalink
fix IllegalStateException
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Nov 29, 2023
1 parent 3f7ff2a commit ae64b1d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 45 deletions.
4 changes: 2 additions & 2 deletions AnarchyExploitFixesFolia/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>me.moomoo.anarchyexploitfixes</groupId>
<artifactId>AnarchyExploitFixes</artifactId>
<version>2.5.2</version>
<version>2.6.0-SNAPSHOT</version>
</parent>

<artifactId>Folia</artifactId>
Expand Down Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <milliseconds>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion AnarchyExploitFixesLegacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>me.moomoo.anarchyexploitfixes</groupId>
<artifactId>AnarchyExploitFixes</artifactId>
<version>2.5.2</version>
<version>2.6.0-SNAPSHOT</version>
</parent>

<artifactId>Legacy</artifactId>
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.moomoo.anarchyexploitfixes</groupId>
<artifactId>AnarchyExploitFixes</artifactId>
<version>2.5.2</version>
<version>2.6.0-SNAPSHOT</version>
<modules>
<module>AnarchyExploitFixesFolia</module>
<module>AnarchyExploitFixesLegacy</module>
Expand Down Expand Up @@ -45,13 +45,14 @@
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.version}</finalName>
<minimizeJar>true</minimizeJar>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>LICENSE</exclude>
<exclude>module-info.class</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/LICENSE</exclude>
<exclude>META-INF/LICENSE.txt</exclude>
<exclude>META-INF/NOTICE.txt</exclude>
<exclude>META-INF/maven/de.tr7zw/functional-annotations/pom.properties</exclude>
Expand Down

0 comments on commit ae64b1d

Please sign in to comment.