Saber-Factions/src/main/java/com/massivecraft/factions/util/AutoLeaveTask.java

29 lines
783 B
Java
Raw Normal View History

package com.massivecraft.factions.util;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.SavageFactions;
2014-04-04 20:55:21 +02:00
public class AutoLeaveTask implements Runnable {
2014-04-04 20:55:21 +02:00
private static AutoLeaveProcessTask task;
double rate;
2014-04-04 20:55:21 +02:00
public AutoLeaveTask() {
this.rate = Conf.autoLeaveRoutineRunsEveryXMinutes;
}
2014-04-04 20:55:21 +02:00
public synchronized void run() {
if (task != null && !task.isFinished()) {
2014-07-01 22:10:18 +02:00
return;
}
2014-07-01 22:10:18 +02:00
task = new AutoLeaveProcessTask();
2018-11-07 06:38:43 +01:00
task.runTaskTimer(SavageFactions.plugin, 1, 1);
2014-04-04 20:55:21 +02:00
// maybe setting has been changed? if so, restart this task at new rate
2014-07-01 22:10:18 +02:00
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) {
2018-11-07 06:38:43 +01:00
SavageFactions.plugin.startAutoLeaveTask(true);
2014-07-01 22:10:18 +02:00
}
2014-04-04 20:55:21 +02:00
}
}