2015-01-09 15:05:10 +01:00
|
|
|
package com.intellectualcrafters.plot.util;
|
|
|
|
|
2015-07-03 13:21:21 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
2015-01-09 15:05:10 +01:00
|
|
|
|
2015-07-05 17:44:10 +02:00
|
|
|
import org.apache.commons.lang.mutable.MutableInt;
|
|
|
|
|
|
|
|
import com.intellectualcrafters.plot.PS;
|
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
public abstract class TaskManager {
|
2015-02-20 07:34:19 +01:00
|
|
|
public static HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
2015-04-01 02:52:22 +02:00
|
|
|
|
|
|
|
public static MutableInt index = new MutableInt(0);
|
|
|
|
public static HashMap<Integer, Integer> tasks = new HashMap<>();
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-22 12:30:46 +01:00
|
|
|
public static int runTaskRepeat(final Runnable r, final int interval) {
|
2015-02-20 07:34:19 +01:00
|
|
|
if (r != null) {
|
2015-07-03 14:15:20 +02:00
|
|
|
return PS.get().TASK.taskRepeat(r, interval);
|
2015-02-20 07:34:19 +01:00
|
|
|
}
|
2015-02-22 12:30:46 +01:00
|
|
|
return -1;
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-23 01:33:48 +01:00
|
|
|
public static void runTaskAsync(final Runnable r) {
|
2015-02-20 07:34:19 +01:00
|
|
|
if (r != null) {
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.get().TASK.taskAsync(r);
|
2015-02-20 07:34:19 +01:00
|
|
|
}
|
2015-01-09 15:05:10 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-23 01:33:48 +01:00
|
|
|
public static void runTask(final Runnable r) {
|
2015-02-20 07:34:19 +01:00
|
|
|
if (r != null) {
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.get().TASK.task(r);
|
2015-02-20 07:34:19 +01:00
|
|
|
}
|
2015-02-15 16:22:00 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-04-29 14:04:25 +02:00
|
|
|
/**
|
|
|
|
* Run task later (delay in ticks)
|
|
|
|
* @param r
|
|
|
|
* @param delay
|
|
|
|
*/
|
2015-02-23 01:33:48 +01:00
|
|
|
public static void runTaskLater(final Runnable r, final int delay) {
|
2015-02-20 07:34:19 +01:00
|
|
|
if (r != null) {
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.get().TASK.taskLater(r, delay);
|
2015-02-20 07:34:19 +01:00
|
|
|
}
|
2015-01-31 08:09:48 +01:00
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-23 01:33:48 +01:00
|
|
|
public static void runTaskLaterAsync(final Runnable r, final int delay) {
|
2015-02-20 07:34:19 +01:00
|
|
|
if (r != null) {
|
2015-07-03 14:15:20 +02:00
|
|
|
PS.get().TASK.taskLaterAsync(r, delay);
|
2015-02-20 07:34:19 +01:00
|
|
|
}
|
2015-02-19 09:51:10 +01:00
|
|
|
}
|
2015-07-03 13:21:21 +02:00
|
|
|
|
|
|
|
public abstract int taskRepeat(final Runnable r, int interval);
|
|
|
|
|
|
|
|
public abstract void taskAsync(final Runnable r);
|
|
|
|
|
|
|
|
public abstract void task(final Runnable r);
|
|
|
|
|
|
|
|
public abstract void taskLater(final Runnable r, int delay);
|
|
|
|
|
|
|
|
public abstract void taskLaterAsync(final Runnable r, int delay);
|
|
|
|
|
|
|
|
public abstract void cancelTask(int task);
|
2015-01-09 15:05:10 +01:00
|
|
|
}
|