PlotSquared/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java

53 lines
1.7 KiB
Java
Raw Normal View History

2015-07-30 19:24:01 +02:00
package com.plotsquared.bukkit.util;
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;
import org.bukkit.Bukkit;
2015-02-19 07:08:15 +01:00
2015-09-13 06:04:31 +02:00
public class BukkitTaskManager extends TaskManager {
private final BukkitMain bukkitMain;
public BukkitTaskManager(BukkitMain bukkitMain) {
this.bukkitMain = bukkitMain;
}
2015-02-20 07:34:19 +01:00
@Override
2016-03-29 01:30:55 +02:00
public int taskRepeat(Runnable runnable, int interval) {
return this.bukkitMain.getServer().getScheduler().scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
2015-02-19 07:08:15 +01:00
}
2016-03-23 02:41:37 +01:00
@SuppressWarnings("deprecation")
@Override
2016-03-29 01:30:55 +02:00
public int taskRepeatAsync(Runnable runnable, int interval) {
return this.bukkitMain.getServer().getScheduler().scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
2015-08-02 13:56:18 +02:00
}
2015-02-20 07:34:19 +01:00
@Override
2016-03-29 01:30:55 +02:00
public void taskAsync(Runnable runnable) {
this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable).getTaskId();
2015-02-19 07:08:15 +01:00
}
2015-02-20 07:34:19 +01:00
@Override
2016-03-29 01:30:55 +02:00
public void task(Runnable runnable) {
this.bukkitMain.getServer().getScheduler().runTask(this.bukkitMain, runnable).getTaskId();
2015-02-19 07:08:15 +01:00
}
2015-02-20 07:34:19 +01:00
@Override
2016-03-29 01:30:55 +02:00
public void taskLater(Runnable runnable, int delay) {
this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay).getTaskId();
2015-02-19 07:08:15 +01:00
}
2015-02-19 11:29:17 +01:00
@Override
2016-03-29 01:30:55 +02:00
public void taskLaterAsync(Runnable runnable, int delay) {
this.bukkitMain.getServer().getScheduler().runTaskLaterAsynchronously(this.bukkitMain, runnable, delay);
2015-02-22 12:30:46 +01:00
}
2015-02-22 12:30:46 +01:00
@Override
2016-03-23 02:41:37 +01:00
public void cancelTask(int task) {
2015-09-13 06:04:31 +02:00
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
}