Package net.glowstone.scheduler
Class GlowScheduler
java.lang.Object
net.glowstone.scheduler.GlowScheduler
- All Implemented Interfaces:
org.bukkit.scheduler.BukkitScheduler
A scheduler for managing server ticks, Bukkit tasks, and other synchronization.
-
Constructor Summary
ConstructorsConstructorDescriptionGlowScheduler(GlowServer server, WorldScheduler worlds) Creates a new task scheduler.GlowScheduler(org.bukkit.Server server, WorldScheduler worlds, SessionRegistry sessionRegistry) Creates a new task scheduler. -
Method Summary
Modifier and TypeMethodDescription<T> Future<T>callSyncMethod(org.bukkit.plugin.Plugin plugin, Callable<T> task) voidvoidcancelTask(int taskId) voidcancelTasks(org.bukkit.plugin.Plugin plugin) List<org.bukkit.scheduler.BukkitWorker>Returns active async tasks.@NotNull ExecutorgetMainThreadExecutor(@NotNull org.bukkit.plugin.Plugin plugin) List<org.bukkit.scheduler.BukkitTask>Returns tasks that still have at least one run remaining.booleanisCurrentlyRunning(int taskId) booleanChecks if the currentThreadis the server's primary thread.booleanisQueued(int taskId) voidrunTask(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task) org.bukkit.scheduler.BukkitTaskorg.bukkit.scheduler.BukkitTaskrunTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.voidrunTaskAsynchronously(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task) org.bukkit.scheduler.BukkitTaskrunTaskAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task) org.bukkit.scheduler.BukkitTaskrunTaskAsynchronously(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.voidrunTaskLater(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay) org.bukkit.scheduler.BukkitTaskrunTaskLater(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) org.bukkit.scheduler.BukkitTaskrunTaskLater(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.voidrunTaskLaterAsynchronously(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay) org.bukkit.scheduler.BukkitTaskrunTaskLaterAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) org.bukkit.scheduler.BukkitTaskrunTaskLaterAsynchronously(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.voidrunTaskTimer(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period) org.bukkit.scheduler.BukkitTaskrunTaskTimer(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) org.bukkit.scheduler.BukkitTaskrunTaskTimer(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.voidrunTaskTimerAsynchronously(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period) org.bukkit.scheduler.BukkitTaskrunTaskTimerAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) org.bukkit.scheduler.BukkitTaskrunTaskTimerAsynchronously(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.intscheduleAsyncDelayedTask(org.bukkit.plugin.Plugin plugin, Runnable task) Deprecated.intscheduleAsyncDelayedTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) Deprecated.intscheduleAsyncRepeatingTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) Deprecated.voidSchedules the given task for the start of the next tick.intscheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, Runnable task) intscheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) intscheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.intscheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.intscheduleSyncRepeatingTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) intscheduleSyncRepeatingTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.voidstart()Starts running ticks.voidstop()Stops the scheduler and all tasks.<T> TsyncIfNeeded(Callable<T> task) Runs a task on the primary thread, and blocks waiting for it to finish.
-
Constructor Details
-
GlowScheduler
Creates a new task scheduler.- Parameters:
server- The server that will use this scheduler.worlds- TheWorldSchedulerthis scheduler will use for ticking the server's worlds.
-
GlowScheduler
public GlowScheduler(org.bukkit.Server server, WorldScheduler worlds, SessionRegistry sessionRegistry) Creates a new task scheduler.- Parameters:
server- The server that will use this scheduler.worlds- TheWorldSchedulerthis scheduler will use for ticking the server's worlds.sessionRegistry- TheSessionRegistrythis scheduler will use to tick players
-
-
Method Details
-
start
public void start()Starts running ticks. -
stop
public void stop()Stops the scheduler and all tasks. -
isPrimaryThread
public boolean isPrimaryThread()Checks if the currentThreadis the server's primary thread.- Returns:
- If the current
Threadis the server's primary thread.
-
scheduleInTickExecution
Schedules the given task for the start of the next tick.- Parameters:
run- the task to run
-
scheduleSyncDelayedTask
- Specified by:
scheduleSyncDelayedTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncDelayedTask
- Specified by:
scheduleSyncDelayedTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncDelayedTask
@Deprecated public int scheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.- Specified by:
scheduleSyncDelayedTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncDelayedTask
@Deprecated public int scheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.- Specified by:
scheduleSyncDelayedTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncRepeatingTask
public int scheduleSyncRepeatingTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) - Specified by:
scheduleSyncRepeatingTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncRepeatingTask
@Deprecated public int scheduleSyncRepeatingTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.- Specified by:
scheduleSyncRepeatingTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleAsyncDelayedTask
@Deprecated public int scheduleAsyncDelayedTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) Deprecated.- Specified by:
scheduleAsyncDelayedTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleAsyncDelayedTask
Deprecated.- Specified by:
scheduleAsyncDelayedTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleAsyncRepeatingTask
@Deprecated public int scheduleAsyncRepeatingTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) Deprecated.- Specified by:
scheduleAsyncRepeatingTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
runTask
public org.bukkit.scheduler.BukkitTask runTask(org.bukkit.plugin.Plugin plugin, Runnable task) throws IllegalArgumentException - Specified by:
runTaskin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTask
public void runTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task) throws IllegalArgumentException - Specified by:
runTaskin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTask
@Deprecated public org.bukkit.scheduler.BukkitTask runTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) throws IllegalArgumentException Deprecated.- Specified by:
runTaskin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskAsynchronously
public org.bukkit.scheduler.BukkitTask runTaskAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task) throws IllegalArgumentException - Specified by:
runTaskAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskAsynchronously
public void runTaskAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task) throws IllegalArgumentException - Specified by:
runTaskAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskAsynchronously
@Deprecated public org.bukkit.scheduler.BukkitTask runTaskAsynchronously(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) throws IllegalArgumentException Deprecated.- Specified by:
runTaskAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskLater
public org.bukkit.scheduler.BukkitTask runTaskLater(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) throws IllegalArgumentException - Specified by:
runTaskLaterin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskLater
public void runTaskLater(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay) throws IllegalArgumentException - Specified by:
runTaskLaterin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskLater
@Deprecated public org.bukkit.scheduler.BukkitTask runTaskLater(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) throws IllegalArgumentException Deprecated.- Specified by:
runTaskLaterin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskLaterAsynchronously
public org.bukkit.scheduler.BukkitTask runTaskLaterAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) throws IllegalArgumentException - Specified by:
runTaskLaterAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskLaterAsynchronously
public void runTaskLaterAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay) throws IllegalArgumentException - Specified by:
runTaskLaterAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskLaterAsynchronously
@Deprecated public org.bukkit.scheduler.BukkitTask runTaskLaterAsynchronously(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) throws IllegalArgumentException Deprecated.- Specified by:
runTaskLaterAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskTimer
public org.bukkit.scheduler.BukkitTask runTaskTimer(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) throws IllegalArgumentException - Specified by:
runTaskTimerin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskTimer
public void runTaskTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period) throws IllegalArgumentException - Specified by:
runTaskTimerin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskTimer
@Deprecated public org.bukkit.scheduler.BukkitTask runTaskTimer(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) throws IllegalArgumentException Deprecated.- Specified by:
runTaskTimerin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskTimerAsynchronously
public org.bukkit.scheduler.BukkitTask runTaskTimerAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) throws IllegalArgumentException - Specified by:
runTaskTimerAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskTimerAsynchronously
public void runTaskTimerAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period) throws IllegalArgumentException - Specified by:
runTaskTimerAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
runTaskTimerAsynchronously
@Deprecated public org.bukkit.scheduler.BukkitTask runTaskTimerAsynchronously(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) throws IllegalArgumentException Deprecated.- Specified by:
runTaskTimerAsynchronouslyin interfaceorg.bukkit.scheduler.BukkitScheduler- Throws:
IllegalArgumentException
-
getMainThreadExecutor
@NotNull public @NotNull Executor getMainThreadExecutor(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) - Specified by:
getMainThreadExecutorin interfaceorg.bukkit.scheduler.BukkitScheduler
-
callSyncMethod
- Specified by:
callSyncMethodin interfaceorg.bukkit.scheduler.BukkitScheduler
-
syncIfNeeded
Runs a task on the primary thread, and blocks waiting for it to finish.- Type Parameters:
T- the task's return type- Parameters:
task- the task to run- Returns:
- the task result
- Throws:
Exception- if thrown by the task
-
cancelTask
public void cancelTask(int taskId) - Specified by:
cancelTaskin interfaceorg.bukkit.scheduler.BukkitScheduler
-
cancelTasks
public void cancelTasks(org.bukkit.plugin.Plugin plugin) - Specified by:
cancelTasksin interfaceorg.bukkit.scheduler.BukkitScheduler
-
cancelAllTasks
public void cancelAllTasks() -
isCurrentlyRunning
public boolean isCurrentlyRunning(int taskId) - Specified by:
isCurrentlyRunningin interfaceorg.bukkit.scheduler.BukkitScheduler
-
isQueued
public boolean isQueued(int taskId) - Specified by:
isQueuedin interfaceorg.bukkit.scheduler.BukkitScheduler
-
getActiveWorkers
Returns active async tasks.- Specified by:
getActiveWorkersin interfaceorg.bukkit.scheduler.BukkitScheduler- Returns:
- active async tasks
-
getPendingTasks
Returns tasks that still have at least one run remaining.- Specified by:
getPendingTasksin interfaceorg.bukkit.scheduler.BukkitScheduler- Returns:
- the tasks to be run
-