Chaning player's inventory before they die.

Discussion in 'Plugin Development' started by millerni456, Dec 21, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    millerni456

    Title sums up my question pretty good.

    I'm trying to spawn chests when a player dies and fill it with their inventory.
    The problem is that the chest fills and the items drop. So it duplicates them.

    That's because I don't know how to change the player's inventory before they die.

    On the event: EntityDeathEvent, i check to see if a player dies. If so I spawn a chest and fill it.
     
  2. Offline

    CptSausage

    Code:
    player.getInventory().clear();
     
  3. Offline

    nisovin

    Probably this:

    Code:
    event.getDrops().clear();
     
  4. Offline

    millerni456

    Sorry Cpt Sausage that didn't work.
    However, nisovin, that did work. Thanks!

    EDIT: Actually i had to add the items to the chest before i could clear the drops. Originally i tried storing the drops in a variable which didn't work.
     
Thread Status:
Not open for further replies.

Share This Page