Class BukkitSchedulerMock
java.lang.Object
be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock
- All Implemented Interfaces:
BukkitScheduler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> @NotNull Future<T>callSyncMethod(@NotNull Plugin plugin, @NotNull Callable<T> task) voidcancelTask(int taskId) voidcancelTasks(@NotNull Plugin plugin) @NotNull Future<?>executeAsyncEvent(@NotNull Event event) executeAsyncEvent(T event, @Nullable Consumer<T> func) protected int@NotNull List<BukkitWorker>longGet the current tick of the server.@NotNull ExecutorgetMainThreadExecutor(@NotNull Plugin plugin) intGets the number of async tasks which are awaiting execution.@NotNull List<BukkitTask>booleanisCurrentlyRunning(int taskId) booleanisQueued(int taskId) voidPerform one tick on the server.voidperformTicks(long ticks) Perform a number of ticks on the server.@NotNull BukkitTaskvoidrunTask(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task) @NotNull BukkitTaskrunTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task) Deprecated.@NotNull BukkitTaskrunTaskAsynchronously(@NotNull Plugin plugin, @NotNull Runnable task) voidrunTaskAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task) @NotNull BukkitTaskrunTaskAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task) @NotNull BukkitTaskrunTaskLater(@NotNull Plugin plugin, @NotNull Runnable task, long delay) voidrunTaskLater(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay) @NotNull BukkitTaskrunTaskLater(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) @NotNull BukkitTaskrunTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Runnable task, long delay) voidrunTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay) @NotNull BukkitTaskrunTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) @NotNull BukkitTaskrunTaskTimer(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) voidrunTaskTimer(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay, long period) @NotNull BukkitTaskrunTaskTimer(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) Deprecated.@NotNull BukkitTaskrunTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) voidrunTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay, long period) @NotNull BukkitTaskrunTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) intscheduleAsyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task) Deprecated.intscheduleAsyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay) Deprecated.intscheduleAsyncRepeatingTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) Deprecated.intscheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task) intscheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay) intscheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task) Deprecated.intscheduleSyncDelayedTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay) Deprecated.intscheduleSyncRepeatingTask(@NotNull Plugin plugin, @NotNull Runnable task, long delay, long period) intscheduleSyncRepeatingTask(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) Deprecated.voidsetShutdownTimeout(long timeout) Sets the maximum time to wait for async tasks to finish before terminating them.voidshutdown()Shuts the scheduler down.voidvoidWaits until all asynchronous tasks have finished executing.
-
Constructor Details
-
BukkitSchedulerMock
public BukkitSchedulerMock()
-
-
Method Details
-
setShutdownTimeout
public void setShutdownTimeout(long timeout) Sets the maximum time to wait for async tasks to finish before terminating them.- Parameters:
timeout- The timeout in milliseconds.
-
shutdown
public void shutdown()Shuts the scheduler down. Note that this function will throw exception that where thrown by old asynchronous tasks. -
executeAsyncEvent
-
executeAsyncEvent
-
getCurrentTick
public long getCurrentTick()Get the current tick of the server.- Returns:
- The current tick of the server.
-
performOneTick
public void performOneTick()Perform one tick on the server. -
performTicks
public void performTicks(long ticks) Perform a number of ticks on the server.- Parameters:
ticks- The number of ticks to executed.
-
getNumberOfQueuedAsyncTasks
public int getNumberOfQueuedAsyncTasks()Gets the number of async tasks which are awaiting execution.- Returns:
- The number of async tasks which are pending execution.
-
waitAsyncTasksFinished
public void waitAsyncTasksFinished()Waits until all asynchronous tasks have finished executing. If you have an asynchronous task that runs indefinitely, this function will never return. Note that this will not wait for async events to finish. -
waitAsyncEventsFinished
public void waitAsyncEventsFinished() -
runTask
@NotNull public @NotNull BukkitTask runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) - Specified by:
runTaskin interfaceBukkitScheduler
-
runTask
@Deprecated @NotNull public @NotNull BukkitTask runTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) Deprecated.- Specified by:
runTaskin interfaceBukkitScheduler
-
runTaskLater
@NotNull public @NotNull BukkitTask runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) - Specified by:
runTaskLaterin interfaceBukkitScheduler
-
runTaskTimer
@NotNull public @NotNull BukkitTask runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) - Specified by:
runTaskTimerin interfaceBukkitScheduler
-
runTaskTimer
@Deprecated @NotNull public @NotNull BukkitTask runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) Deprecated.- Specified by:
runTaskTimerin interfaceBukkitScheduler
-
scheduleSyncDelayedTask
public int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) - Specified by:
scheduleSyncDelayedTaskin interfaceBukkitScheduler
-
scheduleSyncDelayedTask
@Deprecated public int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) Deprecated.- Specified by:
scheduleSyncDelayedTaskin interfaceBukkitScheduler
-
scheduleSyncDelayedTask
public int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) - Specified by:
scheduleSyncDelayedTaskin interfaceBukkitScheduler
-
scheduleSyncDelayedTask
@Deprecated public int scheduleSyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) Deprecated.- Specified by:
scheduleSyncDelayedTaskin interfaceBukkitScheduler
-
scheduleSyncRepeatingTask
public int scheduleSyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) - Specified by:
scheduleSyncRepeatingTaskin interfaceBukkitScheduler
-
scheduleSyncRepeatingTask
@Deprecated public int scheduleSyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) Deprecated.- Specified by:
scheduleSyncRepeatingTaskin interfaceBukkitScheduler
-
scheduleAsyncDelayedTask
@Deprecated public int scheduleAsyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) Deprecated.- Specified by:
scheduleAsyncDelayedTaskin interfaceBukkitScheduler
-
scheduleAsyncDelayedTask
@Deprecated public int scheduleAsyncDelayedTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) Deprecated.- Specified by:
scheduleAsyncDelayedTaskin interfaceBukkitScheduler
-
scheduleAsyncRepeatingTask
@Deprecated public int scheduleAsyncRepeatingTask(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) Deprecated.- Specified by:
scheduleAsyncRepeatingTaskin interfaceBukkitScheduler
-
callSyncMethod
@NotNull public <T> @NotNull Future<T> callSyncMethod(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Callable<T> task) - Specified by:
callSyncMethodin interfaceBukkitScheduler
-
cancelTask
public void cancelTask(int taskId) - Specified by:
cancelTaskin interfaceBukkitScheduler
-
cancelTasks
- Specified by:
cancelTasksin interfaceBukkitScheduler
-
isCurrentlyRunning
public boolean isCurrentlyRunning(int taskId) - Specified by:
isCurrentlyRunningin interfaceBukkitScheduler
-
isQueued
public boolean isQueued(int taskId) - Specified by:
isQueuedin interfaceBukkitScheduler
-
getActiveWorkers
- Specified by:
getActiveWorkersin interfaceBukkitScheduler
-
getPendingTasks
- Specified by:
getPendingTasksin interfaceBukkitScheduler
-
runTaskAsynchronously
@NotNull public @NotNull BukkitTask runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task) - Specified by:
runTaskAsynchronouslyin interfaceBukkitScheduler
-
runTaskAsynchronously
@NotNull public @NotNull BukkitTask runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task) - Specified by:
runTaskAsynchronouslyin interfaceBukkitScheduler
-
runTaskLater
@NotNull public @NotNull BukkitTask runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) - Specified by:
runTaskLaterin interfaceBukkitScheduler
-
runTaskLaterAsynchronously
@NotNull public @NotNull BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay) - Specified by:
runTaskLaterAsynchronouslyin interfaceBukkitScheduler
-
runTaskLaterAsynchronously
@NotNull public @NotNull BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay) - Specified by:
runTaskLaterAsynchronouslyin interfaceBukkitScheduler
-
runTaskTimerAsynchronously
@NotNull public @NotNull BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period) - Specified by:
runTaskTimerAsynchronouslyin interfaceBukkitScheduler
-
runTaskTimerAsynchronously
@NotNull public @NotNull BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull BukkitRunnable task, long delay, long period) - Specified by:
runTaskTimerAsynchronouslyin interfaceBukkitScheduler
-
runTask
- Specified by:
runTaskin interfaceBukkitScheduler
-
runTaskAsynchronously
public void runTaskAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task) - Specified by:
runTaskAsynchronouslyin interfaceBukkitScheduler
-
runTaskLater
public void runTaskLater(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay) - Specified by:
runTaskLaterin interfaceBukkitScheduler
-
runTaskLaterAsynchronously
public void runTaskLaterAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay) - Specified by:
runTaskLaterAsynchronouslyin interfaceBukkitScheduler
-
runTaskTimer
public void runTaskTimer(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay, long period) - Specified by:
runTaskTimerin interfaceBukkitScheduler
-
runTaskTimerAsynchronously
public void runTaskTimerAsynchronously(@NotNull @NotNull Plugin plugin, @NotNull @NotNull Consumer<BukkitTask> task, long delay, long period) - Specified by:
runTaskTimerAsynchronouslyin interfaceBukkitScheduler
-
getMainThreadExecutor
- Specified by:
getMainThreadExecutorin interfaceBukkitScheduler
-
getActiveRunningCount
protected int getActiveRunningCount()
-