Permalink
Browse files

Added offhand support to PlayerInventorySensor.

  • Loading branch information...
me4502 committed Feb 5, 2017
1 parent d6d72e3 commit d445b28d8e4b41290f4f139ee48284086fea78aa
@@ -104,7 +104,8 @@ public boolean testPlayer(Player e) {
if(slot == -1 && !inHand)
return e.getInventory().containsAtLeast(item, item.getAmount());
else if (inHand) { //Eclipse messes with indentation without these {'s
- return e.getItemInHand() != null && ItemUtil.areItemsIdentical(e.getItemInHand(), item) && e.getItemInHand().getAmount() >= item.getAmount();
+ return (e.getInventory().getItemInMainHand() != null && ItemUtil.areItemsIdentical(e.getInventory().getItemInMainHand(), item) && e.getInventory().getItemInMainHand().getAmount() >= item.getAmount())
+ || (e.getInventory().getItemInOffHand() != null && ItemUtil.areItemsIdentical(e.getInventory().getItemInOffHand(), item) && e.getInventory().getItemInOffHand().getAmount() >= item.getAmount());
}
else if (slot > -1) {
return e.getInventory().getItem(slot) != null && ItemUtil.areItemsIdentical(e.getInventory().getItem(slot), item) && e.getInventory().getItem(slot).getAmount() >= item.getAmount();

0 comments on commit d445b28

Please sign in to comment.