public static Boolean run(CommandSender sender, String alias, String[] args) {
if (PlayerHelper.checkIsPlayer(sender)) {
Player player = (Player)sender;
if (!Utils.checkCommandSpam(player, "chunk") && Permissions.checkPerms(player, "cex.chunk.refresh")) {
Location loc = player.getLocation();
World w = player.getWorld();
Chunk lastChunk = w.getChunkAt(loc);
Chunk currentChunk = w.getChunkAt(loc);
// first regenerate player's chunk
w.refreshChunk((int) loc.getX(), (int) loc.getZ());
// regenerate left
while (lastChunk.equals(currentChunk)) {
loc.setX(loc.getX() + 10);
currentChunk = w.getChunkAt(loc);
}
lastChunk = currentChunk;
w.refreshChunk((int) loc.getX(), (int) loc.getZ());
loc = player.getLocation();
// regenerate right
while (lastChunk.equals(currentChunk)) {
loc.setX(loc.getX() - 10);
currentChunk = w.getChunkAt(loc);
}
lastChunk = currentChunk;
w.refreshChunk((int) loc.getX(), (int) loc.getZ());
loc = player.getLocation();
// regenerate in front of player
while (lastChunk.equals(currentChunk)) {
loc.setZ(loc.getZ() + 10);
currentChunk = w.getChunkAt(loc);
}
lastChunk = currentChunk;
w.refreshChunk((int) loc.getX(), (int) loc.getZ());
loc = player.getLocation();
// regenerate behind the player
while (lastChunk.equals(currentChunk)) {
loc.setZ(loc.getZ() - 10);
currentChunk = w.getChunkAt(loc);
}
lastChunk = currentChunk;
w.refreshChunk((int) loc.getX(), (int) loc.getZ());
loc = player.getLocation();
// all done :)
LogHelper.showInfo("chunksRegenerated", sender);
}