Properly preventing drops on death
Hi, one of the first plugins I made was one to prevent players from dropping all their inventory, instead just a few items.
I wanted to re-write that plugin so I wanted to know if anyone knows a better way todo it.
What I did at the time:
* World had to have keepInventory true
* When PlayerDeathEvent triggers, iterate through the player's inv and call dropItem at some items
Disadvantages:
* Little plugin compatibility, specially those that also interact with player inv
* Curse of Vanishing breaks unless hardcoded into the logic
* If I forget to set every world with keepInventory, then players will lose everything
8 Replies
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close
!close
!solved
!answered
Requested by duoslingo#0
bump
guess there’s no better way to do this
Why not just listen for playerdeathevent on like the highest priority and change the itemsToKeep
event.getItemsToKeep().remove(…)
Or more, add to the items to keep
PlayerDeathEvent (paper-api 1.21.3-R0.1-SNAPSHOT API)
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
Because that didn’t existed when I created that plugin at that time 😅
Thxxx! Never noticed they added that
it could be specific to the paper API
yup, actually is
just checked why I didn't noticed its existence, and apparently is only on paper
i usually check spigot jd
Paper on top