Specific item!

Discussion in 'Plugin Development' started by FlothersBR, Jan 1, 2014.

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

    FlothersBR

    When a player dies does not drop into a specific item, the code works most of the error in the console can someone fix it

    @EventHandler
    public void EventNoDropITem(PlayerDeathEvent e) {
    for (ItemStack is : e.getDrops()) {
    if (is.getType() == Material.PORTAL) {
    e.getDrops().remove(is);
    }
    }
    }
     
  2. Offline

    jtjj222

    Some more info would have been helpful, but I can tell you that there is a concurrent modification exception from your use of an enhanced for loop. You can't modify a list while iterating over it using for (item : list).
     
  3. Offline

    Dako

    FlothersBR Post the Stack-Trace(error) please
     
    FlothersBR and jtjj222 like this.
  4. Offline

    FlothersBR

  5. Offline

    jtjj222

    FlothersBR
    You missed the important part of the exception, but from what I saw, it is a concurrent modification exception. Use a regular for loop instead of an enhanced for loop if you are going to remove items from a list.
     
Thread Status:
Not open for further replies.

Share This Page