How to remove death drops? This is my code,but it doesn't work. Help...... Code: @EventHandler public void onPlayerDeath(PlayerDeathEvent event) { event.getDrops().clean(); }
Set the keepInventory gamerule to true. Then clear the inventory. https://jd.bukkit.org/org/bukkit/inventory/Inventory.html#clear().
Yes But I want player drop items,and if they can't find it,clean drops. I have created the timer. The timer has triggered, but drops were not cleared.
@ppodds That already happens: items are cleared from the ground if they arent picked up (= they were not found). You could create a timer that starts when a player dies and when it hits 0 the items are cleared.
getDrops() --> List<ItemStack> So I think... Code: @EventHandler public void onItemSpawn(ItemSpawnEvent event) { event.getEntity().remove(); } But it doesn't work,too. I find this at https://bukkit.org/threads/remove-drops-x-seconds-after-death.272522/
Don't use EntityDeathEvent. PlayerDeathEvent is what you need. You can "remove" their drops by Then you can have easy control on what happens to the items in their inventory.