Keep specific item on death (NOT ALL ITEMS)

Discussion in 'Spigot Plugin Development' started by xRarePvP, May 15, 2016.

  1. So I am trying to find a way to keep all DiamondPickaxes on death. All items besides the diamondpickaxes should be dropped, any ideas?
     
  2. Maybe add a PlayerRespawnEvent, so when the player respawns, it adds a diamond pickaxes to his/hers inventory. And if theres multiple pickaxes, find the amount of pickaxes there are, and then just times the number when the player respawns. Add a PlayerDeathEvent to get the amount of pickaxes, and send the number to PlayerRespawnEvent, and then add that amount to the players inventory. Not sure if this will work, but its just an idea!
     
    • Funny Funny x 1
  3. - PlayerDeathEvent

    List<ItemStack> getDrops()
    Gets all the items which will drop when the entity dies

    Iterate through the list, and if the stack type or equal to Material.DIAMOND_PICKAXE, remove it from the List.
     
  4. remove it from the list, add it to another list, give it to the player when he respawns. beautiful