Can Any One Help Me Please ?

Discussion in 'Plugin Development' started by Lol1212, Jun 14, 2018.

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

    Lol1212

    i am making a server i have one problem :
    i want to make when player dead if he has diamond_axe will not drop it how ?

    i did like this is it correct : ?

    //runs when we place a block in game
    public void onEntityDeath(EntityDeathEvent e){
    ItemStack stack = new ItemStack(Material.DIAMOND_AXE);
    e.getDrops().clear();
    e.getDrops().remove(stack);

    please Help Me !!
     
  2. Offline

    ThePandaPlayer

    Would you please restate the question?

    Do you want to kill a player who possesses a diamond ax?
    Or do you not want the ax to drop?
     
  3. Offline

    MightyOne

    You have to loop through e.getDrops() and look if any item is of material diamond axe, if yes remove it. Use a for loop with int i starting at e.getDrops().size()-1 going down to 0. That will prevent a currenmodificationexception or a indexoutofbound
     
Thread Status:
Not open for further replies.

Share This Page