There are lots of unfactioned players, but we shouldn't care about them.

This commit is contained in:
t00thpick1 2015-01-02 19:19:57 -05:00
parent 3f949e18cc
commit 44dc04e3e1
1 changed files with 70 additions and 64 deletions

View File

@ -17,11 +17,12 @@ import java.util.List;
public class CmdShow extends FCommand { public class CmdShow extends FCommand {
private static final int ARBITRARY_LIMIT = 25000; private static final int ARBITRARY_LIMIT = 25000;
public CmdShow() { public CmdShow() {
this.aliases.add("show"); this.aliases.add("show");
this.aliases.add("who"); this.aliases.add("who");
//this.requiredArgs.add(""); // this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours"); this.optionalArgs.put("faction tag", "yours");
this.permission = Permission.SHOW.node; this.permission = Permission.SHOW.node;
@ -42,7 +43,8 @@ public class CmdShow extends FCommand {
} }
} }
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this
// command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) { if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
return; return;
} }
@ -57,83 +59,87 @@ public class CmdShow extends FCommand {
List<FancyMessage> allies = new ArrayList<FancyMessage>(); List<FancyMessage> allies = new ArrayList<FancyMessage>();
List<FancyMessage> enemies = new ArrayList<FancyMessage>(); List<FancyMessage> enemies = new ArrayList<FancyMessage>();
FancyMessage currentAllies = new FancyMessage(TL.COMMAND_SHOW_ALLIES.toString()).color(ChatColor.GOLD); if (!faction.isNone()) {
FancyMessage currentEnemies = new FancyMessage(TL.COMMAND_SHOW_ENEMIES.toString()).color(ChatColor.GOLD); FancyMessage currentAllies = new FancyMessage(TL.COMMAND_SHOW_ALLIES.toString()).color(ChatColor.GOLD);
FancyMessage currentEnemies = new FancyMessage(TL.COMMAND_SHOW_ENEMIES.toString()).color(ChatColor.GOLD);
boolean firstAlly = true; boolean firstAlly = true;
boolean firstEnemy = true; boolean firstEnemy = true;
for (Faction otherFaction : Factions.getInstance().getAllFactions()) { for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
if (otherFaction == faction) { if (otherFaction == faction) {
continue; continue;
}
Relation rel = otherFaction.getRelationTo(faction);
String s = otherFaction.getTag(fme);
if (rel.isAlly()) {
if (firstAlly) {
currentAllies.then(s).tooltip(getToolTips(otherFaction));
} else {
currentAllies.then(", " + s).tooltip(getToolTips(otherFaction));
} }
firstAlly = false;
if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) { Relation rel = otherFaction.getRelationTo(faction);
allies.add(currentAllies); String s = otherFaction.getTag(fme);
currentAllies = new FancyMessage(); if (rel.isAlly()) {
} if (firstAlly) {
} else if (rel.isEnemy()) { currentAllies.then(s).tooltip(getToolTips(otherFaction));
if (firstEnemy) { } else {
currentEnemies.then(s).tooltip(getToolTips(otherFaction)); currentAllies.then(", " + s).tooltip(getToolTips(otherFaction));
} else { }
currentEnemies.then(", " + s).tooltip(getToolTips(otherFaction)); firstAlly = false;
}
firstEnemy = false;
if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) { if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) {
enemies.add(currentEnemies); allies.add(currentAllies);
currentEnemies = new FancyMessage(); currentAllies = new FancyMessage();
}
} else if (rel.isEnemy()) {
if (firstEnemy) {
currentEnemies.then(s).tooltip(getToolTips(otherFaction));
} else {
currentEnemies.then(", " + s).tooltip(getToolTips(otherFaction));
}
firstEnemy = false;
if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) {
enemies.add(currentEnemies);
currentEnemies = new FancyMessage();
}
} }
} }
allies.add(currentAllies);
enemies.add(currentEnemies);
} }
allies.add(currentAllies);
enemies.add(currentEnemies);
List<FancyMessage> online = new ArrayList<FancyMessage>(); List<FancyMessage> online = new ArrayList<FancyMessage>();
List<FancyMessage> offline = new ArrayList<FancyMessage>(); List<FancyMessage> offline = new ArrayList<FancyMessage>();
FancyMessage currentOnline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSONLINE.toString()).color(ChatColor.GOLD); if (!faction.isNone()) {
FancyMessage currentOffline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSOFFLINE.toString()).color(ChatColor.GOLD); FancyMessage currentOnline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSONLINE.toString()).color(ChatColor.GOLD);
boolean firstOnline = true; FancyMessage currentOffline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSOFFLINE.toString()).color(ChatColor.GOLD);
boolean firstOffline = true; boolean firstOnline = true;
for (FPlayer p : MiscUtil.rankOrder(faction.getFPlayers())) { boolean firstOffline = true;
String name = p.getNameAndTitle(); for (FPlayer p : MiscUtil.rankOrder(faction.getFPlayers())) {
if (p.isOnline()) { String name = p.getNameAndTitle();
if (firstOnline) { if (p.isOnline()) {
currentOnline.then(name).tooltip(getToolTips(p)); if (firstOnline) {
} else { currentOnline.then(name).tooltip(getToolTips(p));
currentOnline.then(", " + name).tooltip(getToolTips(p)); } else {
} currentOnline.then(", " + name).tooltip(getToolTips(p));
firstOnline = false; }
firstOnline = false;
if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) { if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) {
online.add(currentOnline); online.add(currentOnline);
currentOnline = new FancyMessage(); currentOnline = new FancyMessage();
} }
} else {
if (firstOffline) {
currentOffline.then(name).tooltip(getToolTips(p));
} else { } else {
currentOffline.then(", " + name).tooltip(getToolTips(p)); if (firstOffline) {
} currentOffline.then(name).tooltip(getToolTips(p));
firstOffline = false; } else {
currentOffline.then(", " + name).tooltip(getToolTips(p));
}
firstOffline = false;
if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) { if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) {
offline.add(currentOffline); offline.add(currentOffline);
currentOffline = new FancyMessage(); currentOffline = new FancyMessage();
}
} }
} }
online.add(currentOnline);
offline.add(currentOffline);
} }
online.add(currentOnline);
offline.add(currentOffline);
// Send all at once ;D // Send all at once ;D
msg(p.txt.titleize(faction.getTag(fme))); msg(p.txt.titleize(faction.getTag(fme)));
@ -156,7 +162,7 @@ public class CmdShow extends FCommand {
msg(TL.COMMAND_SHOW_LANDVALUE, stringValue, stringRefund); msg(TL.COMMAND_SHOW_LANDVALUE, stringValue, stringRefund);
} }
//Show bank contents // Show bank contents
if (Conf.bankEnabled) { if (Conf.bankEnabled) {
msg(TL.COMMAND_SHOW_BANKCONTAINS, Econ.moneyString(Econ.getBalance(faction.getAccountId()))); msg(TL.COMMAND_SHOW_BANKCONTAINS, Econ.moneyString(Econ.getBalance(faction.getAccountId())));
} }