Saber-Factions/src/com/massivecraft/factions/commands/CmdShow.java

164 lines
4.3 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
import java.util.Collection;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
2011-10-09 18:35:39 +02:00
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.struct.Role;
2011-10-09 20:10:19 +02:00
public class CmdShow extends FCommand
2011-10-09 18:35:39 +02:00
{
2011-10-09 20:10:19 +02:00
public CmdShow()
2011-10-09 18:35:39 +02:00
{
this.aliases.add("show");
this.aliases.add("who");
2011-10-09 18:35:39 +02:00
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours");
2011-10-09 18:35:39 +02:00
this.permission = Permission.COMMAND_SHOW.node;
2011-10-09 18:35:39 +02:00
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
2011-03-23 17:39:56 +01:00
}
2011-10-09 18:35:39 +02:00
@Override
public void perform()
{
Faction faction = this.argAsFaction(0, myFaction);
if (faction == null) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
2011-10-09 18:35:39 +02:00
if ( ! payForCommand(Conf.econCostShow)) return;
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
2011-10-09 18:35:39 +02:00
sendMessageParsed(p.txt.titleize(faction.getTag(fme)));
sendMessageParsed("<a>Description: <i>%s", faction.getDescription());
if ( ! faction.isNormal())
{
return;
}
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
String peaceStatus = "";
2011-10-09 18:35:39 +02:00
if (faction.isPeaceful())
{
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
peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful";
}
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
2011-10-09 18:35:39 +02:00
sendMessageParsed("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
sendMessageParsed("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
2011-10-09 18:35:39 +02:00
if (faction.isPermanent())
{
sendMessageParsed("<a>This faction is permanent, remaining even with no members.");
}
// show the land value
2011-10-09 18:35:39 +02:00
if (Econ.enabled())
{
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
double refund = value * Conf.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-09 18:35:39 +02:00
sendMessageParsed("<a>Total land value: <i>" + stringValue + stringRefund);
}
//Show bank contents
if(Conf.bankEnabled) {
2011-10-09 18:35:39 +02:00
sendMessageParsed("<a>Bank contains: <i>"+Econ.moneyString(faction.getMoney()));
}
}
String listpart;
// List relation
2011-10-09 18:35:39 +02:00
String allyList = p.txt.parse("<a>Allies: ");
String enemyList = p.txt.parse("<a>Enemies: ");
for (Faction otherFaction : Factions.i.get())
{
if (otherFaction == faction)
{
continue;
}
2011-10-09 18:35:39 +02:00
listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
if (otherFaction.getRelation(faction).isAlly())
{
allyList += listpart;
2011-10-09 18:35:39 +02:00
}
else if (otherFaction.getRelation(faction).isEnemy())
{
enemyList += listpart;
}
}
2011-10-09 18:35:39 +02:00
if (allyList.endsWith(", "))
{
allyList = allyList.substring(0, allyList.length()-2);
}
2011-10-09 18:35:39 +02:00
if (enemyList.endsWith(", "))
{
enemyList = enemyList.substring(0, enemyList.length()-2);
}
sendMessage(allyList);
sendMessage(enemyList);
// List the members...
2011-10-09 18:35:39 +02:00
String onlineList = p.txt.parse("<a>")+"Members online: ";
String offlineList = p.txt.parse("<a>")+"Members offline: ";
for (FPlayer follower : admins)
{
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if (follower.isOnline())
{
onlineList += listpart;
2011-10-09 18:35:39 +02:00
}
else
{
offlineList += listpart;
}
}
2011-10-09 18:35:39 +02:00
for (FPlayer follower : mods)
{
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if
(follower.isOnline())
{
onlineList += listpart;
} else {
offlineList += listpart;
}
}
for (FPlayer follower : normals) {
2011-10-09 18:35:39 +02:00
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
if (follower.isOnline()) {
onlineList += listpart;
} else {
offlineList += listpart;
}
}
if (onlineList.endsWith(", ")) {
onlineList = onlineList.substring(0, onlineList.length()-2);
}
if (offlineList.endsWith(", ")) {
offlineList = offlineList.substring(0, offlineList.length()-2);
}
sendMessage(onlineList);
sendMessage(offlineList);
}
}