Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invsee might cause items to disappear (#3065) #5902

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

tanyaofei
Copy link

@tanyaofei tanyaofei commented Aug 12, 2024

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

@mdcfe mdcfe self-requested a review August 25, 2024 21:59
@JRoy JRoy added this to the 2.21.1 milestone Mar 24, 2025
@JRoy
Copy link
Member

JRoy commented Mar 24, 2025

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.

@tanyaofei
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Items are randomly swapped and deleted when using invsee
2 participants