diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index ae30c9bc3..8a64940b9 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -1,7 +1,9 @@ package com.gmail.nossr50.runnables.party; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map.Entry; import org.bukkit.OfflinePlayer; import org.bukkit.scheduler.BukkitRunnable; @@ -17,6 +19,8 @@ public class PartyAutoKickTask extends BukkitRunnable { } private void updatePartyMembers() { + HashMap toRemove = new HashMap(); + long currentTime = System.currentTimeMillis(); long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime(); @@ -24,11 +28,14 @@ public class PartyAutoKickTask extends BukkitRunnable { Party party = partyIterator.next(); for (OfflinePlayer member : new ArrayList(party.getMembers())) { - if (currentTime - member.getLastPlayed() > kickTime) { - PartyManager.removeFromParty(member, party); + toRemove.put(member, party); } } } + + for (Entry entry : toRemove.entrySet()) { + PartyManager.removeFromParty(entry.getKey(), entry.getValue()); + } } }