Only handle primary input in block interact event handler.

This commit is contained in:
sk89q 2014-06-26 16:58:54 -07:00
parent 900c9b5258
commit ff7d5aad1a

View File

@ -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);
}
}
}
}