Skip to content

Commit

Permalink
Fix some bugs in click events
Browse files Browse the repository at this point in the history
  • Loading branch information
bensku committed Mar 17, 2016
1 parent 69e0d75 commit 75e475d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/ch/njol/skript/events/EvtClick.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private boolean checkOffHandUse(@Nullable ItemStack mainHand, @Nullable ItemStac
if (mainHand == null) mainHand = new ItemStack(Material.AIR);

if (clickType == RIGHT) {
if (offHand == null || offHand.getType() == Material.AIR) return false;
if (offHand == null) return false;
switch (offHand.getType()) {
case BOW:
case EGG:
Expand Down Expand Up @@ -257,7 +257,9 @@ private boolean checkOffHandUse(@Nullable ItemStack mainHand, @Nullable ItemStac

if (mainHand.getType().isBlock() || mainHand.getType().isEdible()) {
mainUsable = true;
} else if (target != null) {
}

if (target != null) {
switch (target.getType()) {
case ANVIL:
case BEACON:
Expand Down Expand Up @@ -293,11 +295,15 @@ private boolean checkOffHandUse(@Nullable ItemStack mainHand, @Nullable ItemStac
case WOOD_BUTTON:
case STONE_BUTTON:
case COMMAND:
if (!player.isSneaking()) mainUsable = true;
if (player.isSneaking()) {
if (offHand.getType() == Material.AIR && mainHand.getType() != Material.AIR) return true;
} else {
mainUsable = true;
}
}
}
}

if (mainUsable) return false;
else if (offUsable) return true;
else return false;
Expand Down

0 comments on commit 75e475d

Please sign in to comment.