Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Fix invsee might cause items to disappear (#3065)

Open tanyaofei opened this issue 1 year ago • 2 comments

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:

EssentialsX-2.21.0-dev+null-f1a5caf.jar.zip

tanyaofei avatar Aug 12 '24 02:08 tanyaofei

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.

JRoy avatar Mar 24 '25 16:03 JRoy

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.

tanyaofei avatar Mar 25 '25 01:03 tanyaofei