Made SaveTask routine's repeat rate configurable through new setting "saveToFileEveryXMinutes" (default 30.0, as it was previously hardcoded). Routine can be disabled by setting it to 0 or lower.
Also added in flag to make sure the routine doesn't try to run more than one iteration simultaneously if a previous iteration is still running.
This commit is contained in:
parent
7224734e17
commit
f7d57efe0b
@ -71,6 +71,8 @@ public class Conf
|
||||
|
||||
public static boolean broadcastDescriptionChanges = false;
|
||||
|
||||
public static double saveToFileEveryXMinutes = 30.0;
|
||||
|
||||
public static double autoLeaveAfterDaysOfInactivity = 10.0;
|
||||
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
|
||||
public static boolean removePlayerDataWhenBanned = true;
|
||||
|
@ -20,6 +20,8 @@ import com.massivecraft.factions.zcore.util.PermUtil;
|
||||
import com.massivecraft.factions.zcore.util.Persist;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
|
||||
|
||||
public abstract class MPlugin extends JavaPlugin
|
||||
{
|
||||
@ -88,9 +90,9 @@ public abstract class MPlugin extends JavaPlugin
|
||||
|
||||
|
||||
// Register recurring tasks
|
||||
long saveTicks = 20 * 60 * 30; // Approximately every 30 min
|
||||
if (saveTask == null)
|
||||
if (saveTask == null && Conf.saveToFileEveryXMinutes > 0.0)
|
||||
{
|
||||
long saveTicks = (long)(20 * 60 * Conf.saveToFileEveryXMinutes); // Approximately every 30 min by default
|
||||
saveTask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new SaveTask(this), saveTicks, saveTicks);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import com.massivecraft.factions.zcore.MPlugin;
|
||||
|
||||
public class SaveTask implements Runnable
|
||||
{
|
||||
static private boolean running = false;
|
||||
|
||||
MPlugin p;
|
||||
public SaveTask(MPlugin p)
|
||||
{
|
||||
@ -12,9 +14,11 @@ public class SaveTask implements Runnable
|
||||
|
||||
public void run()
|
||||
{
|
||||
if ( ! p.getAutoSave()) return;
|
||||
if ( ! p.getAutoSave() || running) return;
|
||||
running = true;
|
||||
p.preAutoSave();
|
||||
EM.saveAllToDisc();
|
||||
p.postAutoSave();
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user