Nicer way to handle the ConcurrentModification issue.

This commit is contained in:
GJ 2013-02-15 07:40:47 -05:00
parent 6c4ea34811
commit 4ce06de18a

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.party.runnables; package com.gmail.nossr50.party.runnables;
import java.util.ArrayList; import java.util.Iterator;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -18,8 +18,10 @@ public class PartyAutoKick implements Runnable {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime(); long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
for (Party party : new ArrayList<Party>(PartyManager.getParties())) { for (Party party : PartyManager.getParties()) {
for (OfflinePlayer member : new ArrayList<OfflinePlayer>(party.getMembers())) { for (Iterator<OfflinePlayer> memberIterator = party.getMembers().iterator(); memberIterator.hasNext();) {
OfflinePlayer member = memberIterator.next();
if (currentTime - member.getLastPlayed() > kickTime) { if (currentTime - member.getLastPlayed() > kickTime) {
PartyManager.removeFromParty(member, party); PartyManager.removeFromParty(member, party);
} }