diff --git a/src/main/java/world/bentobox/bentobox/util/DeleteIslandChunks.java b/src/main/java/world/bentobox/bentobox/util/DeleteIslandChunks.java index 6992c107f..ea24320df 100644 --- a/src/main/java/world/bentobox/bentobox/util/DeleteIslandChunks.java +++ b/src/main/java/world/bentobox/bentobox/util/DeleteIslandChunks.java @@ -12,7 +12,6 @@ import world.bentobox.bentobox.database.objects.IslandDeletion; * Deletes islands fast using chunk regeneration * * @author tastybento - * */ public class DeleteIslandChunks { @@ -24,18 +23,19 @@ public class DeleteIslandChunks { private int z; private BukkitTask task; - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "squid:CallToDeprecatedMethod"}) public DeleteIslandChunks(BentoBox plugin, IslandDeletion di) { // Fire event IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETE_CHUNKS).build(); x = di.getMinXChunk(); z = di.getMinZChunk(); + // Run through all chunks of the islands and regenerate them. task = Bukkit.getScheduler().runTaskTimer(plugin, () -> { for (int i = 0; i < SPEED; i++) { - di.getWorld().regenerateChunk(x, z); + // World#regenerateChunk(int, int) from Bukkit is deprecated because it may not regenerate decoration correctly + di.getWorld().regenerateChunk(x, z); if (plugin.getIWM().isNetherGenerate(di.getWorld()) && plugin.getIWM().isNetherIslands(di.getWorld())) { plugin.getIWM().getNetherWorld(di.getWorld()).regenerateChunk(x, z); - } if (plugin.getIWM().isEndGenerate(di.getWorld()) && plugin.getIWM().isEndIslands(di.getWorld())) { plugin.getIWM().getEndWorld(di.getWorld()).regenerateChunk(x, z); @@ -45,6 +45,7 @@ public class DeleteIslandChunks { z = di.getMinZChunk(); x++; if (x > di.getMaxXChunk()) { + // We're done task.cancel(); // Fire event IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETED).build(); @@ -52,7 +53,5 @@ public class DeleteIslandChunks { } } }, 0L, 1L); - } - -} \ No newline at end of file +}