Remove player from a list.

Discussion in 'Plugin Development' started by MinecraftMart, Feb 22, 2015.

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

    MinecraftMart

    So with this code i add a player to a list.
    Code:
    Map<UUID, String> players = new HashMap<UUID, String>();
    //Game refers to another class.
    game.players.put(p.getUniqueId(), arenaName);
    Then with this code i remove the player from the list on death
    Code:
    for (Entry<UUID, String> entry : players.entrySet())
                       {
                           if(entry.getKey().equals(p.getUniqueId())){
                               players.remove(entry.getKey());
                           }
    
                       }
    But when i run the start code it still takes the player even tho i removed it.
    With some debugging i came to the conclusion it didnt take tke player out of the list.
    What do I do?
     
  2. Offline

    Skionz

    @MinecraftMart If you are getting a ConcurrentModificationException use an iterator.
     
Thread Status:
Not open for further replies.

Share This Page