mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-23 00:42:05 +01:00
SPIGOT-4472: Add Consumer scheduler methods
By: md_5 <git@md-5.net>
This commit is contained in:
parent
a159e27b87
commit
50b925fdb0
1 changed files with 81 additions and 0 deletions
|
@ -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 {
|
||||
|
||||
|
@ -213,6 +214,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)}
|
||||
*
|
||||
|
@ -239,6 +250,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
|
||||
|
@ -263,6 +287,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
|
||||
|
@ -291,6 +327,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
|
||||
|
@ -317,6 +368,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
|
||||
|
@ -348,6 +412,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
|
||||
|
|
Loading…
Add table
Reference in a new issue