diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java index 0c864bf6..c5611f2a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java @@ -91,7 +91,7 @@ public class CmdFactionsAccess extends FCommand private void showAccessList(TerritoryAccess territory, Faction locFaction) { - msg("Host faction %s has %s in this territory.", locFaction.getName(), Txt.parse(territory.isHostFactionAllowed() ? "normal access" : "restricted access")); + msg("Host faction %s has %s in this territory.", locFaction.getName(), Txt.parse(territory.isHostFactionAllowed() ? "normal access" : "restricted access")); String players = territory.fplayerList(); String factions = territory.factionList(locFaction); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index 82e44a70..00eb41b9 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -16,8 +16,6 @@ public abstract class CmdFactionsRelationAbstract extends FCommand public CmdFactionsRelationAbstract() { - this.addAliases("faction"); - this.addRequirements(ReqHasPerm.get(Perm.RELATION.node)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsShow.java index 55e611d5..7c2a298b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsShow.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsShow.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -17,6 +18,8 @@ import com.massivecraft.factions.Rel; import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.money.Money; +import com.massivecraft.mcore.util.TimeDiffUtil; +import com.massivecraft.mcore.util.TimeUnit; import com.massivecraft.mcore.util.Txt; public class CmdFactionsShow extends FCommand @@ -46,6 +49,11 @@ public class CmdFactionsShow extends FCommand msg(Txt.titleize(faction.getName(usender))); msg("Description: %s", faction.getDescription()); + long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis(); + LinkedHashMap ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3); + String ageString = TimeDiffUtil.formatedVerboose(ageUnitcounts, ""); + msg("Age: %s", ageString); + // Display important flags // TODO: Find the non default flags, and display them instead. if (faction.getFlag(FFlag.PERMANENT)) diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index b79f0595..5117fe2e 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -44,6 +44,7 @@ public class Faction extends Entity implements EconomyParticipator { this.setName(that.name); this.setDescription(that.description); + this.setCreatedAtMillis(that.createdAtMillis); this.setHome(that.home); this.setPowerBoost(that.powerBoost); this.setOpen(that.open); @@ -71,6 +72,10 @@ public class Faction extends Entity implements EconomyParticipator // Null means the faction has no description. 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. // If they do their members can teleport there using /f home // Null means the faction has no home. @@ -213,6 +218,30 @@ public class Faction extends Entity implements EconomyParticipator 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 // -------------------------------------------- //