From 6818ff28ba7f2d1b17ad66b5f590f414e47a6a5a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 3 Sep 2016 16:34:25 +1000 Subject: [PATCH] Fix VS brushes which require multiple clicks --- .gitignore | 2 +- .../fawe/bukkit/wrapper/AsyncWorld.java | 17 +++++++---- .../com/thevoxelbox/voxelsniper/Sniper.java | 28 +++++++------------ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 448da87b..9f79b0b1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ gradle.log /bukkit19/build /bukkit18/build build -mvn/com/boydti/fawe-api/unknown/fawe-api-unknown.jar \ No newline at end of file +/mvn \ No newline at end of file diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index 1697aaee..3a233281 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -16,7 +16,6 @@ import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID; -import java.util.concurrent.atomic.AtomicBoolean; import org.bukkit.BlockChangeDelegate; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -60,8 +59,8 @@ import org.bukkit.util.Vector; */ public class AsyncWorld implements World { - private final World parent; - private final FaweQueue queue; + private World parent; + private FaweQueue queue; private BukkitImplAdapter adapter; /** @@ -109,6 +108,12 @@ public class AsyncWorld implements World { return new AsyncWorld(world, false); } + public void changeWorld(World world, FaweQueue queue) { + flush(); + this.parent = world; + this.queue = queue; + } + public World getParent() { return parent; } @@ -117,8 +122,6 @@ public class AsyncWorld implements World { return queue; } - private static AtomicBoolean loading = new AtomicBoolean(false); - /** * Create a world async (untested) * - Only optimized for 1.10 @@ -140,7 +143,9 @@ public class AsyncWorld implements World { } public void flush() { - queue.flush(); + if (queue != null) { + queue.flush(); + } } @Override diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java index 2e8953f0..352dd3c0 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Sniper.java @@ -75,14 +75,17 @@ public class Sniper { } // Added - private AsyncWorld tmpWorld; + private AsyncWorld permanentWorld; private MaskedFaweQueue maskQueue; private ChangeSetFaweQueue changeQueue; private FaweQueue baseQueue; // Added public AsyncWorld getWorld() { - if (this.tmpWorld == null) { + if (permanentWorld == null) { + permanentWorld = new AsyncWorld(null, null); + } + if (this.maskQueue == null) { Player player = getPlayer(); FawePlayer fp = FawePlayer.wrap(player); if (this.baseQueue == null || !StringMan.isEqual(baseQueue.getWorldName(), player.getWorld().getName())) { @@ -96,9 +99,9 @@ public class Sniper { changeSet = LoggingChangeSet.wrap(fp, changeSet); } this.changeQueue = new ChangeSetFaweQueue(changeSet, maskQueue); - tmpWorld = new AsyncWorld(player.getWorld(), changeQueue); + permanentWorld.changeWorld(player.getWorld(), changeQueue); } - return tmpWorld; + return permanentWorld; } public Player getPlayer() { @@ -123,7 +126,7 @@ public class Sniper { if (fp.getMeta("fawe_action") != null) { return false; } - tmpWorld = null; + maskQueue = null; if (clickedBlock != null) { clickedBlock = getWorld().getBlockAt(clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); } @@ -155,7 +158,6 @@ public class Sniper { getPlayer().sendMessage("No Brush selected."); return true; } - if (!getPlayer().hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) { getPlayer().sendMessage("You are not allowed to use this brush. You're missing the permission node '" + sniperTool.getCurrentBrush().getPermissionNode() + "'"); return true; @@ -293,17 +295,7 @@ public class Sniper { } } -// if (sniperTool.getCurrentBrush() instanceof PerformBrush) { -// PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush(); -// performerBrush.initP(snipeData); -// } -// -// boolean result = sniperTool.getCurrentBrush().perform(snipeAction, snipeData, targetBlock, lastBlock); -// if (result) { -// MetricsManager.increaseBrushUsage(sniperTool.getCurrentBrush().getName()); -// } -// return result; - final IBrush brush = sniperTool.getCurrentBrush(); + final IBrush brush = sniperTool.getCurrentBrush(); if (sniperTool.getCurrentBrush() instanceof PerformBrush) { PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush(); performerBrush.initP(snipeData); @@ -401,7 +393,7 @@ public class Sniper { changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID()); changeQueue.setChangeSet(changeSet); // NEW QUEUE? - tmpWorld = null; + maskQueue = null; baseQueue = null; changeQueue = null; }