From 9ba11215921bbdd9121c506f279aadb034a93313 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 4 Apr 2019 10:45:21 +1100 Subject: [PATCH] swap order of checks since a boolean check is faster than getting inventory item + string comparison --- .../extension/platform/PlatformManager.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 1f124dd23..3b8347e7d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -321,11 +321,7 @@ public class PlatformManager { try { if (event.getType() == Interaction.HIT) { - if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { - if (!session.isToolControlEnabled()) { - return; - } - + if (session.isToolControlEnabled() && player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { if (!actor.hasPermission("worldedit.selection.pos")) { return; } @@ -341,7 +337,7 @@ public class PlatformManager { return; } - if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) { + if (session.hasSuperPickAxe() && player.isHoldingPickAxe()) { final BlockTool superPickaxe = session.getSuperPickaxe(); if (superPickaxe != null && superPickaxe.canUse(player)) { event.setCancelled(superPickaxe.actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location)); @@ -358,11 +354,7 @@ public class PlatformManager { } } else if (event.getType() == Interaction.OPEN) { - if (player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { - if (!session.isToolControlEnabled()) { - return; - } - + if (session.isToolControlEnabled() && player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { if (!actor.hasPermission("worldedit.selection.pos")) { return; }