Factions3/src/com/massivecraft/factions/cmd/CmdFactionsShow.java

155 lines
4.5 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
2013-04-09 13:15:25 +02:00
import com.massivecraft.factions.ConfServer;
2013-04-16 11:05:49 +02:00
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FFlag;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
2013-04-12 08:56:26 +02:00
import com.massivecraft.mcore.mixin.Mixin;
2013-04-10 10:32:04 +02:00
import com.massivecraft.mcore.util.Txt;
2013-04-10 13:12:22 +02:00
public class CmdFactionsShow extends FCommand
2011-10-09 18:35:39 +02:00
{
2013-04-10 13:12:22 +02:00
public CmdFactionsShow()
2011-10-09 18:35:39 +02:00
{
2013-04-16 10:11:59 +02:00
this.addAliases("show", "who");
this.addOptionalArg("faction", "you");
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.SHOW.node));
2011-03-23 17:39:56 +01:00
}
2011-10-09 18:35:39 +02:00
@Override
public void perform()
{
2013-04-16 11:05:49 +02:00
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Rel.LEADER);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Rel.OFFICER);
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Rel.MEMBER);
Collection<FPlayer> recruits = faction.getFPlayersWhereRole(Rel.RECRUIT);
2013-04-10 10:32:04 +02:00
msg(Txt.titleize(faction.getTag(fme)));
2011-10-10 13:40:24 +02:00
msg("<a>Description: <i>%s", faction.getDescription());
// Display important flags
// TODO: Find the non default flags, and display them instead.
if (faction.getFlag(FFlag.PERMANENT))
2011-10-09 18:35:39 +02:00
{
2011-11-24 16:53:59 +01:00
msg("<a>This faction is permanent - remaining even with no members.");
}
if (faction.getFlag(FFlag.PEACEFUL))
2011-10-09 18:35:39 +02:00
{
2011-11-24 16:53:59 +01:00
msg("<a>This faction is peaceful - in truce with everyone.");
}
New "peaceful" status for factions which can only be set by server admins/moderators. Members of peaceful factions cannot deal or receive PvP damage (unless in a war zone which has friendly fire enabled), cannot claim land from another faction and likewise can't have their land claimed, and cannot be considered as ally or enemy of any other faction. Faction admins and moderators of peaceful factions can enable/disable all explosions inside their faction's territory at will. The main purpose of this is to provide a way for more peaceful players who don't want to take part in faction wars (or just want to take a break from them) to still have fun on the server. It is also meant to allow groups of players to make protected buildings, monuments, grand constructions, and so forth without having to worry about another faction destroying them. New conf.json settings: "peacefulTerritoryDisablePVP" (default true) prevents PvP damage for anyone inside a peaceful faction's territory "peacefulTerritoryDisableMonsters" (default false) provides protection against monsters spawning or attacking inside a peaceful faction's territory "peacefulMembersDisablePowerLoss" (default true) which keeps members of peaceful factions from suffering power loss when they die. New commands: /f peaceful [faction tag] - toggle the indicated faction's "peaceful" status /f noboom - enable/disable explosions inside your faction's territory; only available to faction admin and faction moderators for peaceful factions New permission nodes: factions.setPeaceful - ability to use the /f peaceful command (admins) factions.peacefulExplosionToggle - ability to use /f noboom (everyone)
2011-08-05 10:50:47 +02:00
msg("<a>Joining: <i>"+(faction.isOpen() ? "no invitation is needed" : "invitation is required"));
double powerBoost = faction.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
// show the land value
2013-04-19 09:50:33 +02:00
if (Econ.isEnabled())
2011-10-09 18:35:39 +02:00
{
double value = Econ.calculateTotalLandValue(faction.getLandCount());
2013-04-09 13:15:25 +02:00
double refund = value * ConfServer.econClaimRefundMultiplier;
2011-10-09 18:35:39 +02:00
if (value > 0)
{
String stringValue = Econ.moneyString(value);
String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : "";
2011-10-10 13:40:24 +02:00
msg("<a>Total land value: <i>" + stringValue + stringRefund);
}
//Show bank contents
2013-04-09 13:15:25 +02:00
if(ConfServer.bankEnabled)
{
msg("<a>Bank contains: <i>"+Econ.moneyString(Econ.getBalance(faction.getAccountId())));
}
}
2013-04-10 10:32:04 +02:00
String sepparator = Txt.parse("<i>")+", ";
// List the relations to other factions
Map<Rel, List<String>> relationTags = faction.getFactionTagsPerRelation(fme, true);
2011-11-24 16:53:59 +01:00
if (faction.getFlag(FFlag.PEACEFUL))
{
2013-04-10 10:32:04 +02:00
sendMessage(Txt.parse("<a>In Truce with:<i> *everyone*"));
2011-11-24 16:53:59 +01:00
}
else
{
2013-04-10 10:45:47 +02:00
sendMessage(Txt.parse("<a>In Truce with: ") + Txt.implode(relationTags.get(Rel.TRUCE), sepparator));
2011-11-24 16:53:59 +01:00
}
2013-04-10 10:45:47 +02:00
sendMessage(Txt.parse("<a>Allied to: ") + Txt.implode(relationTags.get(Rel.ALLY), sepparator));
sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationTags.get(Rel.ENEMY), sepparator));
// List the members...
List<String> memberOnlineNames = new ArrayList<String>();
List<String> memberOfflineNames = new ArrayList<String>();
for (FPlayer follower : admins)
2011-10-09 18:35:39 +02:00
{
2013-04-12 08:56:26 +02:00
if (follower.isOnline() && Mixin.isVisible(me, follower.getId()))
2011-10-09 18:35:39 +02:00
{
memberOnlineNames.add(follower.getNameAndTitle(fme));
2011-10-09 18:35:39 +02:00
}
else
2011-10-09 18:35:39 +02:00
{
memberOfflineNames.add(follower.getNameAndTitle(fme));
}
}
for (FPlayer follower : mods)
2011-10-09 18:35:39 +02:00
{
2013-04-12 08:56:26 +02:00
if (follower.isOnline() && Mixin.isVisible(me, follower.getId()))
2011-10-09 18:35:39 +02:00
{
memberOnlineNames.add(follower.getNameAndTitle(fme));
2011-10-09 18:35:39 +02:00
}
else
{
memberOfflineNames.add(follower.getNameAndTitle(fme));
}
}
for (FPlayer follower : normals)
2011-10-09 18:35:39 +02:00
{
2013-04-12 08:56:26 +02:00
if (follower.isOnline() && Mixin.isVisible(me, follower.getId()))
2011-10-09 18:35:39 +02:00
{
memberOnlineNames.add(follower.getNameAndTitle(fme));
}
else
{
memberOfflineNames.add(follower.getNameAndTitle(fme));
}
}
for (FPlayer follower : recruits)
{
if (follower.isOnline())
{
memberOnlineNames.add(follower.getNameAndTitle(fme));
}
else
{
memberOfflineNames.add(follower.getNameAndTitle(fme));
}
}
2013-04-10 10:45:47 +02:00
sendMessage(Txt.parse("<a>Members online: ") + Txt.implode(memberOnlineNames, sepparator));
sendMessage(Txt.parse("<a>Members offline: ") + Txt.implode(memberOfflineNames, sepparator));
}
}