From 2b91f4ebb207673bdef424834f599589bcac410b Mon Sep 17 00:00:00 2001 From: xjboss Date: Sun, 23 Jul 2017 16:58:39 +0800 Subject: [PATCH] Add new version API getClickedInventory --- .../inventory/InventoryClickEvent.java.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 patches/org/bukkit/event/inventory/InventoryClickEvent.java.patch diff --git a/patches/org/bukkit/event/inventory/InventoryClickEvent.java.patch b/patches/org/bukkit/event/inventory/InventoryClickEvent.java.patch new file mode 100644 index 0000000..8b3a9f5 --- /dev/null +++ b/patches/org/bukkit/event/inventory/InventoryClickEvent.java.patch @@ -0,0 +1,36 @@ +--- ../src-base/minecraft/org/bukkit/event/inventory/InventoryClickEvent.java ++++ ../src-work/minecraft/org/bukkit/event/inventory/InventoryClickEvent.java +@@ -52,7 +52,7 @@ + private int rawSlot; + private ItemStack current = null; + private int hotbarKey = -1; +- ++ private Inventory clickedInventory=null; + @Deprecated + public InventoryClickEvent(InventoryView view, SlotType type, int slot, boolean right, boolean shift) { + this(view, type, slot, right ? (shift ? ClickType.SHIFT_RIGHT : ClickType.RIGHT) : (shift ? ClickType.SHIFT_LEFT : ClickType.LEFT), InventoryAction.SWAP_WITH_CURSOR); +@@ -64,6 +64,13 @@ + this.rawSlot = slot; + this.whichSlot = view.convertSlot(slot); + this.click = click; ++ if(slot < 0) { ++ this.clickedInventory = null; ++ } else if(view.getTopInventory() != null && slot < view.getTopInventory().getSize()) { ++ this.clickedInventory = view.getTopInventory(); ++ } else { ++ this.clickedInventory = view.getBottomInventory(); ++ } + this.action = action; + } + +@@ -101,7 +108,9 @@ + } + return getView().getItem(rawSlot); + } +- ++ public Inventory getClickedInventory(){ ++ return this.clickedInventory; ++ } + /** + * Gets whether or not the ClickType for this event represents a right + * click.