2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
2011-03-23 17:39:56 +01:00
|
|
|
import org.bukkit.command.CommandSender;
|
2011-06-30 12:56:02 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2011-07-18 22:06:02 +02:00
|
|
|
|
|
|
|
import com.massivecraft.factions.Conf;
|
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
|
|
|
import com.massivecraft.factions.Econ;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.Faction;
|
|
|
|
import com.massivecraft.factions.struct.Role;
|
|
|
|
import com.massivecraft.factions.util.TextUtil;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
|
|
|
|
public class FCommandShow extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandShow() {
|
2011-03-22 18:48:09 +01:00
|
|
|
aliases.add("show");
|
|
|
|
aliases.add("who");
|
|
|
|
|
2011-06-30 12:56:02 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
optionalParameters.add("faction tag");
|
|
|
|
|
|
|
|
helpDescription = "Show faction information";
|
|
|
|
}
|
|
|
|
|
2011-03-23 17:39:56 +01:00
|
|
|
@Override
|
|
|
|
public boolean hasPermission(CommandSender sender) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-03-22 15:45:41 +01:00
|
|
|
public void perform() {
|
|
|
|
Faction faction;
|
|
|
|
if (parameters.size() > 0) {
|
|
|
|
faction = findFaction(parameters.get(0), true);
|
2011-06-30 12:56:02 +02:00
|
|
|
} else if (!(sender instanceof Player)) {
|
|
|
|
sendMessage("From the command line, you must specify a faction tag (f who <faction tag>).");
|
|
|
|
return;
|
2011-03-22 15:45:41 +01:00
|
|
|
} else {
|
|
|
|
faction = me.getFaction();
|
|
|
|
}
|
2011-06-30 12:56:02 +02:00
|
|
|
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
|
|
|
}
|
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
|
|
|
|
|
|
|
// 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)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
|
|
|
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
|
|
|
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
|
|
|
|
|
|
|
sendMessage(TextUtil.titleize(faction.getTag(me)));
|
|
|
|
sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription());
|
2011-03-23 17:39:56 +01:00
|
|
|
if ( ! faction.isNormal()) {
|
2011-03-22 15:45:41 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-05 10:50:47 +02:00
|
|
|
String peaceStatus = "";
|
|
|
|
if (faction.isPeaceful()) {
|
|
|
|
peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful";
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
2011-08-05 10:50:47 +02:00
|
|
|
|
|
|
|
sendMessage(Conf.colorChrome+"Joining: "+Conf.colorSystem+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
2011-03-22 15:45:41 +01:00
|
|
|
sendMessage(Conf.colorChrome+"Land / Power / Maxpower: "+Conf.colorSystem+ faction.getLandRounded()+" / "+faction.getPowerRounded()+" / "+faction.getPowerMaxRounded());
|
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
|
|
|
|
2011-09-13 20:14:09 +02:00
|
|
|
if (faction.isPermanent()) {
|
|
|
|
sendMessage(Conf.colorChrome+"This faction is permanent, remaining even with no members.");
|
|
|
|
}
|
|
|
|
|
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
|
|
|
// show the land value
|
|
|
|
if (Econ.enabled()) {
|
|
|
|
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
|
|
|
double refund = value * Conf.econClaimRefundMultiplier;
|
|
|
|
if (value > 0) {
|
|
|
|
String stringValue = Econ.moneyString(value);
|
|
|
|
String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : "";
|
|
|
|
sendMessage(Conf.colorChrome+"Total land value: " + Conf.colorSystem + stringValue + stringRefund);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
String listpart;
|
|
|
|
|
|
|
|
// List relation
|
|
|
|
String allyList = Conf.colorChrome+"Allies: ";
|
|
|
|
String enemyList = Conf.colorChrome+"Enemies: ";
|
|
|
|
for (Faction otherFaction : Faction.getAll()) {
|
|
|
|
if (otherFaction == faction) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
listpart = otherFaction.getTag(me)+Conf.colorSystem+", ";
|
2011-07-09 08:36:18 +02:00
|
|
|
if (otherFaction.getRelation(faction).isAlly()) {
|
2011-03-22 15:45:41 +01:00
|
|
|
allyList += listpart;
|
2011-07-09 08:36:18 +02:00
|
|
|
} else if (otherFaction.getRelation(faction).isEnemy()) {
|
2011-03-22 15:45:41 +01:00
|
|
|
enemyList += listpart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allyList.endsWith(", ")) {
|
|
|
|
allyList = allyList.substring(0, allyList.length()-2);
|
|
|
|
}
|
|
|
|
if (enemyList.endsWith(", ")) {
|
|
|
|
enemyList = enemyList.substring(0, enemyList.length()-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
sendMessage(allyList);
|
|
|
|
sendMessage(enemyList);
|
|
|
|
|
|
|
|
// List the members...
|
|
|
|
String onlineList = Conf.colorChrome+"Members online: ";
|
|
|
|
String offlineList = Conf.colorChrome+"Members offline: ";
|
|
|
|
for (FPlayer follower : admins) {
|
|
|
|
listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", ";
|
|
|
|
if (follower.isOnline()) {
|
|
|
|
onlineList += listpart;
|
|
|
|
} else {
|
|
|
|
offlineList += listpart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (FPlayer follower : mods) {
|
|
|
|
listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", ";
|
|
|
|
if (follower.isOnline()) {
|
|
|
|
onlineList += listpart;
|
|
|
|
} else {
|
|
|
|
offlineList += listpart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (FPlayer follower : normals) {
|
|
|
|
listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", ";
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|