Solved Really that hard to clear an inventory

Discussion in 'Plugin Development' started by TheDiamond06, Jun 6, 2015.

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

    TheDiamond06

    I don't understand this at all. I am trying to have it so when a player dies, it does not drop their contents in their inventory. To do this, I am using Player#getInventory().clear();

    However, I seem to be choosing wrong events to do this.
    I have tried: PlayerDeathEvent and EntityDamageEvent. Both of these events even after I checked if it was a player, do not clear the contents, leaving them still dropping.

    How would I make it so the player does not drop the contents of their inventory on the floor when they die.

    Here is the code I did for EntityDamageEvent if you are wondering:
    Code:java
    1. @EventHandler
    2. public void noDeathDrop(EntityDamageEvent e)
    3. {
    4. if(!(e.getEntity() instanceof Player))return;
    5. Player p = (Player) e.getEntity();
    6. if(!(e.getDamage() >= p.getHealth()))return;
    7. p.getInventory().clear();
    8. }
     
  2. Offline

    1Rogue

  3. Offline

    TheDiamond06

Thread Status:
Not open for further replies.

Share This Page