2015-07-30 19:24:01 +02:00
|
|
|
package com.plotsquared.bukkit.util;
|
2015-02-19 07:08:15 +01:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
2015-02-19 07:08:15 +01:00
|
|
|
import com.intellectualcrafters.plot.util.TaskManager;
|
2015-07-27 19:50:04 +02:00
|
|
|
import com.plotsquared.bukkit.BukkitMain;
|
2015-02-19 07:08:15 +01:00
|
|
|
|
2015-09-13 06:04:31 +02:00
|
|
|
public class BukkitTaskManager extends TaskManager {
|
2015-02-20 07:34:19 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public int taskRepeat(final Runnable r, final int interval) {
|
2015-02-22 12:30:46 +01:00
|
|
|
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-08-02 13:56:18 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public int taskRepeatAsync(final Runnable r, final int interval) {
|
2015-08-02 13:56:18 +02:00
|
|
|
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
|
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-02-20 07:34:19 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void taskAsync(final Runnable r) {
|
2015-02-23 01:33:48 +01:00
|
|
|
BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r).getTaskId();
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-02-20 07:34:19 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void task(final Runnable r) {
|
2015-02-23 01:33:48 +01:00
|
|
|
BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r).getTaskId();
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-02-20 07:34:19 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void taskLater(final Runnable r, final int delay) {
|
2015-02-23 01:33:48 +01:00
|
|
|
BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay).getTaskId();
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-02-19 11:29:17 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void taskLaterAsync(final Runnable r, final int delay) {
|
2015-02-23 02:32:27 +01:00
|
|
|
BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay);
|
2015-02-22 12:30:46 +01:00
|
|
|
}
|
2015-09-13 06:04:31 +02:00
|
|
|
|
2015-02-22 12:30:46 +01:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void cancelTask(final int task) {
|
|
|
|
if (task != -1) {
|
2015-02-22 12:30:46 +01:00
|
|
|
Bukkit.getScheduler().cancelTask(task);
|
|
|
|
}
|
2015-02-19 11:29:17 +01:00
|
|
|
}
|
2015-02-19 07:08:15 +01:00
|
|
|
}
|