mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Only handle primary input in block interact event handler.
This commit is contained in:
parent
900c9b5258
commit
ff7d5aad1a
@ -25,6 +25,7 @@ import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
|
|||||||
import com.sk89q.worldedit.command.tool.Tool;
|
import com.sk89q.worldedit.command.tool.Tool;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.event.actor.BlockInteractEvent;
|
import com.sk89q.worldedit.event.actor.BlockInteractEvent;
|
||||||
|
import com.sk89q.worldedit.event.actor.InteractionType;
|
||||||
import com.sk89q.worldedit.internal.ServerInterfaceAdapter;
|
import com.sk89q.worldedit.internal.ServerInterfaceAdapter;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -209,45 +210,47 @@ public class PlatformManager {
|
|||||||
|
|
||||||
// At this time, only handle interaction from players
|
// At this time, only handle interaction from players
|
||||||
if (actor instanceof Player) {
|
if (actor instanceof Player) {
|
||||||
Player player = (Player) actor;
|
if (event.getType() == InteractionType.PRIMARY_INPUT) {
|
||||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
Player player = (Player) actor;
|
||||||
|
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||||
|
|
||||||
if (player.getItemInHand() == getConfiguration().wandItem) {
|
if (player.getItemInHand() == getConfiguration().wandItem) {
|
||||||
if (!session.isToolControlEnabled()) {
|
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));
|
|
||||||
return;
|
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 (player instanceof LocalPlayer) { // Temporary workaround
|
||||||
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
LocalPlayer localPlayer = (LocalPlayer) player;
|
||||||
if (tool.canUse(localPlayer)) {
|
WorldVector worldVector = new WorldVector(location);
|
||||||
((DoubleActionBlockTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector);
|
|
||||||
event.setCancelled(true);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user