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
Admincraft Meta
Admincraft Metaโ€ข3mo ago
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
Skullians
Skulliansโ€ข3mo ago
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
๐๐ข๐ช๐ฎ๐š๐ญ๐ž๐ซ๐ง๐ข๐จ๐ง๐ฌ
Because that didnโ€™t existed when I created that plugin at that time ๐Ÿ˜… Thxxx! Never noticed they added that
Snow Kit
Snow Kitโ€ข3mo ago
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
1whoยกssus?
1whoยกssus?โ€ข3mo ago
Paper on top

Did you find this page helpful?