Fixed concurrentModificationException

This commit is contained in:
Evenprime 2011-04-10 22:08:05 +02:00
parent bbe2250e0a
commit 004748dbd3
2 changed files with 19 additions and 17 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 0.8.2 version: 0.8.3
commands: commands:
nocheat: nocheat:

View File

@ -1,6 +1,7 @@
package cc.co.evenprime.bukkit.nocheat; package cc.co.evenprime.bukkit.nocheat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -103,10 +104,11 @@ public class NoCheat extends JavaPlugin {
*/ */
public void cleanPlayerDataCollection() { public void cleanPlayerDataCollection() {
synchronized(playerData) { synchronized(playerData) {
for(Player p : playerData.keySet()) { Iterator<Map.Entry<Player, NoCheatData>> it = playerData.entrySet().iterator();
if(!p.isOnline()) { while (it.hasNext()) {
playerData.remove(p); Map.Entry<Player, NoCheatData> pairs = (Map.Entry<Player, NoCheatData>)it.next();
} if(!pairs.getKey().isOnline())
it.remove();
} }
} }
} }