Store OfflinePlayers in FTeamWrapper instead of looking them up

This commit is contained in:
eueln 2014-11-15 16:54:16 -06:00
parent 8910de367c
commit 3af4c9a616

View File

@ -19,7 +19,7 @@ public class FTeamWrapper {
private final Map<FScoreboard, Team> teams = new HashMap<FScoreboard, Team>(); private final Map<FScoreboard, Team> teams = new HashMap<FScoreboard, Team>();
private final String teamName; private final String teamName;
private final Faction faction; private final Faction faction;
private final Set<UUID> members = new HashSet<UUID>(); private final Set<OfflinePlayer> members = new HashSet<OfflinePlayer>();
public static void applyUpdatesLater(final Faction faction) { public static void applyUpdatesLater(final Faction faction) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) {
@ -161,7 +161,7 @@ public class FTeamWrapper {
} }
private void addPlayer(OfflinePlayer player) { private void addPlayer(OfflinePlayer player) {
if (members.add(player.getUniqueId())) { if (members.add(player)) {
for (Team team : teams.values()) { for (Team team : teams.values()) {
team.addPlayer(player); team.addPlayer(player);
} }
@ -169,7 +169,7 @@ public class FTeamWrapper {
} }
private void removePlayer(OfflinePlayer player) { private void removePlayer(OfflinePlayer player) {
if (members.remove(player.getUniqueId())) { if (members.remove(player)) {
for (Team team : teams.values()) { for (Team team : teams.values()) {
team.removePlayer(player); team.removePlayer(player);
} }
@ -177,11 +177,7 @@ public class FTeamWrapper {
} }
private Set<OfflinePlayer> getPlayers() { private Set<OfflinePlayer> getPlayers() {
Set<OfflinePlayer> ret = new HashSet<OfflinePlayer>(); return new HashSet<OfflinePlayer>(this.members);
for (UUID uuid : members) {
ret.add(Bukkit.getOfflinePlayer(uuid));
}
return ret;
} }
private void unregister() { private void unregister() {