From ff7d5aad1aa5912f729e026a0f721bfce2ba3f19 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 26 Jun 2014 16:58:54 -0700 Subject: [PATCH] Only handle primary input in block interact event handler. --- .../extension/platform/PlatformManager.java | 71 ++++++++++--------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index e6843853e..9a5bd4347 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.command.tool.DoubleActionBlockTool; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.actor.BlockInteractEvent; +import com.sk89q.worldedit.event.actor.InteractionType; import com.sk89q.worldedit.internal.ServerInterfaceAdapter; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.util.Location; @@ -209,45 +210,47 @@ public class PlatformManager { // At this time, only handle interaction from players if (actor instanceof Player) { - Player player = (Player) actor; - LocalSession session = worldEdit.getSessionManager().get(actor); + if (event.getType() == InteractionType.PRIMARY_INPUT) { + Player player = (Player) actor; + LocalSession session = worldEdit.getSessionManager().get(actor); - if (player.getItemInHand() == getConfiguration().wandItem) { - if (!session.isToolControlEnabled()) { - return; - } - - if (!actor.hasPermission("worldedit.selection.pos")) { - return; - } - - RegionSelector selector = session.getRegionSelector(player.getWorld()); - - if (selector.selectPrimary(location.toVector())) { - selector.explainPrimarySelection(actor, session, vector); - } - - event.setCancelled(true); - return; - } - - if (player instanceof LocalPlayer) { // Temporary workaround - LocalPlayer localPlayer = (LocalPlayer) player; - WorldVector worldVector = new WorldVector(location); - - if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) { - final BlockTool superPickaxe = session.getSuperPickaxe(); - if (superPickaxe != null && superPickaxe.canUse(localPlayer)) { - event.setCancelled(superPickaxe.actPrimary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector)); + if (player.getItemInHand() == getConfiguration().wandItem) { + if (!session.isToolControlEnabled()) { return; } + + if (!actor.hasPermission("worldedit.selection.pos")) { + return; + } + + RegionSelector selector = session.getRegionSelector(player.getWorld()); + + if (selector.selectPrimary(location.toVector())) { + selector.explainPrimarySelection(actor, session, vector); + } + + event.setCancelled(true); + return; } - Tool tool = session.getTool(player.getItemInHand()); - if (tool != null && tool instanceof DoubleActionBlockTool) { - if (tool.canUse(localPlayer)) { - ((DoubleActionBlockTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector); - event.setCancelled(true); + if (player instanceof LocalPlayer) { // Temporary workaround + LocalPlayer localPlayer = (LocalPlayer) player; + WorldVector worldVector = new WorldVector(location); + + if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) { + final BlockTool superPickaxe = session.getSuperPickaxe(); + if (superPickaxe != null && superPickaxe.canUse(localPlayer)) { + event.setCancelled(superPickaxe.actPrimary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector)); + return; + } + } + + Tool tool = session.getTool(player.getItemInHand()); + if (tool != null && tool instanceof DoubleActionBlockTool) { + if (tool.canUse(localPlayer)) { + ((DoubleActionBlockTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector); + event.setCancelled(true); + } } } }