Adding in Faction creation timestamp. You can now see how old the faction is.
This commit is contained in:
parent
0ed104279f
commit
0fd21575e4
@ -91,7 +91,7 @@ public class CmdFactionsAccess extends FCommand
|
|||||||
|
|
||||||
private void showAccessList(TerritoryAccess territory, Faction locFaction)
|
private void showAccessList(TerritoryAccess territory, Faction locFaction)
|
||||||
{
|
{
|
||||||
msg("<i>Host faction %s has %s<i> in this territory.", locFaction.getName(), Txt.parse(territory.isHostFactionAllowed() ? "<lime>normal access" : "<rose>restricted access"));
|
msg("<i>Host faction %s <i>has %s<i> in this territory.", locFaction.getName(), Txt.parse(territory.isHostFactionAllowed() ? "<lime>normal access" : "<rose>restricted access"));
|
||||||
|
|
||||||
String players = territory.fplayerList();
|
String players = territory.fplayerList();
|
||||||
String factions = territory.factionList(locFaction);
|
String factions = territory.factionList(locFaction);
|
||||||
|
@ -16,8 +16,6 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
|
|||||||
|
|
||||||
public CmdFactionsRelationAbstract()
|
public CmdFactionsRelationAbstract()
|
||||||
{
|
{
|
||||||
this.addAliases("faction");
|
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
|
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
|
||||||
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ import com.massivecraft.factions.Rel;
|
|||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.mixin.Mixin;
|
import com.massivecraft.mcore.mixin.Mixin;
|
||||||
import com.massivecraft.mcore.money.Money;
|
import com.massivecraft.mcore.money.Money;
|
||||||
|
import com.massivecraft.mcore.util.TimeDiffUtil;
|
||||||
|
import com.massivecraft.mcore.util.TimeUnit;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
public class CmdFactionsShow extends FCommand
|
public class CmdFactionsShow extends FCommand
|
||||||
@ -46,6 +49,11 @@ public class CmdFactionsShow extends FCommand
|
|||||||
msg(Txt.titleize(faction.getName(usender)));
|
msg(Txt.titleize(faction.getName(usender)));
|
||||||
msg("<a>Description: <i>%s", faction.getDescription());
|
msg("<a>Description: <i>%s", faction.getDescription());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
// Display important flags
|
// Display important flags
|
||||||
// TODO: Find the non default flags, and display them instead.
|
// TODO: Find the non default flags, and display them instead.
|
||||||
if (faction.getFlag(FFlag.PERMANENT))
|
if (faction.getFlag(FFlag.PERMANENT))
|
||||||
|
@ -44,6 +44,7 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
this.setName(that.name);
|
this.setName(that.name);
|
||||||
this.setDescription(that.description);
|
this.setDescription(that.description);
|
||||||
|
this.setCreatedAtMillis(that.createdAtMillis);
|
||||||
this.setHome(that.home);
|
this.setHome(that.home);
|
||||||
this.setPowerBoost(that.powerBoost);
|
this.setPowerBoost(that.powerBoost);
|
||||||
this.setOpen(that.open);
|
this.setOpen(that.open);
|
||||||
@ -71,6 +72,10 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
// Null means the faction has no description.
|
// Null means the faction has no description.
|
||||||
private String description = null;
|
private String description = null;
|
||||||
|
|
||||||
|
// We store the creation date for the faction.
|
||||||
|
// It can be displayed on info pages etc.
|
||||||
|
private long createdAtMillis = System.currentTimeMillis();
|
||||||
|
|
||||||
// Factions can optionally set a home location.
|
// Factions can optionally set a home location.
|
||||||
// If they do their members can teleport there using /f home
|
// If they do their members can teleport there using /f home
|
||||||
// Null means the faction has no home.
|
// Null means the faction has no home.
|
||||||
@ -213,6 +218,30 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FIELD: createdAtMillis
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public long getCreatedAtMillis()
|
||||||
|
{
|
||||||
|
return this.createdAtMillis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAtMillis(long createdAtMillis)
|
||||||
|
{
|
||||||
|
// Clean input
|
||||||
|
long target = createdAtMillis;
|
||||||
|
|
||||||
|
// Detect Nochange
|
||||||
|
if (MUtil.equals(this.createdAtMillis, createdAtMillis)) return;
|
||||||
|
|
||||||
|
// Apply
|
||||||
|
this.createdAtMillis = target;
|
||||||
|
|
||||||
|
// Mark as changed
|
||||||
|
this.changed();
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// FIELD: home
|
// FIELD: home
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user