From 4496d4251b39b5c4cf06ff6024e1d1d72be31145 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 7 Apr 2020 23:22:53 -0400 Subject: [PATCH] Finished Grace Timer :) --- .../java/com/massivecraft/factions/tag/GeneralTag.java | 3 ++- .../massivecraft/factions/util/timer/type/GraceTimer.java | 8 ++++---- .../com/massivecraft/factions/zcore/util/TagReplacer.java | 4 ++++ src/main/resources/config.yml | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/tag/GeneralTag.java b/src/main/java/com/massivecraft/factions/tag/GeneralTag.java index ac85a606..81a7963f 100644 --- a/src/main/java/com/massivecraft/factions/tag/GeneralTag.java +++ b/src/main/java/com/massivecraft/factions/tag/GeneralTag.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.tag; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FactionsPlugin; +import com.massivecraft.factions.util.timer.TimerManager; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; @@ -12,7 +13,7 @@ public enum GeneralTag implements Tag { /** * @author FactionsUUID Team */ - + GRACE_TIMER("{grace-time}", () -> String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true))), MAX_WARPS("{max-warps}", () -> String.valueOf(FactionsPlugin.getInstance().getConfig().getInt("max-warps", 5))), MAX_ALLIES("{max-allies}", () -> getRelation("ally")), MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")), diff --git a/src/main/java/com/massivecraft/factions/util/timer/type/GraceTimer.java b/src/main/java/com/massivecraft/factions/util/timer/type/GraceTimer.java index cde70416..f5a740df 100644 --- a/src/main/java/com/massivecraft/factions/util/timer/type/GraceTimer.java +++ b/src/main/java/com/massivecraft/factions/util/timer/type/GraceTimer.java @@ -44,14 +44,14 @@ public class GraceTimer extends GlobalTimer implements Listener { @Override public void load(Config config) { - config.get(this.name, isPaused()); - config.get(this.name, getRemaining()); + setPaused(config.getBoolean(this.name + ".paused")); + setRemaining(config.getLong(this.name + ".time"), false); } @Override public void save(Config config) { - config.set(this.name, isPaused()); - config.set(this.name, getRemaining()); + config.set(this.name + ".paused", isPaused()); + config.set(this.name + ".time", getRemaining()); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java index a18f4089..37311e0c 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.zcore.util; import com.massivecraft.factions.*; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.util.timer.TimerManager; import org.apache.commons.lang.time.DurationFormatUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -82,6 +83,7 @@ public enum TagReplacer { /** * General variables, require no faction or player */ + GRACE_TIMER(TagType.GENERAL, "{grace-time}"), MAX_WARPS(TagType.GENERAL, "{max-warps}"), MAX_ALLIES(TagType.GENERAL, "{max-allies}"), MAX_ALTS(TagType.GENERAL, "{max-alts}"), @@ -125,6 +127,8 @@ public enum TagReplacer { */ protected String getValue() { switch (this) { + case GRACE_TIMER: + return String.valueOf(TimerManager.getRemaining(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining(), true)); case TOTAL_ONLINE: return String.valueOf(Bukkit.getOnlinePlayers().size()); case FACTIONLESS: diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9de61c3c..59437e69 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1560,6 +1560,7 @@ Wild: # - {action-access-color} : Access color # General variables. Can be used anywhere. +# - {grace-time} : Time of Grace Period # - {total-online} : Total # of players on the server # - {max-warps} : Max # of warps a faction can set # - {max-allies} : Max # of allies a faction can have