2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.Factions;
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.integration.Econ;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2012-11-06 16:43:30 +01:00
|
|
|
import com.massivecraft.factions.struct.Relation;
|
2014-12-07 04:44:00 +01:00
|
|
|
import com.massivecraft.factions.util.MiscUtil;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-11-13 20:49:13 +01:00
|
|
|
import mkremins.fanciful.FancyMessage;
|
|
|
|
import org.bukkit.ChatColor;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-11-17 20:16:58 +01:00
|
|
|
import java.util.ArrayList;
|
2014-12-15 00:24:25 +01:00
|
|
|
import java.util.List;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
public class CmdShow extends FCommand {
|
2014-12-30 06:31:36 +01:00
|
|
|
private static final int ARBITRARY_LIMIT = 25000;
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdShow() {
|
2014-07-01 22:10:18 +02:00
|
|
|
this.aliases.add("show");
|
|
|
|
this.aliases.add("who");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("faction tag", "yours");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.SHOW.node;
|
|
|
|
this.disableOnLock = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
Faction faction = myFaction;
|
|
|
|
if (this.argIsSet(0)) {
|
|
|
|
faction = this.argAsFaction(0);
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
2014-12-08 00:12:52 +01:00
|
|
|
if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
|
2014-07-01 21:49:42 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
String peaceStatus = "";
|
|
|
|
if (faction.isPeaceful()) {
|
2014-12-08 00:12:52 +01:00
|
|
|
peaceStatus = " " + Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString();
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
double powerBoost = faction.getPowerBoost();
|
2014-12-11 05:32:47 +01:00
|
|
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-12-15 00:24:25 +01:00
|
|
|
List<FancyMessage> allies = new ArrayList<FancyMessage>();
|
|
|
|
List<FancyMessage> enemies = new ArrayList<FancyMessage>();
|
2014-12-08 00:12:52 +01:00
|
|
|
FancyMessage currentAllies = new FancyMessage(TL.COMMAND_SHOW_ALLIES.toString()).color(ChatColor.GOLD);
|
|
|
|
FancyMessage currentEnemies = new FancyMessage(TL.COMMAND_SHOW_ENEMIES.toString()).color(ChatColor.GOLD);
|
2014-11-17 21:30:41 +01:00
|
|
|
|
|
|
|
boolean firstAlly = true;
|
|
|
|
boolean firstEnemy = true;
|
|
|
|
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
|
|
|
if (otherFaction == faction) {
|
|
|
|
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;
|
|
|
|
|
2014-12-30 06:31:36 +01:00
|
|
|
if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) {
|
|
|
|
allies.add(currentAllies);
|
|
|
|
currentAllies = new FancyMessage();
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
|
|
|
} else if (rel.isEnemy()) {
|
|
|
|
if (firstEnemy) {
|
|
|
|
currentEnemies.then(s).tooltip(getToolTips(otherFaction));
|
|
|
|
} else {
|
|
|
|
currentEnemies.then(", " + s).tooltip(getToolTips(otherFaction));
|
|
|
|
}
|
|
|
|
firstEnemy = false;
|
|
|
|
|
2014-12-30 06:31:36 +01:00
|
|
|
if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) {
|
|
|
|
enemies.add(currentEnemies);
|
|
|
|
currentEnemies = new FancyMessage();
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
allies.add(currentAllies);
|
|
|
|
enemies.add(currentEnemies);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-12-15 00:24:25 +01:00
|
|
|
List<FancyMessage> online = new ArrayList<FancyMessage>();
|
|
|
|
List<FancyMessage> offline = new ArrayList<FancyMessage>();
|
|
|
|
FancyMessage currentOnline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSONLINE.toString()).color(ChatColor.GOLD);
|
|
|
|
FancyMessage currentOffline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSOFFLINE.toString()).color(ChatColor.GOLD);
|
2014-11-17 19:32:34 +01:00
|
|
|
boolean firstOnline = true;
|
|
|
|
boolean firstOffline = true;
|
2014-12-07 04:44:00 +01:00
|
|
|
for (FPlayer p : MiscUtil.rankOrder(faction.getFPlayers())) {
|
2014-11-13 20:49:13 +01:00
|
|
|
String name = p.getNameAndTitle();
|
|
|
|
if (p.isOnline()) {
|
2014-11-17 21:30:41 +01:00
|
|
|
if (firstOnline) {
|
2014-12-15 00:24:25 +01:00
|
|
|
currentOnline.then(name).tooltip(getToolTips(p));
|
2014-11-17 21:30:41 +01:00
|
|
|
} else {
|
2014-12-15 00:24:25 +01:00
|
|
|
currentOnline.then(", " + name).tooltip(getToolTips(p));
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
2014-11-17 19:32:34 +01:00
|
|
|
firstOnline = false;
|
2014-12-15 00:24:25 +01:00
|
|
|
|
2014-12-30 06:31:36 +01:00
|
|
|
if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) {
|
|
|
|
online.add(currentOnline);
|
|
|
|
currentOnline = new FancyMessage();
|
2014-12-07 02:32:35 +01:00
|
|
|
}
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-11-17 21:30:41 +01:00
|
|
|
if (firstOffline) {
|
2014-12-15 00:24:25 +01:00
|
|
|
currentOffline.then(name).tooltip(getToolTips(p));
|
2014-11-17 21:30:41 +01:00
|
|
|
} else {
|
2014-12-15 00:24:25 +01:00
|
|
|
currentOffline.then(", " + name).tooltip(getToolTips(p));
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
2014-11-17 19:32:34 +01:00
|
|
|
firstOffline = false;
|
2014-12-15 00:24:25 +01:00
|
|
|
|
2014-12-30 06:31:36 +01:00
|
|
|
if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) {
|
|
|
|
offline.add(currentOffline);
|
|
|
|
currentOffline = new FancyMessage();
|
2014-12-07 02:32:35 +01:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
2014-12-15 00:24:25 +01:00
|
|
|
online.add(currentOnline);
|
|
|
|
offline.add(currentOffline);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-11-13 20:49:13 +01:00
|
|
|
// Send all at once ;D
|
2014-12-11 05:32:47 +01:00
|
|
|
msg(p.txt.titleize(faction.getTag(fme)));
|
|
|
|
msg(TL.COMMAND_SHOW_DESCRIPTION, faction.getDescription());
|
|
|
|
if (!faction.isNormal()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
msg(TL.COMMAND_SHOW_JOINING.toString() + peaceStatus, (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString()));
|
|
|
|
msg(TL.COMMAND_SHOW_POWER, faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
|
|
|
if (faction.isPermanent()) {
|
|
|
|
msg(TL.COMMAND_SHOW_PERMANENT);
|
|
|
|
}
|
|
|
|
// show the land value
|
|
|
|
if (Econ.shouldBeUsed()) {
|
|
|
|
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
|
|
|
double refund = value * Conf.econClaimRefundMultiplier;
|
|
|
|
if (value > 0) {
|
|
|
|
String stringValue = Econ.moneyString(value);
|
|
|
|
String stringRefund = (refund > 0.0) ? (TL.COMMAND_SHOW_DEPRECIATED.format(Econ.moneyString(refund))) : "";
|
|
|
|
msg(TL.COMMAND_SHOW_LANDVALUE, stringValue, stringRefund);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Show bank contents
|
|
|
|
if (Conf.bankEnabled) {
|
|
|
|
msg(TL.COMMAND_SHOW_BANKCONTAINS, Econ.moneyString(Econ.getBalance(faction.getAccountId())));
|
|
|
|
}
|
|
|
|
}
|
2014-12-11 05:36:46 +01:00
|
|
|
|
2014-11-13 20:49:13 +01:00
|
|
|
sendFancyMessage(allies);
|
|
|
|
sendFancyMessage(enemies);
|
|
|
|
sendFancyMessage(online);
|
|
|
|
sendFancyMessage(offline);
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
}
|