How to cancel dropping items on player death

Discussion in 'Plugin Development' started by 5Shadow7Prince, Nov 19, 2011.

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

    5Shadow7Prince

    Hi there!
    I have such code:
    entity listener, on entity death. There i can get drops, but i cant calcel this! if i need to save player's inventory i do: save his inv. on entity death (if instance Player - getDrops), and return this onPlayerRespawn. But i cant cancel dropping his inventory on player dies.
    How i can realise this?
     
  2. Offline

    spowney

    I beleive it's

    event.getDrops().clear();

    but I can't be certain. It's early....
     
  3. Offline

    5Shadow7Prince

    thanks, its working, but i have new trouble:
    i have:
    Code:
    Player player = (Player) event.getEntity();
    SPF.data.put(player.getName().toLowerCase(), event.getDrops());
    event.getDrops().clear();
    
    but after that SPF.data.get(player...) is empty! if i remove "event.getDrops().clear()" its okay, but with - fail.
     
  4. Offline

    spowney

    you need to copy event.getDrops() to a new container before you clear it if you want to use the contents afterwards.

    It's hard to see the full problem without src but I would assume thats the problem
     
  5. Offline

    DDoS

    @Verrier
    @lukegb

    Even more spam here.

    Edit: Rigby90 took care of it. Thanks.
     
Thread Status:
Not open for further replies.

Share This Page