From 42c02b37bf63f66e2c819b7a44ed94c107a9381f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 16 Dec 2014 15:44:25 +1100 Subject: [PATCH] Fixes plot claim block removing on clear. --- .../intellectualcrafters/plot/PlotMain.java | 2 +- .../plot/commands/Clear.java | 7 ++- .../plot/commands/Delete.java | 2 +- .../plot/commands/SetOwner.java | 1 - .../plot/commands/Unlink.java | 4 +- .../plot/generator/DefaultPlotManager.java | 61 +++---------------- .../plot/listeners/PlayerEvents.java | 2 +- .../plot/object/Plot.java | 4 +- .../plot/object/PlotManager.java | 4 +- .../plot/util/PlotHelper.java | 12 ++-- 10 files changed, 31 insertions(+), 68 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 22cc3b62c..2757bf3ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -579,7 +579,7 @@ public class PlotMain extends JavaPlugin { } for (final Plot plot : toDeletePlot) { final World worldobj = Bukkit.getWorld(world); - PlotHelper.clear(worldobj, plot); + PlotHelper.clear(worldobj, plot, true); PlotHelper.removeSign(worldobj, plot); DBFunc.delete(world, plot); removePlot(world, plot.id, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 48acfb101..4d9c306f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -57,7 +57,7 @@ public class Clear extends SubCommand { if (plot == null) { PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); } else { - plot.clear(null); + plot.clear(null, false); PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); } } @@ -78,6 +78,11 @@ public class Clear extends SubCommand { } assert plot != null; plot.clear(plr); + + // sign + + // wall + return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 4e9034963..366870db1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -60,7 +60,7 @@ public class Delete extends SubCommand { } final boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); if (result) { - plot.clear(plr); + plot.clear(plr, true); DBFunc.delete(plr.getWorld().getName(), plot); if ((Math.abs(plot.id.x) <= Math.abs(Auto.lastPlot.x)) && (Math.abs(plot.id.y) <= Math.abs(Auto.lastPlot.y))) { Auto.lastPlot = plot.id; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index f5d59fd32..a4169ab5e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -81,7 +81,6 @@ public class SetOwner extends SubCommand { PlotMain.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); } } - PlotHelper.setSign(world, args[0], plot); PlayerFunctions.sendMessage(plr, C.SET_OWNER); 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 c293f5b05..c7a48e808 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -32,6 +32,8 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.SetBlockFast; +import com.intellectualcrafters.plot.util.UUIDHandler; + import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; @@ -115,7 +117,7 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - + PlotHelper.setSign(plr.getWorld(), UUIDHandler.getName(plot.owner), plot); } } try { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java index ba7c60c77..ec34b5a06 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java @@ -223,56 +223,6 @@ public class DefaultPlotManager extends PlotManager { return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z); } - - public void clearPlotAsync(final World world, final Plot plot) { - PlotHelper.runners.put(plot, 1); - final DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world)); - - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); - - final PlotBlock[] plotfloor = dpw.TOP_BLOCK; - final PlotBlock[] filling = dpw.MAIN_BLOCK; - - // PlotBlock wall = dpw.WALL_BLOCK; - final PlotBlock wall = dpw.WALL_BLOCK; - - final PlotBlock wall_filling = dpw.WALL_FILLING; - - Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, 1, pos1.getBlockZ())); - if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) { - setWallFilling(world, dpw, plot.id, wall_filling); - } - - block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, dpw.WALL_HEIGHT + 1, pos1.getBlockZ())); - if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) { - setWall(world, dpw, plot.id, wall); - } - int count = 10000; - - int s_x = pos1.getBlockX(); - int s_y = 0; - int s_z = pos1.getBlockZ(); - - int e_x = pos2.getBlockX(); - int e_y = world.getMaxHeight(); - int e_z = pos2.getBlockZ(); - - Plugin plugin = (Plugin) PlotMain.getMain(); - - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - // TODO Auto-generated method stub - } - }, 1L); - - PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); - - } /** * Clearing the plot needs to only consider removing the blocks - This @@ -283,7 +233,7 @@ public class DefaultPlotManager extends PlotManager { * plots */ @Override - public boolean clearPlot(final World world, final Plot plot) { + public boolean clearPlot(final World world, final Plot plot, boolean isDelete) { PlotHelper.runners.put(plot, 1); final Plugin plugin = (Plugin) PlotMain.getMain(); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { @@ -299,7 +249,14 @@ public class DefaultPlotManager extends PlotManager { final PlotBlock[] filling = dpw.MAIN_BLOCK; // PlotBlock wall = dpw.WALL_BLOCK; - final PlotBlock wall = dpw.WALL_BLOCK; + final PlotBlock wall; + + if (isDelete) { + wall = dpw.WALL_BLOCK; + } + else { + wall = dpw.CLAIMED_WALL_BLOCK; + } final PlotBlock wall_filling = dpw.WALL_FILLING; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 84137b4e4..cf3f06244 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -550,7 +550,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Set plots = PlotMain.getPlots(event.getPlayer()); for (final Plot plot : plots) { final PlotManager manager = PlotMain.getPlotManager(plot.getWorld()); - manager.clearPlot(null, plot); + manager.clearPlot(null, plot, true); DBFunc.delete(plot.getWorld().getName(), plot); PlotMain.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 794438915..3afc1fd54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -342,8 +342,8 @@ public class Plot implements Cloneable { * * @param plr initiator */ - public void clear(final Player plr) { - PlotHelper.clear(plr, this); + public void clear(final Player plr, boolean isDelete) { + PlotHelper.clear(plr, this, isDelete); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 3896bec0b..323571256 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -51,8 +51,8 @@ public abstract class PlotManager { * Plot clearing (return false if you do not support some method) */ - public abstract boolean clearPlot(final World world, final Plot plot); - + public abstract boolean clearPlot(final World world, final Plot plot, boolean isDelete); + public abstract Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot); /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index bb3c12067..a7b66e220 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -683,7 +683,7 @@ public class PlotHelper { } } - public static void clear(final World world, final Plot plot) { + public static void clear(final World world, final Plot plot, final boolean isDelete) { if (runners.containsKey(plot)) { PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); return; @@ -698,7 +698,7 @@ public class PlotHelper { h = (prime * h) + pos1.getBlockZ(); state = h; - manager.clearPlot(world, plot); + manager.clearPlot(world, plot, isDelete); if (canSetFast) { final Plugin plugin = (Plugin) PlotMain.getMain(); @@ -715,10 +715,10 @@ public class PlotHelper { * @param requester * @param plot */ - public static void clear(final Player requester, final Plot plot) { + public static void clear(final Player requester, final Plot plot, final boolean isDelete) { if (requester == null) { clearAllEntities(plot.getWorld(), plot, false); - clear(plot.getWorld(), plot); + clear(plot.getWorld(), plot, isDelete); removeSign(plot.getWorld(), plot); return; } @@ -735,11 +735,11 @@ public class PlotHelper { world = requester.getWorld(); clearAllEntities(world, plot, false); - clear(world, plot); + clear(world, plot, isDelete); removeSign(world, plot); final Plugin plugin = (Plugin) PlotMain.getMain(); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start) / 1000.0))); + PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start)))); } }, 90L); }