A few optimizations.

This commit is contained in:
t00thpick1 2015-01-02 19:33:34 -05:00
parent 44dc04e3e1
commit 37565463ad
3 changed files with 11 additions and 2 deletions

View File

@ -164,6 +164,8 @@ public interface Faction extends EconomyParticipator {
public boolean removeFPlayer(FPlayer fplayer);
public int getSize();
public Set<FPlayer> getFPlayers();
public Set<FPlayer> getFPlayersWhereOnline(boolean online);

View File

@ -307,8 +307,8 @@ public abstract class MCommand<T extends MPlugin> {
public String replaceFactionTags(String s, Faction faction) {
boolean raidable = faction.getLandRounded() > faction.getPower();
FPlayer fLeader = faction.getFPlayerAdmin();
String online = String.valueOf(faction.getFPlayersWhereOnline(true).size());
String members = String.valueOf(faction.getFPlayers().size());
String online = String.valueOf(faction.getOnlinePlayers().size());
String members = String.valueOf(faction.getSize());
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
return s.replace("{power}", String.valueOf(faction.getPowerRounded())).replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())).replace("{leader}", leader).replace("{chunks}", String.valueOf(faction.getLandRounded())).replace("{raidable}", String.valueOf(raidable)).replace("{warps}", String.valueOf(faction.getWarps().size())).replace("{online}", online).replace("{members}", members);
}

View File

@ -458,6 +458,10 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
}
public int getSize() {
return fplayers.size();
}
public Set<FPlayer> getFPlayers() {
// return a shallow copy of the FPlayer list, to prevent tampering and
// concurrency issues
@ -466,6 +470,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
Set<FPlayer> ret = new HashSet<FPlayer>();
if (!this.isNormal()) {
return ret;
}
for (FPlayer fplayer : fplayers) {
if (fplayer.isOnline() == online) {