Skip to content

Commit

Permalink
swap order of checks
Browse files Browse the repository at this point in the history
since a boolean check is faster than getting inventory item + string
comparison
  • Loading branch information
boy0001 committed Apr 3, 2019
1 parent 3d2054a commit 9ba1121
Showing 1 changed file with 3 additions and 11 deletions.
Expand Up @@ -321,11 +321,7 @@ public void handleBlockInteract(BlockInteractEvent event) {

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;
}
Expand All @@ -341,7 +337,7 @@ public void handleBlockInteract(BlockInteractEvent event) {
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));
Expand All @@ -358,11 +354,7 @@ public void handleBlockInteract(BlockInteractEvent event) {
}

} 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;
}
Expand Down

0 comments on commit 9ba1121

Please sign in to comment.