BenCodez / GraveStonesPlus

5 stars 2 forks source link

Items enchanted with Curse of Vanishing don't disappear on death #43

Closed dlsf closed 1 month ago

dlsf commented 1 month ago

Since the Vanilla behavior is that Curse of Vanishing items are only temporary, it would be awesome if the plugin could mirror this behavior. Currently, it seems to merely copy the player's inventory before death.

I'd imagine that servers would want to configure this, so I believe a toggle for this would be optimal.

dlsf commented 1 month ago

I just realized that the problem runs a bit deeper than that; the plugin seems to be ignoring everything that happens to the player's items upon death (both Vanilla behavior and by other plugins listening to the PlayerDeathEvent).

I think a solution to this would be the following:

  1. Set the PlayerDeathListener's EventPriority to HIGHEST so it (optimally) runs after all other plugins processed the event
  2. (the ignoredCancelled attribute is unnecessary as the PlayerDeathEvent is not Cancellable)
  3. Match the player's inventory with the PlayerDeathEvent.getDrops() so only the stuff that should get dropped according to Vanilla (and which may have been edited by other plugins) actually gets dropped

Or, if just the Curse of Vanishing items should be removed, simply checking for that enchantment would also be fine, lol

BenCodez commented 1 month ago

There already is a check for curse of vanishing. Is keep inventory on on the world? What's in console when you die?

dlsf commented 1 month ago

Oh, you're right, it's working. The issue that the plugin fails to capture the changes that other plugins make to the PlayerDeathEvent still remains, though

BenCodez commented 1 month ago

https://bencodez.com/job/GraveStonesPlus/ this work?

dlsf commented 1 month ago

That's better, thank you :)