2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-11-24 16:27:14 +01:00
|
|
|
import java.util.ArrayList;
|
2011-03-22 15:45:41 +01:00
|
|
|
import java.util.Collection;
|
2011-11-24 16:27:14 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
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;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.FPlayer;
|
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2011-10-05 12:13:54 +02:00
|
|
|
import com.massivecraft.factions.integration.Econ;
|
2013-04-09 13:24:55 +02:00
|
|
|
import com.massivecraft.factions.FFlag;
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2013-04-09 13:24:55 +02:00
|
|
|
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-22 09:37:53 +02:00
|
|
|
import com.massivecraft.mcore.money.Money;
|
2013-04-10 10:32:04 +02:00
|
|
|
import com.massivecraft.mcore.util.Txt;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
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");
|
2011-03-22 18:48:09 +01:00
|
|
|
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addOptionalArg("faction", "you");
|
2011-06-30 12:56:02 +02:00
|
|
|
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.SHOW.node));
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
2011-06-30 12:56:02 +02: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;
|
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
|
|
|
|
2013-04-19 15:32:16 +02:00
|
|
|
Collection<FPlayer> leaders = faction.getFPlayersWhereRole(Rel.LEADER);
|
2013-04-19 15:51:41 +02:00
|
|
|
Collection<FPlayer> officers = faction.getFPlayersWhereRole(Rel.OFFICER);
|
2011-10-23 17:30:41 +02:00
|
|
|
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Rel.MEMBER);
|
2013-01-06 21:44:29 +01:00
|
|
|
Collection<FPlayer> recruits = faction.getFPlayersWhereRole(Rel.RECRUIT);
|
2011-03-22 15:45:41 +01:00
|
|
|
|
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());
|
2011-11-24 16:27:14 +01:00
|
|
|
|
|
|
|
// 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.");
|
2011-11-24 16:27:14 +01:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-10-24 02:33:30 +02:00
|
|
|
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.");
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
2011-08-05 10:50:47 +02:00
|
|
|
|
2013-04-11 11:44:55 +02:00
|
|
|
msg("<a>Joining: <i>"+(faction.isOpen() ? "no invitation is needed" : "invitation is required"));
|
2012-01-28 18:56:51 +01:00
|
|
|
|
|
|
|
double powerBoost = faction.getPowerBoost();
|
|
|
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
2013-04-17 08:49:43 +02:00
|
|
|
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
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
|
2013-04-22 09:37:53 +02:00
|
|
|
if (Econ.isEnabled(faction))
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-17 08:49:43 +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)
|
|
|
|
{
|
2013-04-22 09:37:53 +02:00
|
|
|
String stringValue = Money.format(faction, value);
|
|
|
|
String stringRefund = (refund > 0.0) ? (" ("+Money.format(faction, refund)+" depreciated)") : "";
|
2011-10-10 13:40:24 +02:00
|
|
|
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
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-26 17:44:20 +02:00
|
|
|
|
|
|
|
//Show bank contents
|
2013-04-09 13:15:25 +02:00
|
|
|
if(ConfServer.bankEnabled)
|
2011-11-24 16:27:14 +01:00
|
|
|
{
|
2013-04-22 09:37:53 +02:00
|
|
|
msg("<a>Bank contains: <i>"+Money.format(faction, Money.get(faction)));
|
2011-09-26 17:44:20 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-04-10 10:32:04 +02:00
|
|
|
String sepparator = Txt.parse("<i>")+", ";
|
2011-11-24 16:27:14 +01:00
|
|
|
|
|
|
|
// List the relations to other factions
|
2012-11-06 16:43:27 +01:00
|
|
|
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));
|
2011-11-24 16:27:14 +01:00
|
|
|
|
|
|
|
// List the members...
|
|
|
|
List<String> memberOnlineNames = new ArrayList<String>();
|
|
|
|
List<String> memberOfflineNames = new ArrayList<String>();
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-19 15:32:16 +02:00
|
|
|
for (FPlayer follower : leaders)
|
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
|
|
|
{
|
2011-11-24 16:27:14 +01:00
|
|
|
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
2011-10-09 18:35:39 +02:00
|
|
|
}
|
2011-11-24 16:27:14 +01:00
|
|
|
else
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2011-11-24 16:27:14 +01:00
|
|
|
memberOfflineNames.add(follower.getNameAndTitle(fme));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-19 15:51:41 +02:00
|
|
|
for (FPlayer follower : officers)
|
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
|
|
|
{
|
2011-11-24 16:27:14 +01:00
|
|
|
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
2011-10-09 18:35:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-24 16:27:14 +01:00
|
|
|
memberOfflineNames.add(follower.getNameAndTitle(fme));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-24 16:27:14 +01:00
|
|
|
|
|
|
|
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
|
|
|
{
|
2011-11-24 16:27:14 +01:00
|
|
|
memberOnlineNames.add(follower.getNameAndTitle(fme));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
2011-11-24 16:27:14 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
memberOfflineNames.add(follower.getNameAndTitle(fme));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-06 21:44:29 +01:00
|
|
|
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));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|