package com.gmail.nossr50.runnables.party;

import java.util.Iterator;

import org.bukkit.OfflinePlayer;
import org.bukkit.scheduler.BukkitRunnable;

import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.party.PartyManager;

public class PartyAutoKickTask extends BukkitRunnable {
    @Override
    public void run() {
        updatePartyMembers();
    }

    private void updatePartyMembers() {
        long currentTime = System.currentTimeMillis();
        long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();

        for (Iterator<Party> partyIterator = PartyManager.getParties().iterator(); partyIterator.hasNext();) {
            Party party = partyIterator.next();

            for (Iterator<OfflinePlayer> memberIterator = party.getMembers().iterator(); memberIterator.hasNext();) {
                OfflinePlayer member = memberIterator.next();

                if (currentTime - member.getLastPlayed() > kickTime) {
                    PartyManager.removeFromParty(member, party);
                }
            }
        }
    }
}

@@ -37,16 +37,44 @@
 party;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -804,25 +804,16 @@
    for (
-Iterator%3C
 OfflineP
@@ -821,148 +821,69 @@
 ayer
-%3E
  member
-Iterator = party.getMembers().iterator(); memberIterator.hasNext();) %7B%0A                OfflinePlayer member = memberIterator.next();
+ : new ArrayList%3COfflinePlayer%3E(party.getMembers())) %7B
 %0A%0A  

Deal with the ConcurrentModification issue. Fixes #873