From cf30a6301847832db495711cb5e1d9ee0091bcde Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Sun, 20 Nov 2011 02:00:12 +0100 Subject: [PATCH] Further cleanup of input handlers. Slight deviation from previous behaviour: Wand and navigation wand can no longer be used as ordinary tool binds. However, these are already blocked elsewhere anyway, so it is unimportant. --- .../java/com/sk89q/worldedit/WorldEdit.java | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 835b127b9..6d69dd13e 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -1092,12 +1092,17 @@ public class WorldEdit { * @return false if you want the action to go through */ public boolean handleBlockRightClick(LocalPlayer player, WorldVector clicked) { - int itemInHand = player.getItemInHand(); - LocalSession session = getSession(player); - if (itemInHand == config.wandItem && session.isToolControlEnabled() - && player.hasPermission("worldedit.selection.pos")) { + if (player.getItemInHand() == config.wandItem) { + if (!session.isToolControlEnabled()) { + return false; + } + + if (!player.hasPermission("worldedit.selection.pos")) { + return false; + } + RegionSelector selector = session.getRegionSelector(player.getWorld()); if (selector.selectSecondary(clicked)) { selector.explainSecondarySelection(player, session, clicked); @@ -1107,7 +1112,6 @@ public class WorldEdit { } Tool tool = session.getTool(player.getItemInHand()); - if (tool != null && tool instanceof BlockTool) { if (tool.canUse(player)) { ((BlockTool)tool).actPrimary(server, config, player, session, clicked); @@ -1129,27 +1133,30 @@ public class WorldEdit { LocalSession session = getSession(player); if (player.getItemInHand() == config.wandItem) { - if (session.isToolControlEnabled() - && player.hasPermission("worldedit.selection.pos")) { - - RegionSelector selector = session.getRegionSelector(player.getWorld()); - if (selector.selectPrimary(clicked)) { - selector.explainPrimarySelection(player, session, clicked); - } - - return true; + if (!session.isToolControlEnabled()) { + return false; } - } else if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) { - if (session.getSuperPickaxe() != null) { - if (session.getSuperPickaxe().canUse(player)) { - return session.getSuperPickaxe().actPrimary(server, config, - player, session, clicked); - } + + if (!player.hasPermission("worldedit.selection.pos")) { + return false; + } + + RegionSelector selector = session.getRegionSelector(player.getWorld()); + if (selector.selectPrimary(clicked)) { + selector.explainPrimarySelection(player, session, clicked); + } + + return true; + } + + if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) { + final BlockTool superPickaxe = session.getSuperPickaxe(); + if (superPickaxe != null && superPickaxe.canUse(player)) { + return superPickaxe.actPrimary(server, config, player, session, clicked); } } Tool tool = session.getTool(player.getItemInHand()); - if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool.canUse(player)) { ((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked);