"autoLeaveAfterDaysOfInactivity" routine now runs only once every few minutes instead of running every time a player logs in. New setting "autoLeaveRoutineRunsEveryXMinutes" (default 5 minutes) to determine just how often the routine is run.

The routine is also slightly more careful about how it calculates how long a player has been offline.
This commit is contained in:
Brettflan
2012-02-26 16:55:58 -06:00
parent d71bd15a79
commit de3c7436fe
5 changed files with 60 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.FFlag;
import com.massivecraft.factions.struct.FPerm;
import com.massivecraft.factions.struct.Rel;
import com.massivecraft.factions.util.AutoLeaveTask;
import com.massivecraft.factions.zcore.MPlugin;
import com.google.gson.GsonBuilder;
@@ -56,6 +57,7 @@ public class P extends MPlugin
private boolean locked = false;
public boolean getLocked() {return this.locked;}
public void setLocked(boolean val) {this.locked = val; this.setAutoSave(val);}
private Integer AutoLeaveTask = null;
// Commands
public FCmdRoot cmdBase;
@@ -99,6 +101,9 @@ public class P extends MPlugin
Worldguard.init(this);
}
// start up task which runs the autoLeaveAfterDaysOfInactivity routine
startAutoLeaveTask(false);
// Register Event Handlers
getServer().getPluginManager().registerEvents(playerListener, this);
getServer().getPluginManager().registerEvents(chatEarlyListener, this);
@@ -131,9 +136,29 @@ public class P extends MPlugin
Board.save();
Conf.save();
EssentialsFeatures.unhookChat();
if (AutoLeaveTask != null)
{
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
AutoLeaveTask = null;
}
super.onDisable();
}
public void startAutoLeaveTask(boolean restartIfRunning)
{
if (AutoLeaveTask != null)
{
if ( ! restartIfRunning) return;
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
}
if (Conf.autoLeaveRoutineRunsEveryXMinutes > 0.0)
{
long ticks = (long)(20 * 60 * Conf.autoLeaveRoutineRunsEveryXMinutes);
AutoLeaveTask = getServer().getScheduler().scheduleSyncRepeatingTask(this, new AutoLeaveTask(), ticks, ticks);
}
}
@Override
public void postAutoSave()
{