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;
|
2013-04-25 16:54:55 +02:00
|
|
|
import java.util.Collections;
|
2013-04-25 10:51:11 +02:00
|
|
|
import java.util.LinkedHashMap;
|
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-16 11:05:49 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
2013-04-25 13:25:15 +02:00
|
|
|
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
|
2013-04-24 08:39:26 +02:00
|
|
|
import com.massivecraft.factions.entity.UConf;
|
2013-04-22 17:59:51 +02:00
|
|
|
import com.massivecraft.factions.entity.UPlayer;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2014-06-04 16:47:01 +02:00
|
|
|
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
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-25 16:54:55 +02:00
|
|
|
import com.massivecraft.factions.PlayerRoleComparator;
|
2013-04-09 13:24:55 +02:00
|
|
|
import com.massivecraft.factions.Rel;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
|
|
|
import com.massivecraft.massivecore.mixin.Mixin;
|
|
|
|
import com.massivecraft.massivecore.money.Money;
|
|
|
|
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
|
|
|
import com.massivecraft.massivecore.util.TimeUnit;
|
|
|
|
import com.massivecraft.massivecore.util.Txt;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-26 14:01:28 +02:00
|
|
|
public class CmdFactionsFaction extends FCommand
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-26 14:01:28 +02:00
|
|
|
public CmdFactionsFaction()
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-26 14:01:28 +02:00
|
|
|
this.addAliases("f", "faction");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Args
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addOptionalArg("faction", "you");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2013-04-25 13:25:15 +02:00
|
|
|
this.addRequirements(ReqFactionsEnabled.get());
|
2013-04-26 14:01:28 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.FACTION.node));
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
2011-06-30 12:56:02 +02:00
|
|
|
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
// Args
|
2013-04-25 07:29:19 +02:00
|
|
|
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
|
2013-04-16 11:05:49 +02:00
|
|
|
if (faction == null) return;
|
2013-04-24 11:16:37 +02:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
// Data precalculation
|
2013-04-24 11:16:37 +02:00
|
|
|
UConf uconf = UConf.get(faction);
|
2013-04-25 16:54:55 +02:00
|
|
|
//boolean none = faction.isNone();
|
|
|
|
boolean normal = faction.isNormal();
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-26 17:54:06 +02:00
|
|
|
// INFO: Title
|
|
|
|
msg(Txt.titleize(Txt.upperCaseFirst(faction.getUniverse()) + " Faction " + faction.getName(usender)));
|
|
|
|
|
2013-04-25 16:02:37 +02:00
|
|
|
// INFO: Description
|
2013-04-25 16:54:55 +02:00
|
|
|
msg("<a>Description: <i>%s", faction.getDescription());
|
2011-11-24 16:27:14 +01:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
if (normal)
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
// INFO: Age
|
|
|
|
long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis();
|
|
|
|
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
|
|
|
|
String ageString = TimeDiffUtil.formatedVerboose(ageUnitcounts, "<i>");
|
|
|
|
msg("<a>Age: <i>%s", ageString);
|
2013-04-24 08:39:26 +02:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
// INFO: Open
|
|
|
|
msg("<a>Open: <i>"+(faction.isOpen() ? "<lime>Yes<i>, anyone can join" : "<rose>No<i>, only invited people can join"));
|
|
|
|
|
|
|
|
// INFO: Power
|
|
|
|
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
|
|
|
|
if (Econ.isEnabled(faction))
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
long landCount = faction.getLandCount();
|
2013-04-24 11:16:37 +02:00
|
|
|
|
2014-06-04 16:47:01 +02:00
|
|
|
for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values())
|
2013-04-24 11:16:37 +02:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
Double money = uconf.econChunkCost.get(type);
|
2013-04-26 08:02:32 +02:00
|
|
|
if (money == null) continue;
|
|
|
|
if (money == 0D) continue;
|
2013-04-25 16:54:55 +02:00
|
|
|
money *= landCount;
|
|
|
|
|
|
|
|
String word = null;
|
|
|
|
if (money > 0)
|
|
|
|
{
|
|
|
|
word = "cost";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
word = "reward";
|
|
|
|
money *= -1;
|
|
|
|
}
|
|
|
|
|
2013-12-03 12:59:46 +01:00
|
|
|
msg("<a>Total land %s %s: <i>%s", type.toString().toLowerCase(), word, Money.format(money));
|
2013-04-24 11:16:37 +02:00
|
|
|
}
|
2013-04-25 16:54:55 +02:00
|
|
|
|
|
|
|
// Show bank contents
|
|
|
|
if (UConf.get(faction).bankEnabled)
|
2013-04-24 11:16:37 +02:00
|
|
|
{
|
2013-12-03 12:59:46 +01:00
|
|
|
msg("<a>Bank contains: <i>"+Money.format(Money.get(faction)));
|
2013-04-24 11:16:37 +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
|
|
|
}
|
2011-09-26 17:44:20 +02:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
// Display important flags
|
|
|
|
// TODO: Find the non default flags, and display them instead.
|
|
|
|
if (faction.getFlag(FFlag.PERMANENT))
|
2011-11-24 16:27:14 +01:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
msg("<a>This faction is permanent - remaining even with no followers.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (faction.getFlag(FFlag.PEACEFUL))
|
|
|
|
{
|
|
|
|
msg("<a>This faction is peaceful - in truce with everyone.");
|
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-25 16:54:55 +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
|
2013-04-25 07:29:19 +02:00
|
|
|
Map<Rel, List<String>> relationNames = faction.getFactionNamesPerRelation(usender, 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-24 19:01:17 +02:00
|
|
|
sendMessage(Txt.parse("<a>In Truce with: ") + Txt.implode(relationNames.get(Rel.TRUCE), sepparator));
|
2011-11-24 16:53:59 +01:00
|
|
|
}
|
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
sendMessage(Txt.parse("<a>Allies: ") + Txt.implode(relationNames.get(Rel.ALLY), sepparator));
|
2013-04-24 19:01:17 +02:00
|
|
|
sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationNames.get(Rel.ENEMY), sepparator));
|
2011-11-24 16:27:14 +01:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
// List the followers...
|
|
|
|
List<String> followerNamesOnline = new ArrayList<String>();
|
|
|
|
List<String> followerNamesOffline = new ArrayList<String>();
|
2013-04-25 16:02:37 +02:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
List<UPlayer> followers = faction.getUPlayers();
|
|
|
|
Collections.sort(followers, PlayerRoleComparator.get());
|
2013-04-25 16:02:37 +02:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
for (UPlayer follower : followers)
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-06-18 09:07:05 +02:00
|
|
|
if (follower.isOnline() && Mixin.canSee(sender, follower.getId()))
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
followerNamesOnline.add(follower.getNameAndTitle(usender));
|
2011-10-09 18:35:39 +02:00
|
|
|
}
|
2013-04-25 16:54:55 +02:00
|
|
|
else if (normal)
|
2011-10-09 18:35:39 +02:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
// For the non-faction we skip the offline members since they are far to many (infinate almost)
|
|
|
|
followerNamesOffline.add(follower.getNameAndTitle(usender));
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
sendMessage(Txt.parse("<a>Followers online (%s): ", followerNamesOnline.size()) + Txt.implode(followerNamesOnline, sepparator));
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
if (normal)
|
2013-01-06 21:44:29 +01:00
|
|
|
{
|
2013-04-25 16:54:55 +02:00
|
|
|
sendMessage(Txt.parse("<a>Followers offline (%s): ", followerNamesOffline.size()) + Txt.implode(followerNamesOffline, sepparator));
|
2013-01-06 21:44:29 +01:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|