diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 40cbb2b3a..6e8b15d2e 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,6 +8,7 @@ UTF-8 PlotSquared + 2.11.20 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 5c4e83b67..4954431c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -34,6 +34,7 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.ChunkLoc; @@ -72,11 +73,15 @@ public class DebugExec extends SubCommand { return false; } boolean result; + if (!PlotSquared.isPlotWorld(args[1])) { + MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]); + return false; + } if (BukkitHybridUtils.regions != null) { - result = ((BukkitHybridUtils)(HybridUtils.manager)).scheduleRoadUpdate(args[1], BukkitHybridUtils.regions); + result = ((BukkitHybridUtils)(HybridUtils.manager)).scheduleRoadUpdate(args[1], BukkitHybridUtils.regions, 0); } else { - result = HybridUtils.manager.scheduleRoadUpdate(args[1]); + result = HybridUtils.manager.scheduleRoadUpdate(args[1], 0); } if (!result) { PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); @@ -94,7 +99,7 @@ public class DebugExec extends SubCommand { while (BukkitHybridUtils.chunks.size() > 0) { ChunkLoc chunk = BukkitHybridUtils.chunks.get(0); BukkitHybridUtils.chunks.remove(0); - ((BukkitHybridUtils)(HybridUtils.manager)).regenerateRoad(BukkitHybridUtils.world, chunk); + ((BukkitHybridUtils)(HybridUtils.manager)).regenerateRoad(BukkitHybridUtils.world, chunk, 0); ChunkManager.manager.unloadChunk(BukkitHybridUtils.world, chunk); } PlotSquared.log("&cCancelled!"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 046c9b775..960dc77d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -42,7 +42,7 @@ public class DebugRoadRegen extends SubCommand { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); - final boolean result = HybridUtils.manager.regenerateRoad(world, chunk); + final boolean result = HybridUtils.manager.regenerateRoad(world, chunk, 0); MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index 7107f4ada..7847a2223 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -42,10 +42,21 @@ public class RegenAllRoads extends SubCommand { sendMessage(player, C.NOT_CONSOLE); return false; } - if (args.length != 1) { + if (args.length < 1) { sendMessage(player, C.NEED_PLOT_WORLD); return false; } + int height = 0; + if (args.length == 2) { + try { + height = Integer.parseInt(args[1]); + } + catch (NumberFormatException e) { + sendMessage(player, C.NOT_VALID_NUMBER); + sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads [height]"); + return false; + } + } final String name = args[0]; final PlotManager manager = PlotSquared.getPlotManager(name); if ((manager == null) || !(manager instanceof HybridPlotManager)) { @@ -57,7 +68,7 @@ public class RegenAllRoads extends SubCommand { PlotSquared.log("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); PlotSquared.log("&6Potential chunks to update: &7" + (chunks.size() * 1024)); PlotSquared.log("&6Estimated time: &7" + (chunks.size()) + " seconds"); - final boolean result = HybridUtils.manager.scheduleRoadUpdate(name); + final boolean result = HybridUtils.manager.scheduleRoadUpdate(name, height); if (!result) { PlotSquared.log("&cCannot schedule mass schematic update! (Is one already in progress?)"); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 4b23247d2..5f073ce84 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -240,7 +240,7 @@ public class SchematicCmd extends SubCommand { } else { if (args.length == 3) { try { - world = args[0]; + world = args[1]; final String[] split = args[2].split(";"); final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); if ((PlotSquared.getPlots(world) == null) || (PlotSquared.getPlots(world).get(i) == null)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 5be013de2..0f9b16a7a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -148,7 +148,7 @@ public class BukkitHybridUtils extends HybridUtils { for (int z = sz; z < (sz + 32); z++) { final Chunk chunk = world.getChunkAt(x, z); chunks2.add(chunk); - regenerateRoad(worldname, new ChunkLoc(x, z)); + regenerateRoad(worldname, new ChunkLoc(x, z), 0); MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } } @@ -171,20 +171,20 @@ public class BukkitHybridUtils extends HybridUtils { private long last; @Override - public boolean scheduleRoadUpdate(final String world) { + public boolean scheduleRoadUpdate(final String world, int extend) { if (BukkitHybridUtils.UPDATE) { return false; } BukkitHybridUtils.UPDATE = true; final List regions = ChunkManager.manager.getChunkChunks(world); - return scheduleRoadUpdate(world, regions); + return scheduleRoadUpdate(world, regions, extend); } public static List regions; public static List chunks = new ArrayList<>(); public static String world; - public boolean scheduleRoadUpdate(final String world, final List rgs) { + public boolean scheduleRoadUpdate(final String world, final List rgs, final int extend) { BukkitHybridUtils.regions = rgs; BukkitHybridUtils.world = world; chunks = new ArrayList(); @@ -195,7 +195,7 @@ public class BukkitHybridUtils extends HybridUtils { public void run() { count.increment(); if (count.intValue() % 20 == 0) { - PlotSquared.log("PROGRESS: " + ((100 * (2048 - chunks.size())) / 1024) + "%"); + PlotSquared.log("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%"); } if (regions.size() == 0 && chunks.size() == 0) { BukkitHybridUtils.UPDATE = false; @@ -222,14 +222,14 @@ public class BukkitHybridUtils extends HybridUtils { while (chunks.size() > 0) { ChunkLoc chunk = chunks.get(0); chunks.remove(0); - regenerateRoad(world, chunk); + regenerateRoad(world, chunk, extend); ChunkManager.manager.unloadChunk(world, chunk); } Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task); TaskManager.runTaskLater(new Runnable() { @Override public void run() { - scheduleRoadUpdate(world, regions); + scheduleRoadUpdate(world, regions, extend); } }, 2400); return; @@ -238,7 +238,7 @@ public class BukkitHybridUtils extends HybridUtils { while (System.currentTimeMillis() < diff && chunks.size() > 0) { ChunkLoc chunk = chunks.get(0); chunks.remove(0); - regenerateRoad(world, chunk); + regenerateRoad(world, chunk, extend); ChunkManager.manager.unloadChunk(world, chunk); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index 06d311fd2..2a7f528aa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -59,14 +59,15 @@ public abstract class HybridUtils { public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy); - public abstract boolean scheduleRoadUpdate(final String world); + public abstract boolean scheduleRoadUpdate(final String world, int extend); - public boolean regenerateRoad(final String world, final ChunkLoc chunk) { + public boolean regenerateRoad(final String world, final ChunkLoc chunk, int extend) { final int x = chunk.x << 4; final int z = chunk.z << 4; final int ex = x + 15; final int ez = z + 15; final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world); + extend = Math.min(extend, 255 - plotworld.ROAD_HEIGHT - plotworld.SCHEMATIC_HEIGHT); if (!plotworld.ROAD_SCHEMATIC_ENABLED) { return false; } @@ -125,7 +126,7 @@ public abstract class HybridUtils { final int sy = plotworld.ROAD_HEIGHT; final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = plotworld.G_SCH.get(loc); - for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) { + for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) { BlockManager.manager.functionSetBlock(world, x + X, y, z + Z, 0, (byte) 0); } if (blocks != null) {