Class BukkitSchedulerMock

java.lang.Object
be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock
All Implemented Interfaces:
org.bukkit.scheduler.BukkitScheduler

public class BukkitSchedulerMock extends Object implements org.bukkit.scheduler.BukkitScheduler
  • 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

      @NotNull public @NotNull Future<?> executeAsyncEvent(org.bukkit.event.Event event)
    • executeAsyncEvent

      @NotNull public <T extends org.bukkit.event.Event> @NotNull Future<?> executeAsyncEvent(T event, Consumer<T> func)
    • 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 org.bukkit.scheduler.BukkitTask runTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task)
      Specified by:
      runTask in interface org.bukkit.scheduler.BukkitScheduler
    • runTask

      @Deprecated @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task)
      Deprecated.
      Specified by:
      runTask in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskLater

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskLater(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay)
      Specified by:
      runTaskLater in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskTimer

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period)
      Specified by:
      runTaskTimer in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskTimer

      @Deprecated @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task, long delay, long period)
      Deprecated.
      Specified by:
      runTaskTimer in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleSyncDelayedTask

      public int scheduleSyncDelayedTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay)
      Specified by:
      scheduleSyncDelayedTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleSyncDelayedTask

      @Deprecated public int scheduleSyncDelayedTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task, long delay)
      Deprecated.
      Specified by:
      scheduleSyncDelayedTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleSyncDelayedTask

      public int scheduleSyncDelayedTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task)
      Specified by:
      scheduleSyncDelayedTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleSyncDelayedTask

      @Deprecated public int scheduleSyncDelayedTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task)
      Deprecated.
      Specified by:
      scheduleSyncDelayedTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleSyncRepeatingTask

      public int scheduleSyncRepeatingTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period)
      Specified by:
      scheduleSyncRepeatingTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleSyncRepeatingTask

      @Deprecated public int scheduleSyncRepeatingTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task, long delay, long period)
      Deprecated.
      Specified by:
      scheduleSyncRepeatingTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleAsyncDelayedTask

      @Deprecated public int scheduleAsyncDelayedTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay)
      Deprecated.
      Specified by:
      scheduleAsyncDelayedTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleAsyncDelayedTask

      @Deprecated public int scheduleAsyncDelayedTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task)
      Deprecated.
      Specified by:
      scheduleAsyncDelayedTask in interface org.bukkit.scheduler.BukkitScheduler
    • scheduleAsyncRepeatingTask

      @Deprecated public int scheduleAsyncRepeatingTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period)
      Deprecated.
      Specified by:
      scheduleAsyncRepeatingTask in interface org.bukkit.scheduler.BukkitScheduler
    • callSyncMethod

      @NotNull public <T> @NotNull Future<T> callSyncMethod(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Callable<T> task)
      Specified by:
      callSyncMethod in interface org.bukkit.scheduler.BukkitScheduler
    • cancelTask

      public void cancelTask(int taskId)
      Specified by:
      cancelTask in interface org.bukkit.scheduler.BukkitScheduler
    • cancelTasks

      public void cancelTasks(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Specified by:
      cancelTasks in interface org.bukkit.scheduler.BukkitScheduler
    • isCurrentlyRunning

      public boolean isCurrentlyRunning(int taskId)
      Specified by:
      isCurrentlyRunning in interface org.bukkit.scheduler.BukkitScheduler
    • isQueued

      public boolean isQueued(int taskId)
      Specified by:
      isQueued in interface org.bukkit.scheduler.BukkitScheduler
    • getActiveWorkers

      @NotNull public @NotNull List<org.bukkit.scheduler.BukkitWorker> getActiveWorkers()
      Specified by:
      getActiveWorkers in interface org.bukkit.scheduler.BukkitScheduler
    • getPendingTasks

      @NotNull public @NotNull List<org.bukkit.scheduler.BukkitTask> getPendingTasks()
      Specified by:
      getPendingTasks in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskAsynchronously

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task)
      Specified by:
      runTaskAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskAsynchronously

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task)
      Specified by:
      runTaskAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskLater

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskLater(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task, long delay)
      Specified by:
      runTaskLater in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskLaterAsynchronously

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay)
      Specified by:
      runTaskLaterAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskLaterAsynchronously

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskLaterAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task, long delay)
      Specified by:
      runTaskLaterAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskTimerAsynchronously

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delay, long period)
      Specified by:
      runTaskTimerAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskTimerAsynchronously

      @NotNull public @NotNull org.bukkit.scheduler.BukkitTask runTaskTimerAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.scheduler.BukkitRunnable task, long delay, long period)
      Specified by:
      runTaskTimerAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTask

      public void runTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task)
      Specified by:
      runTask in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskAsynchronously

      public void runTaskAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task)
      Specified by:
      runTaskAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskLater

      public void runTaskLater(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay)
      Specified by:
      runTaskLater in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskLaterAsynchronously

      public void runTaskLaterAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay)
      Specified by:
      runTaskLaterAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskTimer

      public void runTaskTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period)
      Specified by:
      runTaskTimer in interface org.bukkit.scheduler.BukkitScheduler
    • runTaskTimerAsynchronously

      public void runTaskTimerAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period)
      Specified by:
      runTaskTimerAsynchronously in interface org.bukkit.scheduler.BukkitScheduler
    • getMainThreadExecutor

      @NotNull public @NotNull Executor getMainThreadExecutor(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      Specified by:
      getMainThreadExecutor in interface org.bukkit.scheduler.BukkitScheduler
    • getActiveRunningCount

      protected int getActiveRunningCount()