From e792a85c00194f91b28e07e99730899c333de840 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 17:52:32 +1000 Subject: [PATCH] Better UUID conversion --- .../plot/commands/DebugUUID.java | 2 +- .../plot/util/MainUtil.java | 75 ++++++++++++++----- 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 0280dd40a..374419b7b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -217,7 +217,7 @@ public class DebugUUID extends SubCommand { MainUtil.sendConsoleMessage("&7 - Updating plot objects"); - for (Plot plot : PlotSquared.getPlots()) { + for (Plot plot : PlotSquared.getPlotsRaw()) { UUID value = uCMap.get(plot.owner); if (value != null) { plot.owner = value; 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 5ec80bad2..0325ea75c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -94,26 +94,21 @@ public class MainUtil { myplot.settings.setMerged(new boolean[] { false, false, false, false }); DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); } - if (plotworld.TYPE != 0 && plotworld.TERRAIN < 2) { - // FIXME unlink augmented - } - else { - 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); - } - } + 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.createRoadSouth(plotworld, p); + manager.createRoadSouthEast(plotworld, p); } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } + if (ly) { + manager.createRoadSouth(plotworld, p); + } + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } } manager.finishPlotUnlink(plotworld, ids); @@ -424,7 +419,7 @@ public class MainUtil { if (lx) { if (ly) { if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { - if (removeRoads) { + if (removeRoads) { manager.removeRoadSouthEast(plotworld, plot); } } @@ -456,7 +451,51 @@ public class MainUtil { manager.finishPlotMerge(plotworld, plotIds); return true; } + + public static void removeRoadSouthEast(PlotWorld plotworld, Plot plot) { + if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x + 1, id.y + 1); + Location pos1 = getPlotTopLoc(plot.world, id).add(1, 0, 1); + Location pos2 = getPlotBottomLoc(plot.world, id2); + ChunkManager.manager.regenerateRegion(pos1, pos2, null); + } + else { + PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + } + } + + public static void removeRoadEast(PlotWorld plotworld, Plot plot) { + if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x + 1, id.y); + Location bot = getPlotBottomLocAbs(plot.world, id2); + Location top = getPlotTopLocAbs(plot.world, id); + Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() + 1); + Location pos2 = new Location(plot.world, bot.getX(), 0, top.getZ()); + ChunkManager.manager.regenerateRegion(pos1, pos2, null); + } + else { + PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + } + } + + public static void removeRoadSouth(PlotWorld plotworld, Plot plot) { + if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x, id.y + 1); + Location bot = getPlotBottomLocAbs(plot.world, id2); + Location top = getPlotTopLocAbs(plot.world, id); + Location pos1 = new Location(plot.world, bot.getX() + 1, 0, top.getZ() + 1); + Location pos2 = new Location(plot.world, top.getX(), 0, bot.getZ()); + ChunkManager.manager.regenerateRegion(pos1, pos2, null); + } + else { + PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + } + } + /** * Merges 2 plots Removes the road inbetween
- Assumes the first plot parameter is lower
- Assumes neither * are a Mega-plot
- Assumes plots are directly next to each other
- Saves to DB