Rename task classes to correspond to config values and use minutes as the unit for human readability and thinking.

This commit is contained in:
Olof Larsson 2013-04-24 08:45:52 +02:00
parent 825d937c84
commit cb1926c5c1
5 changed files with 26 additions and 25 deletions

View File

@ -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();

View File

@ -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<MConf>
{
@ -38,9 +37,9 @@ public class MConf extends Entity<MConf>
// 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

View File

@ -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

View File

@ -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

View File

@ -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