From 6d9ef913158dc6f5f5db7b1a9aa155f894047dd7 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Thu, 10 Jan 2013 19:58:25 -0500 Subject: [PATCH] Make purge task run options configurable. Also adds ability to disable the task entirely. --- src/main/java/com/gmail/nossr50/config/Config.java | 1 + src/main/java/com/gmail/nossr50/mcMMO.java | 11 +++++++++-- src/main/resources/config.yml | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index d6750fb80..7d67d0f9f 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -35,6 +35,7 @@ public class Config extends ConfigLoader { public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); } public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); } public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); } + public int getPurgeInterval() { return config.getInt("General.Purge_Interval", 0); } /* mySQL */ public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 993264652..2311f17a5 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -197,8 +197,15 @@ public class mcMMO extends JavaPlugin { scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40); //Chunklet unloader (Runs every 20 seconds by default) scheduler.scheduleSyncRepeatingTask(this, new ChunkletUnloader(), 0, ChunkletUnloader.RUN_INTERVAL * 20); - //Old & Powerless User remover (Runs every 6 hours) - scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, 21600 * 20); + + //Old & Powerless User remover + int purgeInterval = Config.getInstance().getPurgeInterval(); + if (purgeInterval == 0) { + scheduler.runTask(this, new UserPurgeTask()); + } + else if (purgeInterval > 0) { + scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, purgeInterval * 60L * 60L * 20L); + } registerCommands(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 96975948f..452998ff6 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -17,6 +17,10 @@ General: #Allow mcMMO to inform other plugins of damage being dealt Event_Callback: true Power_Level_Cap: 0 + #Amount of time (in hours) to wait between database purging + #To only run at server start, set to 0 + #To never run, set to -1 + Purge_Interval: 0 # # Settings for using a mySQL database