Paper icon indicating copy to clipboard operation
Paper copied to clipboard

InventoryCloseEvent not firing.

Open RockinChaos opened this issue 6 years ago • 10 comments

What behaviour is expected:

InventoryCloseEvent should fire when the player closes their inventory.

What behaviour is observed:

InventoryCloseEvent is never fired.

Steps/models to reproduce:

1.) Create and register an InventoryCloseEvent. 2.) Set it to output a debug message. 3.) Open inventory via e then close it via e or ESC 4.) Debug message is never sent to the console.

Plugin list:

ItemJoin -- I am the developer of this and was notified that features utilizing InventoryCloseEvent stopped working in paper when the users updated their paper version.

Paper build number:

The build number is the latest (b374). => This is the 1.15 branch.

Anything else:

The issue doesn't occur in b365, so the bug appeared somewhere between b365 and b374. Let me know if you need additional information, to me, it seems pretty simple but I often don't explain things very well.

RockinChaos avatar Jun 30 '20 22:06 RockinChaos

Inventory events don't fire for player-only inventories. That is entirely client side iirc.

Machine-Maker avatar Jul 02 '20 23:07 Machine-Maker

For certain player-only inventory events (Such as InventoryOpenEvent) yes, however for the InventoryCloseEvent--it is supposed to fire.

In any version below b365 this event used to work but as of updating to b374 it has stopped working. If it was strictly client-sided then why would it work in b365 in the first place?

RockinChaos avatar Jul 03 '20 03:07 RockinChaos

Yeah, ok. looks like it broke on build 371

More specifically, looks like md_5's fix for SPIGOT-5799 caused it.

Machine-Maker avatar Jul 03 '20 04:07 Machine-Maker

Oh wow, so I wasn't crazy when InventoryCloseEvent didnt fire for me. I swore it was working a while back.

MeLikeChoco avatar Jul 04 '20 09:07 MeLikeChoco

Are you talking specifically at player quit, and only for type == player?

aikar avatar Jul 05 '20 00:07 aikar

we talked over this, it is iffy.

Essentially, you're wanting to react to a client packet, and not really a server state change (because to the server, nothing has changed)

This may be best for you to use protocol lib for instead and react to the packet directly.

aikar avatar Jul 05 '20 01:07 aikar

But what I don't understand is why it is broken in the first place, it originally worked before MD_5's commit to fix another bug. Essentially the bug fix ended up creating an additional bug did it not?

Since MC 1.7 the result of a player closing their inventory would result in the event being triggered. Are we simply transitioning away from this to only fire when a player has an open inventory via chest such as how the InventoryOpenEvent functions?

I have currently been using an implementation of the TinyProtocol class to temporarily negate this issue but a lot of other developers still use the InventoryCloseEvent and its probably going to keep reappearing as an issue.

Thanks for the quick replies.

RockinChaos avatar Jul 05 '20 01:07 RockinChaos

I guess the argument is, that since there isn't an open event for a player's inventory, there shouldn't be a close one

Machine-Maker avatar Jul 05 '20 01:07 Machine-Maker

going to close as wontfix because it was technically a bug in first place.

Please use protocol lib and listen to the close packet if you really want to do this.

aikar avatar Jul 07 '20 16:07 aikar

Fixed in CraftBukkit 5c77bd28168.

Proximyst avatar Oct 01 '20 09:10 Proximyst