From f5682c354abb24bd2b7082106f2311771837b5af Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 12 Mar 2016 12:13:18 +0100 Subject: [PATCH] 0.2h Improve InventoryUtil --- .../massivecore/util/InventoryUtil.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/com/massivecraft/massivecore/util/InventoryUtil.java b/src/com/massivecraft/massivecore/util/InventoryUtil.java index 72218196..82663fdb 100644 --- a/src/com/massivecraft/massivecore/util/InventoryUtil.java +++ b/src/com/massivecraft/massivecore/util/InventoryUtil.java @@ -60,19 +60,32 @@ public class InventoryUtil // EVENT INTERPRETATION // -------------------------------------------- // + public static boolean isOutside(int rawSlot) + { + return rawSlot < 0; + } + public static boolean isTopInventory(int rawSlot, Inventory inventory) + { + if (isOutside(rawSlot)) return false; + return rawSlot < inventory.getSize(); + } + public static boolean isBottomInventory(int rawSlot, Inventory inventory) + { + if (isOutside(rawSlot)) return false; + return rawSlot >= inventory.getSize(); + } + public static boolean isOutside(InventoryClickEvent event) { - return event.getRawSlot() < 0; + return isOutside(event.getRawSlot()); } public static boolean isTopInventory(InventoryClickEvent event) { - if (isOutside(event)) return false; - return event.getRawSlot() < event.getInventory().getSize(); + return isTopInventory(event.getRawSlot(), event.getInventory()); } public static boolean isBottomInventory(InventoryClickEvent event) { - if (isOutside(event)) return false; - return event.getRawSlot() >= event.getInventory().getSize(); + return isBottomInventory(event.getRawSlot(), event.getInventory()); } @Deprecated