Fixed setup + new plot clearing

This commit is contained in:
boy0001 2015-04-30 14:46:24 +10:00
parent 304decbcef
commit 5968b9e22e
3 changed files with 9 additions and 18 deletions

View File

@ -45,22 +45,24 @@ public class Setup extends SubCommand {
} }
public void displayGenerators(PlotPlayer plr) { public void displayGenerators(PlotPlayer plr) {
MainUtil.sendMessage(plr, "&6What generator do you want?"); StringBuffer message = new StringBuffer();
message.append("&6What generator do you want?");
for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) { for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) {
// + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared") // + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")
if (entry.getKey().equals("PlotSquared")) { if (entry.getKey().equals("PlotSquared")) {
MainUtil.sendMessage(plr, "\n&8 - &2" + entry.getKey() + "(Hybrid Generator)"); message.append("\n&8 - &2" + entry.getKey() + "(Hybrid Generator)");
} }
else if (entry.getValue() instanceof HybridGen) { else if (entry.getValue() instanceof HybridGen) {
MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Hybrid Generator)"); message.append("\n&8 - &7" + entry.getKey() + "(Hybrid Generator)");
} }
else if (entry.getValue() instanceof PlotGenerator) { else if (entry.getValue() instanceof PlotGenerator) {
MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Plot Generator)"); message.append("\n&8 - &7" + entry.getKey() + "(Plot Generator)");
} }
else { else {
MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Unknown structure)"); message.append("\n&8 - &7" + entry.getKey() + "(Unknown structure)");
} }
} }
MainUtil.sendMessage(plr, message.toString());
} }
@Override @Override

View File

@ -601,7 +601,6 @@ public class MainUtil {
*/ */
public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) {
if (runners.containsKey(plot)) { if (runners.containsKey(plot)) {
System.out.print("RUNNABLE ALREADY");
return false; return false;
} }
ChunkManager.manager.clearAllEntities(plot); ChunkManager.manager.clearAllEntities(plot);
@ -611,7 +610,6 @@ public class MainUtil {
} }
public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) {
System.out.print(1);
final PlotManager manager = PlotSquared.getPlotManager(world); final PlotManager manager = PlotSquared.getPlotManager(world);
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final int prime = 31; final int prime = 31;
@ -622,24 +620,20 @@ public class MainUtil {
System.currentTimeMillis(); System.currentTimeMillis();
final PlotWorld plotworld = PlotSquared.getPlotWorld(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
runners.put(plot, 1); runners.put(plot, 1);
System.out.print(2);
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
@Override @Override
public void run() { public void run() {
System.out.print(3);
runners.remove(plot); runners.remove(plot);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
} }
}); });
return; return;
} }
System.out.print(2.1);
final Runnable run = new Runnable() { final Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
System.out.print(3.1);
MainUtil.setBiome(world, plot, "FOREST"); MainUtil.setBiome(world, plot, "FOREST");
runners.remove(plot); runners.remove(plot);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -682,7 +676,7 @@ public class MainUtil {
setSimpleCuboidAsync(world, pos1, pos2, blocks[0]); setSimpleCuboidAsync(world, pos1, pos2, blocks[0]);
return; return;
} }
for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int y = pos1.getY(); y < Math.min(256, pos2.getY()); y++) {
for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int x = pos1.getX(); x < pos2.getX(); x++) {
for (int z = pos1.getZ(); z < pos2.getZ(); z++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
final int i = random.random(blocks.length); final int i = random.random(blocks.length);
@ -717,7 +711,7 @@ public class MainUtil {
} }
public static void setSimpleCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { public static void setSimpleCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int y = pos1.getY(); y < Math.min(256, pos2.getY()); y++) {
for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int x = pos1.getX(); x < pos2.getX(); x++) {
for (int z = pos1.getZ(); z < pos2.getZ(); z++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
SetBlockQueue.setBlock(world, x, y, z, newblock); SetBlockQueue.setBlock(world, x, y, z, newblock);

View File

@ -278,9 +278,6 @@ public class BukkitChunkManager extends ChunkManager {
final int c1z = c1.getZ(); final int c1z = c1.getZ();
final int c2x = c2.getX(); final int c2x = c2.getX();
final int c2z = c2.getZ(); final int c2z = c2.getZ();
System.out.print(4);
final ArrayList<Chunk> chunks = new ArrayList<Chunk>(); final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
for (int x = c1x; x <= c2x; x++) { for (int x = c1x; x <= c2x; x++) {
for (int z = c1z; z <= c2z; z++) { for (int z = c1z; z <= c2z; z++) {
@ -297,13 +294,11 @@ public class BukkitChunkManager extends ChunkManager {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < 20) { while (System.currentTimeMillis() - start < 20) {
if (chunks.size() == 0) { if (chunks.size() == 0) {
System.out.print(5);
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex); TaskManager.tasks.remove(currentIndex);
return; return;
} }
System.out.print(6);
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final Chunk chunk = chunks.get(0); final Chunk chunk = chunks.get(0);
chunks.remove(0); chunks.remove(0);