From cb1926c5c1e0322d6d18a7a7c21a1b78b97e35e9 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 24 Apr 2013 08:45:52 +0200 Subject: [PATCH] Rename task classes to correspond to config values and use minutes as the unit for human readability and thinking. --- src/com/massivecraft/factions/Factions.java | 12 ++++++------ src/com/massivecraft/factions/entity/MConf.java | 7 +++---- .../{EconRewardTask.java => TaskEconLandReward.java} | 11 ++++++----- ...PlayerDataTask.java => TaskPlayerDataRemove.java} | 11 ++++++----- ...werUpdateTask.java => TaskPlayerPowerUpdate.java} | 10 +++++----- 5 files changed, 26 insertions(+), 25 deletions(-) rename src/com/massivecraft/factions/task/{EconRewardTask.java => TaskEconLandReward.java} (65%) rename src/com/massivecraft/factions/task/{RemovePlayerDataTask.java => TaskPlayerDataRemove.java} (65%) rename src/com/massivecraft/factions/task/{PowerUpdateTask.java => TaskPlayerPowerUpdate.java} (78%) diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 89767c13..54e0b162 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -34,9 +34,9 @@ import com.massivecraft.factions.listeners.FactionsListenerMain; import com.massivecraft.factions.listeners.TodoFactionsPlayerListener; import com.massivecraft.factions.mixin.PowerMixin; import com.massivecraft.factions.mixin.PowerMixinDefault; -import com.massivecraft.factions.task.RemovePlayerDataTask; -import com.massivecraft.factions.task.EconRewardTask; -import com.massivecraft.factions.task.PowerUpdateTask; +import com.massivecraft.factions.task.TaskPlayerDataRemove; +import com.massivecraft.factions.task.TaskEconLandReward; +import com.massivecraft.factions.task.TaskPlayerPowerUpdate; import com.massivecraft.mcore.MPlugin; import com.massivecraft.mcore.usys.Aspect; @@ -136,9 +136,9 @@ public class Factions extends MPlugin getServer().getPluginManager().registerEvents(this.playerListener, this); // Schedule recurring non-tps-dependent tasks - PowerUpdateTask.get().schedule(this); - RemovePlayerDataTask.get().schedule(this); - EconRewardTask.get().schedule(this); + TaskPlayerPowerUpdate.get().schedule(this); + TaskPlayerDataRemove.get().schedule(this); + TaskEconLandReward.get().schedule(this); // Register built in chat modifiers ChatModifierLc.get().register(); diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index bcdb22ef..42cecd92 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -9,7 +9,6 @@ import org.bukkit.event.EventPriority; import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.mcore.store.Entity; -import com.massivecraft.mcore.util.TimeUnit; public class MConf extends Entity { @@ -38,9 +37,9 @@ public class MConf extends Entity // TASKS // -------------------------------------------- // - public long taskPowerMillis = TimeUnit.MILLIS_PER_MINUTE; - public long taskEconMillis = 20 * TimeUnit.MILLIS_PER_MINUTE; - public long taskAutoLeaveMillis = 5 * TimeUnit.MILLIS_PER_MINUTE; + public double taskPlayerPowerUpdateMinutes = 1; + public double taskPlayerDataRemoveMinutes = 5; + public double taskEconLandRewardMinutes = 20; // -------------------------------------------- // // REMOVE DATA diff --git a/src/com/massivecraft/factions/task/EconRewardTask.java b/src/com/massivecraft/factions/task/TaskEconLandReward.java similarity index 65% rename from src/com/massivecraft/factions/task/EconRewardTask.java rename to src/com/massivecraft/factions/task/TaskEconLandReward.java index e1015fcc..0ad2c0c4 100644 --- a/src/com/massivecraft/factions/task/EconRewardTask.java +++ b/src/com/massivecraft/factions/task/TaskEconLandReward.java @@ -4,15 +4,16 @@ import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; import com.massivecraft.mcore.ModuloRepeatTask; +import com.massivecraft.mcore.util.TimeUnit; -public class EconRewardTask extends ModuloRepeatTask +public class TaskEconLandReward extends ModuloRepeatTask { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EconRewardTask i = new EconRewardTask(); - public static EconRewardTask get() { return i; } + private static TaskEconLandReward i = new TaskEconLandReward(); + public static TaskEconLandReward get() { return i; } // -------------------------------------------- // // OVERRIDE: MODULO REPEAT TASK @@ -21,13 +22,13 @@ public class EconRewardTask extends ModuloRepeatTask @Override public long getDelayMillis() { - return MConf.get().taskEconMillis; + return (long) (MConf.get().taskEconLandRewardMinutes * TimeUnit.MILLIS_PER_MINUTE); } @Override public void setDelayMillis(long delayMillis) { - MConf.get().taskEconMillis = delayMillis; + MConf.get().taskEconLandRewardMinutes = delayMillis / (double) TimeUnit.MILLIS_PER_MINUTE; } @Override diff --git a/src/com/massivecraft/factions/task/RemovePlayerDataTask.java b/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java similarity index 65% rename from src/com/massivecraft/factions/task/RemovePlayerDataTask.java rename to src/com/massivecraft/factions/task/TaskPlayerDataRemove.java index 677a7f2d..aeb0982b 100644 --- a/src/com/massivecraft/factions/task/RemovePlayerDataTask.java +++ b/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java @@ -4,15 +4,16 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.UPlayerColl; import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.mcore.ModuloRepeatTask; +import com.massivecraft.mcore.util.TimeUnit; -public class RemovePlayerDataTask extends ModuloRepeatTask +public class TaskPlayerDataRemove extends ModuloRepeatTask { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static RemovePlayerDataTask i = new RemovePlayerDataTask(); - public static RemovePlayerDataTask get() { return i; } + private static TaskPlayerDataRemove i = new TaskPlayerDataRemove(); + public static TaskPlayerDataRemove get() { return i; } // -------------------------------------------- // // OVERRIDE: MODULO REPEAT TASK @@ -21,13 +22,13 @@ public class RemovePlayerDataTask extends ModuloRepeatTask @Override public long getDelayMillis() { - return MConf.get().taskAutoLeaveMillis; + return (long) (MConf.get().taskPlayerDataRemoveMinutes * TimeUnit.MILLIS_PER_MINUTE); } @Override public void setDelayMillis(long delayMillis) { - MConf.get().taskAutoLeaveMillis = delayMillis; + MConf.get().taskPlayerDataRemoveMinutes = delayMillis / (double) TimeUnit.MILLIS_PER_MINUTE; } @Override diff --git a/src/com/massivecraft/factions/task/PowerUpdateTask.java b/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java similarity index 78% rename from src/com/massivecraft/factions/task/PowerUpdateTask.java rename to src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java index adbcb0c9..fde4a1e1 100644 --- a/src/com/massivecraft/factions/task/PowerUpdateTask.java +++ b/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java @@ -10,14 +10,14 @@ import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReaso import com.massivecraft.mcore.ModuloRepeatTask; import com.massivecraft.mcore.util.TimeUnit; -public class PowerUpdateTask extends ModuloRepeatTask +public class TaskPlayerPowerUpdate extends ModuloRepeatTask { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static PowerUpdateTask i = new PowerUpdateTask(); - public static PowerUpdateTask get() { return i; } + private static TaskPlayerPowerUpdate i = new TaskPlayerPowerUpdate(); + public static TaskPlayerPowerUpdate get() { return i; } // -------------------------------------------- // // OVERRIDE: MODULO REPEAT TASK @@ -26,13 +26,13 @@ public class PowerUpdateTask extends ModuloRepeatTask @Override public long getDelayMillis() { - return MConf.get().taskPowerMillis; + return (long) (MConf.get().taskPlayerPowerUpdateMinutes * TimeUnit.MILLIS_PER_MINUTE); } @Override public void setDelayMillis(long delayMillis) { - MConf.get().taskPowerMillis = delayMillis; + MConf.get().taskPlayerPowerUpdateMinutes = delayMillis / (double) TimeUnit.MILLIS_PER_MINUTE; } @Override