mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Added comments to DeleteIslandChunks
I've also added a sonar suppresswarning to avoid the "issues" when calling regenerateChunk
This commit is contained in:
parent
044c67ea28
commit
7fd6237280
@ -12,7 +12,6 @@ import world.bentobox.bentobox.database.objects.IslandDeletion;
|
|||||||
* Deletes islands fast using chunk regeneration
|
* Deletes islands fast using chunk regeneration
|
||||||
*
|
*
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DeleteIslandChunks {
|
public class DeleteIslandChunks {
|
||||||
|
|
||||||
@ -24,18 +23,19 @@ public class DeleteIslandChunks {
|
|||||||
private int z;
|
private int z;
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings({"deprecation", "squid:CallToDeprecatedMethod"})
|
||||||
public DeleteIslandChunks(BentoBox plugin, IslandDeletion di) {
|
public DeleteIslandChunks(BentoBox plugin, IslandDeletion di) {
|
||||||
// Fire event
|
// Fire event
|
||||||
IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETE_CHUNKS).build();
|
IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETE_CHUNKS).build();
|
||||||
x = di.getMinXChunk();
|
x = di.getMinXChunk();
|
||||||
z = di.getMinZChunk();
|
z = di.getMinZChunk();
|
||||||
|
// Run through all chunks of the islands and regenerate them.
|
||||||
task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||||
for (int i = 0; i < SPEED; i++) {
|
for (int i = 0; i < SPEED; i++) {
|
||||||
|
// World#regenerateChunk(int, int) from Bukkit is deprecated because it may not regenerate decoration correctly
|
||||||
di.getWorld().regenerateChunk(x, z);
|
di.getWorld().regenerateChunk(x, z);
|
||||||
if (plugin.getIWM().isNetherGenerate(di.getWorld()) && plugin.getIWM().isNetherIslands(di.getWorld())) {
|
if (plugin.getIWM().isNetherGenerate(di.getWorld()) && plugin.getIWM().isNetherIslands(di.getWorld())) {
|
||||||
plugin.getIWM().getNetherWorld(di.getWorld()).regenerateChunk(x, z);
|
plugin.getIWM().getNetherWorld(di.getWorld()).regenerateChunk(x, z);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (plugin.getIWM().isEndGenerate(di.getWorld()) && plugin.getIWM().isEndIslands(di.getWorld())) {
|
if (plugin.getIWM().isEndGenerate(di.getWorld()) && plugin.getIWM().isEndIslands(di.getWorld())) {
|
||||||
plugin.getIWM().getEndWorld(di.getWorld()).regenerateChunk(x, z);
|
plugin.getIWM().getEndWorld(di.getWorld()).regenerateChunk(x, z);
|
||||||
@ -45,6 +45,7 @@ public class DeleteIslandChunks {
|
|||||||
z = di.getMinZChunk();
|
z = di.getMinZChunk();
|
||||||
x++;
|
x++;
|
||||||
if (x > di.getMaxXChunk()) {
|
if (x > di.getMaxXChunk()) {
|
||||||
|
// We're done
|
||||||
task.cancel();
|
task.cancel();
|
||||||
// Fire event
|
// Fire event
|
||||||
IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETED).build();
|
IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETED).build();
|
||||||
@ -52,7 +53,5 @@ public class DeleteIslandChunks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0L, 1L);
|
}, 0L, 1L);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user