[SPIGOT-3228] InventoryClickEvent.getClickedInventory() returns wrong inventory. Created: 06/May/17 Updated: 07/May/17 Resolved: 07/May/17 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Magyar Dávid | Assignee: | Unassigned |
Resolution: | Cannot Reproduce | Votes: | 0 |
Labels: | InventoryClickEvent, inventory | ||
Environment: |
SPIGOT: git-Spigot-a3f6ea5-a2af8f0 (MC: 1.11.2) OS: Windows 8.1 |
Attachments: |
![]() |
Description |
Inventory.getClickedInventory() returns different value for clicking one inventory in the first and last rows, if the top inventory is a Dropper inventory typed one. I guess the problem is that the top inventory is not a Chest typed and the index checking of which inventory contains the given clicked RawIndex is miscalculated. Depending on the .getClickedInventory(), it returns the top inventory for some slots of the botton inventory's top slots.
Occurance details: _*Attacked file:*_ The problem, I guess: |
Comments |
Comment by Magyar Dávid [ 07/May/17 ] |
EDIT: My bad, but the top inventory was Dropper inventory, meanwhile the InventoryView.getType() was overwritten and returned ShulkerBox. Maybe. I'm currently digging into it. UPDATE: yeah, it was my bad, I returned a ShulkerInventory for the .getTopInventory() and the type of another inventory, a DropperInventory's type for the .getType(). SUGGESTION: You could define the .getType() method in the abstract InventoryView class, if possible, to return the type of the result of .getTopInventory(), since it MUST match, unless misindexing will occur, like in my case. For now, it's up to the programmer to implement the InventoryView correctly, that way it will be more ... safe code. Thank you, for caring about Spigot and investigated my issue! |
Comment by md_5 [ 07/May/17 ] |
Cannot reproduce, all slots return Dropper: @EventHandler public void click(InventoryClickEvent event) { getServer().broadcastMessage( "Clicked: " + event.getClickedInventory().getType()); } |