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.
This commit is contained in:
TomyLobo 2011-11-20 02:00:12 +01:00
parent 71d302c893
commit cf30a63018

View File

@ -1092,12 +1092,17 @@ public class WorldEdit {
* @return false if you want the action to go through * @return false if you want the action to go through
*/ */
public boolean handleBlockRightClick(LocalPlayer player, WorldVector clicked) { public boolean handleBlockRightClick(LocalPlayer player, WorldVector clicked) {
int itemInHand = player.getItemInHand();
LocalSession session = getSession(player); LocalSession session = getSession(player);
if (itemInHand == config.wandItem && session.isToolControlEnabled() if (player.getItemInHand() == config.wandItem) {
&& player.hasPermission("worldedit.selection.pos")) { if (!session.isToolControlEnabled()) {
return false;
}
if (!player.hasPermission("worldedit.selection.pos")) {
return false;
}
RegionSelector selector = session.getRegionSelector(player.getWorld()); RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectSecondary(clicked)) { if (selector.selectSecondary(clicked)) {
selector.explainSecondarySelection(player, session, clicked); selector.explainSecondarySelection(player, session, clicked);
@ -1107,7 +1112,6 @@ public class WorldEdit {
} }
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof BlockTool) { if (tool != null && tool instanceof BlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((BlockTool)tool).actPrimary(server, config, player, session, clicked); ((BlockTool)tool).actPrimary(server, config, player, session, clicked);
@ -1129,27 +1133,30 @@ public class WorldEdit {
LocalSession session = getSession(player); LocalSession session = getSession(player);
if (player.getItemInHand() == config.wandItem) { if (player.getItemInHand() == config.wandItem) {
if (session.isToolControlEnabled() if (!session.isToolControlEnabled()) {
&& player.hasPermission("worldedit.selection.pos")) { return false;
RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectPrimary(clicked)) {
selector.explainPrimarySelection(player, session, clicked);
}
return true;
} }
} else if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
if (session.getSuperPickaxe() != null) { if (!player.hasPermission("worldedit.selection.pos")) {
if (session.getSuperPickaxe().canUse(player)) { return false;
return session.getSuperPickaxe().actPrimary(server, config, }
player, session, clicked);
} 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()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool != null && tool instanceof DoubleActionBlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked); ((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked);