Iterator<Player> iterator = plugin.inreview.keySet().iterator();
while (iterator.hasNext()) {
Player key = (Player) iterator.next();
chat.getRecipients().remove(key);
}
This throws an: java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
at java.util.HashMap$EntryIterator.next(Unknown Source)
at java.util.HashMap$EntryIterator.next(Unknown Source)
Any ideas as to why this is happening? When this occurs, there is one key (with one value) in the map.
My guess is that your
getRecipients()returns the same collection asplugin.inreview!This would mean that you try to remove an element from the collection while you are iterating over it. This is of course bad.
Instead, you should do this
Another possibility is that you have several threads?