Fix invsee might cause items to disappear (#3065)
Information
This PR fixes #3065.
Details
This is an upstream bug. This PR doesn’t fix it but rather avoids triggering it.
Proposed fix:
Slots 35 ~ 40 refer to player's equipment slots in the server side, but refer to bottom inventory in the client side. When a player(A) try to drag an item into his inventory, Bukkit treats it as dragging to the players(B)'s equipment slots. Since the inventory view cannot display B's equipment slots, A might mistakenly think the item has disappeared. Therefore, this PR added a Listener to cancel the InventoryDragEvent
Environments tested:
OS: MacOS
Java version: 17
- [X ] Paper 1.21
Demonstration:
still need to test this but at first glance I'd want to remove the use of streams + use the isArmorSlot method in the com.earth2me.essentials.craftbukkit.Inventories class to make it more clear what is going on in this code.
I have commit new codes, but one thing to note is that this listener does not only cancel the event of dragging into armor slots but also all events of dragging into the bottom inventory. This is because the slot on the client side does not match the slot on the server side, if not so, the item may appear in a slot that was not dragged to or disappear.