diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java index 7a20646c8..9fc1bf9a5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java @@ -1,36 +1,33 @@ package mineplex.game.clans.clans; import java.util.EnumMap; -import java.util.EnumSet; import java.util.concurrent.TimeUnit; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; public class ClanEnergyTracker extends MiniPlugin { private ClansManager _clans; - private EnumMap _updateMap; + private EnumMap> _updateMap; public ClanEnergyTracker(JavaPlugin plugin, ClansManager clans) { super("Clan Energy Tracker", plugin); _clans = clans; - _updateMap = new EnumMap(UpdateType.class); - _updateMap.put(UpdateType.MIN_05, TimeUnit.HOURS.toMillis(1)); - _updateMap.put(UpdateType.MIN_10, TimeUnit.HOURS.toMillis(4)); - _updateMap.put(UpdateType.MIN_30, TimeUnit.DAYS.toMillis(1)); - _updateMap.put(UpdateType.HOUR_01, TimeUnit.DAYS.toMillis(2)); + _updateMap = new EnumMap>(UpdateType.class); + _updateMap.put(UpdateType.MIN_05, Pair.create(0L, TimeUnit.HOURS.toMillis(1))); + _updateMap.put(UpdateType.MIN_10, Pair.create(TimeUnit.HOURS.toMillis(1), TimeUnit.HOURS.toMillis(4))); + _updateMap.put(UpdateType.MIN_30, Pair.create(TimeUnit.HOURS.toMillis(4), TimeUnit.DAYS.toMillis(1))); + _updateMap.put(UpdateType.HOUR_01, Pair.create(TimeUnit.DAYS.toMillis(1), TimeUnit.DAYS.toMillis(2))); } @EventHandler @@ -42,9 +39,7 @@ public class ClanEnergyTracker extends MiniPlugin if (_updateMap.containsKey(event.getType())) { for (ClanInfo clan : _clans.getClanMap().values()) - { display(clan, event.getType()); - } } } @@ -60,13 +55,12 @@ public class ClanEnergyTracker extends MiniPlugin // Energy Remaining in milliseconds long energyRemaining = (clan.getEnergy() / clan.getEnergyCostPerMinute()) * 60000L; - Long energyForDisplay = _updateMap.get(type); + Pair energyBounds = _updateMap.get(type); - if (energyForDisplay != null && energyRemaining < energyForDisplay.longValue()) + if (energyBounds != null && energyRemaining > energyBounds.getLeft() && energyRemaining < energyBounds.getRight()) { _clans.middleTextClan(clan, C.cRed + "Urgent", "Clan Energy is almost depleted", 20, 200, 80); _clans.messageClan(clan, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!")); } } - }