Don't repeatedly copy the Set<FPlayer> of Faction members

This commit is contained in:
eueln 2014-10-21 14:49:01 -05:00 committed by t00thpick1
parent 157d98d4b0
commit 947f82cb2f

View File

@ -12,6 +12,7 @@ import org.bukkit.scoreboard.Team;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class FScoreboard { public class FScoreboard {
private static Map<FPlayer, FScoreboard> fscoreboards = new HashMap<FPlayer, FScoreboard>(); private static Map<FPlayer, FScoreboard> fscoreboards = new HashMap<FPlayer, FScoreboard>();
@ -130,6 +131,7 @@ public class FScoreboard {
public void updateFactionTeam(Faction faction) { public void updateFactionTeam(Faction faction) {
Team team = factionTeams.get(faction); Team team = factionTeams.get(faction);
Set<FPlayer> factionMembers = faction.getFPlayers();
if (!Factions.i.get().contains(faction)) { if (!Factions.i.get().contains(faction)) {
// Faction was disbanded // Faction was disbanded
@ -146,13 +148,13 @@ public class FScoreboard {
} }
for (OfflinePlayer player : team.getPlayers()) { for (OfflinePlayer player : team.getPlayers()) {
if (!player.isOnline() || !faction.getFPlayers().contains(FPlayers.i.get(player.getPlayer()))) { if (!player.isOnline() || !factionMembers.contains(FPlayers.i.get(player.getPlayer()))) {
// Player is offline or no longer in faction // Player is offline or no longer in faction
team.removePlayer(player); team.removePlayer(player);
} }
} }
for (FPlayer fmember : faction.getFPlayers()) { for (FPlayer fmember : factionMembers) {
if (!fmember.isOnline()) { if (!fmember.isOnline()) {
continue; continue;
} }