mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
Don't want the scheduler taking invalid arguments as well.
By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
parent
c4d411e2bf
commit
91e69e54b4
1 changed files with 8 additions and 0 deletions
|
@ -168,6 +168,10 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int scheduleSyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period) {
|
public int scheduleSyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period) {
|
||||||
|
if (plugin == null) throw new IllegalArgumentException("Plugin can not null");
|
||||||
|
if (task == null) throw new IllegalArgumentException("Task can not null");
|
||||||
|
if (delay < 0) throw new IllegalArgumentException("Delay cannot be less than 0");
|
||||||
|
|
||||||
CraftTask newTask = new CraftTask(plugin, task, true, getCurrentTick()+delay, period);
|
CraftTask newTask = new CraftTask(plugin, task, true, getCurrentTick()+delay, period);
|
||||||
synchronized (schedulerQueue) {
|
synchronized (schedulerQueue) {
|
||||||
schedulerQueue.put(newTask, true);
|
schedulerQueue.put(newTask, true);
|
||||||
|
@ -185,6 +189,10 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int scheduleAsyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period) {
|
public int scheduleAsyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period) {
|
||||||
|
if (plugin == null) throw new IllegalArgumentException("Plugin can not null");
|
||||||
|
if (task == null) throw new IllegalArgumentException("Task can not null");
|
||||||
|
if (delay < 0) throw new IllegalArgumentException("Delay cannot be less than 0");
|
||||||
|
|
||||||
CraftTask newTask = new CraftTask(plugin, task, false, getCurrentTick()+delay, period);
|
CraftTask newTask = new CraftTask(plugin, task, false, getCurrentTick()+delay, period);
|
||||||
synchronized (schedulerQueue) {
|
synchronized (schedulerQueue) {
|
||||||
schedulerQueue.put(newTask, false);
|
schedulerQueue.put(newTask, false);
|
||||||
|
|
Loading…
Reference in a new issue