Use WorldEdit API for area cleanup instead
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-11-12 04:07:55 +01:00
parent 3ef681e839
commit e68326cb87
3 changed files with 29 additions and 103 deletions

View File

@@ -10,6 +10,7 @@ import wtf.beatrice.limbomanager.LimboManager;
import java.util.ArrayList;
import java.util.List;
@Deprecated // this works, but it's too slow. (fast-async)worldedit's api has a far better way of handling it.
public class AreaCleanerRunnable implements Runnable
{
public BukkitTask task;
@@ -73,97 +74,5 @@ public class AreaCleanerRunnable implements Runnable
});
}
/*
int locationsDone = 0;
for(int x = min.getBlockX(); x < max.getBlockX(); x++) {
for (int y = min.getBlockY(); y < max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z < max.getBlockZ(); z++) {
if(locationsDone == blocksPerRun)
{
}
blocksList.add(new Location(min.getWorld(), x, y, z));
locationsDone++;
}
}
}
if(blocksList.isEmpty())
{
// we finished, free the location and cancel the task.
Cache.playerIslands.remove(playerName); // todo: what if player rejoins in the meanwhile
LimboManager.getInstance().getLogger().info("finished cleaning area for " + playerName);
task.cancel();
}
for (int i = 0; i < blocksPerRun; i++)
{
if(i >= blocksList.size())
{
// we finished, free the location and cancel the task.
Cache.playerIslands.remove(playerName); // todo: what if player rejoins in the meanwhile
LimboManager.getInstance().getLogger().info("finished cleaning area for " + playerName);
task.cancel();
break;
}
Location loc = blocksList.get(i);
Bukkit.getScheduler().runTask(LimboManager.getInstance(), () ->
{
LimboManager.getInstance().getLogger().info("c: " + loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ());
loc.getBlock().setType(Material.AIR);
});
}*/
/*for(int i = 0; i < blocksPerRun; i++)
{
// sync block write
Bukkit.getScheduler().runTask(LimboManager.getInstance(), () ->
{
LimboManager.getInstance().getLogger().info("c: " + current.getBlockX() + " " + current.getBlockY() + " " + current.getBlockZ());
current.getBlock().setType(Material.AIR);
// update current coordinates
if(current.getBlockX() < max.getBlockX())
{
current.setX(current.getBlockX() + 1);
}
else {
current.setX(min.getBlockX());
if(current.getBlockY() < max.getBlockY())
{
current.setY(max.getBlockY() + 1);
} else {
current.setY(min.getBlockY());
if(current.getBlockZ() < max.getBlockZ())
{
current.setZ(max.getBlockZ() + 1);
} else {
// we finished, free the location and cancel the task.
Cache.playerIslands.remove(playerName); // todo: what if player rejoins in the meanwhile
LimboManager.getInstance().getLogger().info("finished cleaning area for " + playerName);
task.cancel();
return;
}
}
}
});
}*/
}
}