Prevent dropping an item on death

Discussion in 'Skript' started by JuanDeeg, Jul 15, 2021.

  1. Hello all,

    I would like to prevent a certain item from dropping on death. For example if players inventory contains a clock on death of player do not drop the clock on the ground (but drop all other items). Would I need to loop through the entire inventory?

  2. Here code
    Code (Text):
    public void onPlayerDeath(PlayerDeathEvent e) {
    List<ItemStack> list = e.getDrops();
    List<ItemStack> otherlist = new ArrayList<>();
    for(ItemStack i : list) {
      if(!i.getType().equals(Material.STONE)) {
  3. I’m pretty sure you can simply remove an element from the drops list
  4. Hey thanks for the reply! How can I achieve this with Skript?
  5. Oh I didn’t notice this is the skript section and I don’t think that @chochoco4777 noticed either.
  6. on death of player:
    remove clock from drops

    #not tested
  7. Hmm yeah I had also tried something similar to this. However the clock will still drop on the ground when player dies. ^Also tried using what you had written there didnt seem to work
  8. try remove clock from victim's inventory
  9. Still no luck with this. I have:

    on death of player:
    remove clock from victim's inventory

    Clock will still drop on death of player.
  10. you need to loop all items of players inventory to make this
  11. Hey appreciate the reply. How can I achieve something like this?
  12. This is the skript section tho
    • Funny Funny x 1
  13. loop all items in victim's inventory:
    loop-item is a clock