From 3540e1f6cad15d5bccb4490cfb37ed7003461715 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 30 Apr 2015 23:57:44 +1000 Subject: [PATCH] Yay! version 2.10 is coming soon. --- PlotSquared/pom.xml | 2 +- .../plot/commands/Unlink.java | 59 +------------------ .../plot/generator/HybridPlotManager.java | 21 +++++++ .../plot/generator/HybridPlotWorld.java | 1 - .../plot/util/ExpireManager.java | 2 +- .../plot/util/MainUtil.java | 59 +++++++++++++++++++ .../plot/util/SetBlockQueue.java | 6 +- .../plot/util/bukkit/BukkitChunkManager.java | 6 +- 8 files changed, 93 insertions(+), 63 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 19b1543f9..fbba2eb39 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.17 + 2.10 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 00b8f64c9..1bd856359 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -66,7 +66,7 @@ public class Unlink extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - if (!unlinkPlot(plot)) { + if (!MainUtil.unlinkPlot(plot)) { MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return; } @@ -81,61 +81,4 @@ public class Unlink extends SubCommand { } return true; } - - public static boolean unlinkPlot(final Plot plot) { - final String world = plot.world; - final PlotId pos1 = MainUtil.getBottomPlot(plot).id; - final PlotId pos2 = MainUtil.getTopPlot(plot).id; - final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); - final boolean result = EventUtil.manager.callUnlink(world, ids); - if (!result) { - return false; - } - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - manager.startPlotUnlink(plotworld, ids); - for (final PlotId id : ids) { - final Plot myplot = PlotSquared.getPlots(world).get(id); - if (plot == null) { - continue; - } - if (plot.helpers != null) { - myplot.helpers = plot.helpers; - } - if (plot.denied != null) { - myplot.denied = plot.denied; - } - myplot.deny_entry = plot.deny_entry; - myplot.settings.setMerged(new boolean[] { false, false, false, false }); - DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); - } - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - final boolean lx = x < pos2.x; - final boolean ly = y < pos2.y; - final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); - if (lx) { - manager.createRoadEast(plotworld, p); - if (ly) { - manager.createRoadSouthEast(plotworld, p); - } - } - if (ly) { - manager.createRoadSouth(plotworld, p); - } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); - } - } - manager.finishPlotUnlink(plotworld, ids); - for (final PlotId id : ids) { - final Plot myPlot = MainUtil.getPlot(world, id); - if (plot.hasOwner()) { - final String name = UUIDHandler.getName(myPlot.owner); - if (name != null) { - MainUtil.setSign(name, myPlot); - } - } - } - return true; - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 83c958490..890306d4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -66,6 +66,27 @@ public class HybridPlotManager extends ClassicPlotManager { Template.zipAll(plotworld.worldname, files); } + @Override + public boolean createRoadEast(PlotWorld plotworld, Plot plot) { + super.createRoadEast(plotworld, plot); + // TODO schematic + return true; + } + + @Override + public boolean createRoadSouth(PlotWorld plotworld, Plot plot) { + super.createRoadSouth(plotworld, plot); + // TODO schematic + return true; + } + + @Override + public boolean createRoadSouthEast(PlotWorld plotworld, Plot plot) { + super.createRoadSouthEast(plotworld, plot); + // TODO schematic + return true; + } + /** * Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync * function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index f73e2ced3..40b67badd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -88,7 +88,6 @@ public class HybridPlotWorld extends ClassicPlotWorld { setupSchematics(); } catch (final Exception e) { PlotSquared.log("&c - road schematics are disabled for this world."); - this.ROAD_SCHEMATIC_ENABLED = false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index ab83c26b2..806ada38c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -107,7 +107,7 @@ public class ExpireManager { return; } if (plot.settings.isMerged()) { - Unlink.unlinkPlot(plot); + MainUtil.unlinkPlot(plot); } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.clearPlot(plotworld, plot, false, null); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c7264c4a6..a6e7c267b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -42,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * plot functions @@ -66,6 +67,64 @@ public class MainUtil { return true; } + public static boolean unlinkPlot(final Plot plot) { + final String world = plot.world; + final PlotId pos1 = MainUtil.getBottomPlot(plot).id; + final PlotId pos2 = MainUtil.getTopPlot(plot).id; + final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); + final boolean result = EventUtil.manager.callUnlink(world, ids); + if (!result) { + return false; + } + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + manager.startPlotUnlink(plotworld, ids); + for (final PlotId id : ids) { + final Plot myplot = PlotSquared.getPlots(world).get(id); + if (plot == null) { + continue; + } + if (plot.helpers != null) { + myplot.helpers = plot.helpers; + } + if (plot.denied != null) { + myplot.denied = plot.denied; + } + myplot.deny_entry = plot.deny_entry; + myplot.settings.setMerged(new boolean[] { false, false, false, false }); + DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); + } + // FIXME unlink augmented + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final boolean lx = x < pos2.x; + final boolean ly = y < pos2.y; + final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); + if (lx) { + manager.createRoadEast(plotworld, p); + if (ly) { + manager.createRoadSouthEast(plotworld, p); + } + } + if (ly) { + manager.createRoadSouth(plotworld, p); + } + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + } + } + manager.finishPlotUnlink(plotworld, ids); + for (final PlotId id : ids) { + final Plot myPlot = MainUtil.getPlot(world, id); + if (plot.hasOwner()) { + final String name = UUIDHandler.getName(myPlot.owner); + if (name != null) { + MainUtil.setSign(name, myPlot); + } + } + } + return true; + } + public static boolean isPlotAreaAbs(final Location location) { final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); if (plotworld.TYPE == 2) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java index 46df665cc..082b27a56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; public class SetBlockQueue { private volatile static HashMap blocks; - private volatile static int allocate = 20; + private volatile static int allocate = 25; private volatile static boolean running = false; private volatile static boolean locked = false; private volatile static HashSet runnables; @@ -21,6 +21,10 @@ public class SetBlockQueue { allocate = t; } + public static int getAllocate() { + return allocate; + } + public synchronized static void addNotify(Runnable whenDone) { if (runnables == null) { TaskManager.runTask(whenDone); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 4884b567c..e78651549 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -61,6 +61,7 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetBlockQueue; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitChunkManager extends ChunkManager { @@ -292,8 +293,11 @@ public class BukkitChunkManager extends ChunkManager { @Override public void run() { long start = System.currentTimeMillis(); - while (System.currentTimeMillis() - start < 20) { + int allocated = SetBlockQueue.getAllocate(); + SetBlockQueue.allocate(0); + while (System.currentTimeMillis() - start < allocated) { if (chunks.size() == 0) { + SetBlockQueue.allocate(SetBlockQueue.getAllocate() + allocated); TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex);