Prevent player onDeath to drop

Discussion in 'Plugin Development' started by Cheesier, Apr 17, 2011.

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

    Cheesier

    Anyone know how i can stop players from dropping their inventory ?
    Tried
    Code:
    public void onEntityDeath(EntityDeathEvent event) {
        event.getDrops().clear();
    }
    I thought that would do it... it didnt... I know the code gets ran.

    /bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  2. Offline

    cdkid

    I just started doing plugins, so there may be a better way, but here's some pseudo
    Code:
    ondeath
    {
      if entity instanceof player
        save player's inventory;
    }
    onrespawn
    {
      check if player has saved inventory
          if so, load and delete player's saved inventory
    }
    
    maybe just use a tempfile to store saved inventories or something similar to that. You could keep it in memory, but that might not be a great idea for if they d/c without respawning.
     
  3. Offline

    Ne0nx3r0

Thread Status:
Not open for further replies.

Share This Page