2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
import com.massivecraft.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;
|
2015-01-02 20:38:35 +01:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
2015-01-22 00:58:33 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
import java.util.Collection;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
public class CmdShow extends FCommand {
|
|
|
|
|
|
|
|
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.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
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
this.senderMustBeMember = false;
|
|
|
|
this.senderMustBeModerator = false;
|
|
|
|
this.senderMustBeAdmin = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void perform() {
|
2015-01-02 20:38:35 +01:00
|
|
|
Faction faction = this.myFaction;
|
|
|
|
if (argIsSet(0)) {
|
|
|
|
faction = argAsFaction(0);
|
|
|
|
if (faction == null) {
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-01-02 20:38:35 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
|
2014-12-30 05:02:18 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
|
|
|
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
|
|
|
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
|
|
|
|
|
|
|
msg((p).txt.titleize(faction.getTag(this.fme)));
|
2015-01-22 00:58:33 +01:00
|
|
|
msg(TL.COMMAND_SHOW_DESCRIPTION, faction.getDescription());
|
2015-01-02 20:38:35 +01:00
|
|
|
if (!faction.isNormal()) {
|
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()) {
|
2015-01-22 00:58:33 +01:00
|
|
|
peaceStatus = " " + Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString();
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
msg(TL.COMMAND_SHOW_JOINING.toString() + peaceStatus, (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString()));
|
2015-01-02 20:38:35 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
double powerBoost = faction.getPowerBoost();
|
2015-01-27 18:07:55 +01:00
|
|
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
|
2015-01-27 16:06:18 +01:00
|
|
|
String raidable = faction.getLandRounded() > faction.getPowerRounded() ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
|
|
|
|
msg(TL.COMMAND_SHOW_POWER, faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost, raidable);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-01-27 18:07:55 +01:00
|
|
|
if (P.p.getConfig().getBoolean("hcf.raidable", false)) {
|
|
|
|
int dtr = Math.max(faction.getPowerRounded() - faction.getLandRounded(), 0);
|
|
|
|
msg(TL.COMMAND_SHOW_DEATHS_TIL_RAIDABLE, dtr);
|
|
|
|
}
|
2015-01-02 20:38:35 +01:00
|
|
|
if (faction.isPermanent()) {
|
2015-01-22 00:58:33 +01:00
|
|
|
msg(TL.COMMAND_SHOW_PERMANENT);
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|
2014-11-17 21:30:41 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
if (Econ.shouldBeUsed()) {
|
|
|
|
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
|
|
|
double refund = value * Conf.econClaimRefundMultiplier;
|
|
|
|
if (value > 0.0D) {
|
|
|
|
String stringValue = Econ.moneyString(value);
|
2015-01-22 00:58:33 +01:00
|
|
|
String stringRefund = (refund > 0.0) ? (TL.COMMAND_SHOW_DEPRECIATED.format(Econ.moneyString(refund))) : "";
|
|
|
|
msg(TL.COMMAND_SHOW_LANDVALUE, stringValue, stringRefund);
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
if (Conf.bankEnabled) {
|
2015-01-22 00:58:33 +01:00
|
|
|
msg(TL.COMMAND_SHOW_BANKCONTAINS, Econ.moneyString(Econ.getBalance(faction.getAccountId())));
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|
2014-11-17 21:30:41 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|
2014-11-17 21:30:41 +01:00
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
String allyList = p.txt.parse(TL.COMMAND_SHOW_ALLIES.toString());
|
|
|
|
String enemyList = p.txt.parse(TL.COMMAND_SHOW_ENEMIES.toString());
|
2015-01-02 20:38:35 +01:00
|
|
|
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
|
|
|
if (otherFaction != faction) {
|
|
|
|
Relation rel = otherFaction.getRelationTo(faction);
|
|
|
|
if ((rel.isAlly()) || (rel.isEnemy())) {
|
|
|
|
String listpart = otherFaction.getTag(this.fme) + p.txt.parse("<i>") + ", ";
|
|
|
|
if (rel.isAlly()) {
|
|
|
|
allyList = allyList + listpart;
|
|
|
|
} else if (rel.isEnemy()) {
|
|
|
|
enemyList = enemyList + listpart;
|
|
|
|
}
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-15 00:24:25 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
if (allyList.endsWith(", ")) {
|
|
|
|
allyList = allyList.substring(0, allyList.length() - 2);
|
|
|
|
}
|
|
|
|
if (enemyList.endsWith(", ")) {
|
|
|
|
enemyList = enemyList.substring(0, enemyList.length() - 2);
|
|
|
|
}
|
|
|
|
sendMessage(allyList);
|
|
|
|
sendMessage(enemyList);
|
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
String onlineList = p.txt.parse("<a>") + TL.COMMAND_SHOW_MEMBERSONLINE.toString();
|
|
|
|
String offlineList = p.txt.parse("<a>") + TL.COMMAND_SHOW_MEMBERSOFFLINE.toString();
|
2015-01-02 20:38:35 +01:00
|
|
|
for (FPlayer follower : admins) {
|
|
|
|
String listpart = follower.getNameAndTitle(this.fme) + p.txt.parse("<i>") + ", ";
|
|
|
|
if (follower.isOnlineAndVisibleTo(this.me)) {
|
|
|
|
onlineList = onlineList + listpart;
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2015-01-02 20:38:35 +01:00
|
|
|
offlineList = offlineList + listpart;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
2015-01-02 20:38:35 +01:00
|
|
|
for (FPlayer follower : mods) {
|
|
|
|
String listpart = follower.getNameAndTitle(this.fme) + p.txt.parse("<i>") + ", ";
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
if (follower.isOnlineAndVisibleTo(this.me)) {
|
|
|
|
onlineList = onlineList + listpart;
|
|
|
|
} else {
|
|
|
|
offlineList = offlineList + listpart;
|
2014-12-11 05:32:47 +01:00
|
|
|
}
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|
2014-12-11 05:32:47 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
for (FPlayer follower : normals) {
|
|
|
|
String listpart = follower.getNameAndTitle(this.fme) + p.txt.parse("<i>") + ", ";
|
|
|
|
if (follower.isOnlineAndVisibleTo(this.me)) {
|
|
|
|
onlineList = onlineList + listpart;
|
|
|
|
} else {
|
|
|
|
offlineList = offlineList + listpart;
|
2014-12-11 05:32:47 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 05:36:46 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
if (onlineList.endsWith(", ")) {
|
|
|
|
onlineList = onlineList.substring(0, onlineList.length() - 2);
|
|
|
|
}
|
|
|
|
if (offlineList.endsWith(", ")) {
|
|
|
|
offlineList = offlineList.substring(0, offlineList.length() - 2);
|
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
sendMessage(onlineList);
|
|
|
|
sendMessage(offlineList);
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_SHOW_COMMANDDESCRIPTION;
|
|
|
|
}
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|