diff options
author | md_5 <git@md-5.net> | 2018-11-23 11:40:21 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-11-23 11:40:21 +1100 |
commit | a35fa83843daa00df508e88a5def5a01d6199e1f (patch) | |
tree | 3eb33b58c11848e90391ce46eae17c572a24101e /src | |
parent | 689f15654dbcf994a9482d59066e3847cd6baf95 (diff) | |
download | bukkit-a35fa83843daa00df508e88a5def5a01d6199e1f.tar bukkit-a35fa83843daa00df508e88a5def5a01d6199e1f.tar.gz bukkit-a35fa83843daa00df508e88a5def5a01d6199e1f.tar.lz bukkit-a35fa83843daa00df508e88a5def5a01d6199e1f.tar.xz bukkit-a35fa83843daa00df508e88a5def5a01d6199e1f.zip |
SPIGOT-4472: Add Consumer scheduler methods
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/scheduler/BukkitScheduler.java | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java index 3e696ec5..abd0dffb 100644 --- a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java +++ b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.Plugin; import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.List; +import java.util.function.Consumer; public interface BukkitScheduler { @@ -214,6 +215,16 @@ public interface BukkitScheduler { public BukkitTask runTask(Plugin plugin, Runnable task) throws IllegalArgumentException; /** + * Returns a task that will run on the next server tick. + * + * @param plugin the reference to the plugin scheduling task + * @param task the task to be run + * @throws IllegalArgumentException if plugin is null + * @throws IllegalArgumentException if task is null + */ + public void runTask(Plugin plugin, Consumer<BukkitTask> task) throws IllegalArgumentException; + + /** * @deprecated Use {@link BukkitRunnable#runTask(Plugin)} * * @param plugin the reference to the plugin scheduling task @@ -240,6 +251,19 @@ public interface BukkitScheduler { public BukkitTask runTaskAsynchronously(Plugin plugin, Runnable task) throws IllegalArgumentException; /** + * <b>Asynchronous tasks should never access any API in Bukkit. Great care + * should be taken to assure the thread-safety of asynchronous tasks.</b> + * <p> + * Returns a task that will run asynchronously. + * + * @param plugin the reference to the plugin scheduling task + * @param task the task to be run + * @throws IllegalArgumentException if plugin is null + * @throws IllegalArgumentException if task is null + */ + public void runTaskAsynchronously(Plugin plugin, Consumer<BukkitTask> task) throws IllegalArgumentException; + + /** * @deprecated Use {@link BukkitRunnable#runTaskAsynchronously(Plugin)} * @param plugin the reference to the plugin scheduling task * @param task the task to be run @@ -264,6 +288,18 @@ public interface BukkitScheduler { public BukkitTask runTaskLater(Plugin plugin, Runnable task, long delay) throws IllegalArgumentException; /** + * Returns a task that will run after the specified number of server + * ticks. + * + * @param plugin the reference to the plugin scheduling task + * @param task the task to be run + * @param delay the ticks to wait before running the task + * @throws IllegalArgumentException if plugin is null + * @throws IllegalArgumentException if task is null + */ + public void runTaskLater(Plugin plugin, Consumer<BukkitTask> task, long delay) throws IllegalArgumentException; + + /** * @deprecated Use {@link BukkitRunnable#runTaskLater(Plugin, long)} * @param plugin the reference to the plugin scheduling task * @param task the task to be run @@ -292,6 +328,21 @@ public interface BukkitScheduler { public BukkitTask runTaskLaterAsynchronously(Plugin plugin, Runnable task, long delay) throws IllegalArgumentException; /** + * <b>Asynchronous tasks should never access any API in Bukkit. Great care + * should be taken to assure the thread-safety of asynchronous tasks.</b> + * <p> + * Returns a task that will run asynchronously after the specified number + * of server ticks. + * + * @param plugin the reference to the plugin scheduling task + * @param task the task to be run + * @param delay the ticks to wait before running the task + * @throws IllegalArgumentException if plugin is null + * @throws IllegalArgumentException if task is null + */ + public void runTaskLaterAsynchronously(Plugin plugin, Consumer<BukkitTask> task, long delay) throws IllegalArgumentException; + + /** * @deprecated Use {@link BukkitRunnable#runTaskLaterAsynchronously(Plugin, long)} * @param plugin the reference to the plugin scheduling task * @param task the task to be run @@ -318,6 +369,19 @@ public interface BukkitScheduler { public BukkitTask runTaskTimer(Plugin plugin, Runnable task, long delay, long period) throws IllegalArgumentException; /** + * Returns a task that will repeatedly run until cancelled, starting after + * the specified number of server ticks. + * + * @param plugin the reference to the plugin scheduling task + * @param task the task to be run + * @param delay the ticks to wait before running the task + * @param period the ticks to wait between runs + * @throws IllegalArgumentException if plugin is null + * @throws IllegalArgumentException if task is null + */ + public void runTaskTimer(Plugin plugin, Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException; + + /** * @deprecated Use {@link BukkitRunnable#runTaskTimer(Plugin, long, long)} * @param plugin the reference to the plugin scheduling task * @param task the task to be run @@ -349,6 +413,23 @@ public interface BukkitScheduler { public BukkitTask runTaskTimerAsynchronously(Plugin plugin, Runnable task, long delay, long period) throws IllegalArgumentException; /** + * <b>Asynchronous tasks should never access any API in Bukkit. Great care + * should be taken to assure the thread-safety of asynchronous tasks.</b> + * <p> + * Returns a task that will repeatedly run asynchronously until cancelled, + * starting after the specified number of server ticks. + * + * @param plugin the reference to the plugin scheduling task + * @param task the task to be run + * @param delay the ticks to wait before running the task for the first + * time + * @param period the ticks to wait between runs + * @throws IllegalArgumentException if plugin is null + * @throws IllegalArgumentException if task is null + */ + public void runTaskTimerAsynchronously(Plugin plugin, Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException; + + /** * @deprecated Use {@link BukkitRunnable#runTaskTimerAsynchronously(Plugin, long, long)} * @param plugin the reference to the plugin scheduling task * @param task the task to be run |