From 1c7f7a2dfc82fc06bc2ace78854f53cfcd6063f6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Apr 2015 18:30:27 +1100 Subject: [PATCH] Various fixes Fixed issue with augmented plot world and mob / entity interaction Fixed an issue with async plot diff calculation including upper chunks outside of plot in result PlotMeConverter will now try a force save of the PS configuration right away Incremented version number Tweaked behaviour of plot list command --- PlotSquared/pom.xml | 2 +- .../plot/commands/list.java | 12 +++++++++--- .../plot/database/PlotMeConverter.java | 2 ++ .../plot/generator/BukkitHybridUtils.java | 19 ++++++++----------- .../plot/generator/HybridUtils.java | 3 ++- .../plot/listeners/PlayerEvents.java | 3 +++ .../plot/listeners/PlayerEvents_1_8.java | 3 +++ .../plot/object/RunnableVal.java | 7 +++++++ 8 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index d47a65424..7dc265d95 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.4 + 2.9.5 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index d563738d9..26974a642 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -192,12 +192,18 @@ public class list extends SubCommand { return false; } - displayPlots(plr, plots, page); + displayPlots(plr, plots, page, world); return true; } - public void displayPlots(PlotPlayer player, Collection oldPlots, int page) { - ArrayList plots = PlotSquared.sortPlots(oldPlots); + public void displayPlots(PlotPlayer player, Collection oldPlots, int page, String world) { + ArrayList plots; + if (world != null) { + plots = PlotSquared.sortPlots(oldPlots, world); + } + else { + plots = PlotSquared.sortPlots(oldPlots); + } if (page < 0) { page = 0; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index c4c554815..c7c9c927a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -250,6 +250,7 @@ public class PlotMeConverter { height = 64; } PlotSquared.config.set("worlds." + world + ".road.height", height); + PlotSquared.config.save(PlotSquared.configFile); } catch (final Exception e) { sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } @@ -300,6 +301,7 @@ public class PlotMeConverter { PlotSquared.config.set("worlds." + world + ".road.height", height); PlotSquared.config.set("worlds." + world + ".plot.height", height); PlotSquared.config.set("worlds." + world + ".wall.height", height); + PlotSquared.config.save(PlotSquared.configFile); } } catch (final Exception e) { } 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 8ccb66eaa..683863e6b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -21,6 +21,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; @@ -29,7 +30,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { - public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone, final Runnable ifFailed) { + public void checkModified(final Plot plot, final RunnableVal whenDone) { TaskManager.index.increment(); final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); @@ -41,7 +42,6 @@ public class BukkitHybridUtils extends HybridUtils { int tx = top.getX() >> 4; int tz = top.getZ() >> 4; - int size = (tx-bx) << 4; World world = BukkitUtil.getWorld(plot.world); final HashSet chunks = new HashSet<>(); @@ -53,6 +53,7 @@ public class BukkitHybridUtils extends HybridUtils { PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); if (!(plotworld instanceof ClassicPlotWorld)) { + whenDone.value = -1; TaskManager.runTaskLater(whenDone, 1); return; } @@ -65,23 +66,19 @@ public class BukkitHybridUtils extends HybridUtils { final Integer task = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { - if (count.intValue() >= requiredChanges) { - TaskManager.runTaskLater(whenDone, 1); - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); - TaskManager.tasks.remove(currentIndex); - return; - } if (chunks.size() == 0) { - TaskManager.runTaskLater(ifFailed, 1); + whenDone.value = 0; + TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); return; } final Chunk chunk = chunks.iterator().next(); + chunks.iterator().remove(); int bx = Math.max(chunk.getX() >> 4, bot.getX()); int bz = Math.max(chunk.getZ() >> 4, bot.getZ()); - int ex = Math.max((chunk.getX() >> 4) + 15, top.getX()); - int ez = Math.max((chunk.getZ() >> 4) + 15, top.getZ()); + int ex = Math.min((chunk.getX() >> 4) + 15, top.getX()); + int ez = Math.min((chunk.getZ() >> 4) + 15, top.getZ()); // count changes count.add(checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK)); count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK)); 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 a561df522..464ab3b5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; @@ -21,7 +22,7 @@ public abstract class HybridUtils { public static HybridUtils manager; - public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed, Runnable ifFailed); + public abstract void checkModified(final Plot plot, final RunnableVal whenDone); public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); 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 483484031..f359d9e45 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -1060,6 +1060,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { + if (!isPlotArea(l)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 074f4be4d..f2651086e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -23,6 +23,9 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(l)) { + if (!isPlotArea(l)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java new file mode 100644 index 000000000..3a4c41241 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java @@ -0,0 +1,7 @@ +package com.intellectualcrafters.plot.object; + +public abstract class RunnableVal implements Runnable { + public Object value; + + public abstract void run(); +}