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
ConstructorDescriptionGlowScheduler
(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) void
void
cancelTask
(int taskId) void
cancelTasks
(org.bukkit.plugin.Plugin plugin) List<org.bukkit.scheduler.BukkitWorker>
Returns active async tasks.@NotNull Executor
getMainThreadExecutor
(@NotNull org.bukkit.plugin.Plugin plugin) List<org.bukkit.scheduler.BukkitTask>
Returns tasks that still have at least one run remaining.boolean
isCurrentlyRunning
(int taskId) boolean
Checks if the currentThread
is the server's primary thread.boolean
isQueued
(int taskId) void
runTask
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task) org.bukkit.scheduler.BukkitTask
org.bukkit.scheduler.BukkitTask
runTask
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.void
runTaskAsynchronously
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task) org.bukkit.scheduler.BukkitTask
runTaskAsynchronously
(org.bukkit.plugin.Plugin plugin, Runnable task) org.bukkit.scheduler.BukkitTask
runTaskAsynchronously
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.void
runTaskLater
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay) org.bukkit.scheduler.BukkitTask
runTaskLater
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) org.bukkit.scheduler.BukkitTask
runTaskLater
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.void
runTaskLaterAsynchronously
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay) org.bukkit.scheduler.BukkitTask
runTaskLaterAsynchronously
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) org.bukkit.scheduler.BukkitTask
runTaskLaterAsynchronously
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.void
runTaskTimer
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period) org.bukkit.scheduler.BukkitTask
runTaskTimer
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) org.bukkit.scheduler.BukkitTask
runTaskTimer
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.void
runTaskTimerAsynchronously
(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<org.bukkit.scheduler.BukkitTask> task, long delay, long period) org.bukkit.scheduler.BukkitTask
runTaskTimerAsynchronously
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) org.bukkit.scheduler.BukkitTask
runTaskTimerAsynchronously
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.int
scheduleAsyncDelayedTask
(org.bukkit.plugin.Plugin plugin, Runnable task) Deprecated.int
scheduleAsyncDelayedTask
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) Deprecated.int
scheduleAsyncRepeatingTask
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) Deprecated.void
Schedules the given task for the start of the next tick.int
scheduleSyncDelayedTask
(org.bukkit.plugin.Plugin plugin, Runnable task) int
scheduleSyncDelayedTask
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) int
scheduleSyncDelayedTask
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.int
scheduleSyncDelayedTask
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.int
scheduleSyncRepeatingTask
(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) int
scheduleSyncRepeatingTask
(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay, long period) Deprecated.void
start()
Starts running ticks.void
stop()
Stops the scheduler and all tasks.<T> T
syncIfNeeded
(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
- TheWorldScheduler
this 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
- TheWorldScheduler
this scheduler will use for ticking the server's worlds.sessionRegistry
- TheSessionRegistry
this 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 currentThread
is the server's primary thread.- Returns:
- If the current
Thread
is 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:
scheduleSyncDelayedTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncDelayedTask
- Specified by:
scheduleSyncDelayedTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncDelayedTask
@Deprecated public int scheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task) Deprecated.- Specified by:
scheduleSyncDelayedTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncDelayedTask
@Deprecated public int scheduleSyncDelayedTask(org.bukkit.plugin.Plugin plugin, org.bukkit.scheduler.BukkitRunnable task, long delay) Deprecated.- Specified by:
scheduleSyncDelayedTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleSyncRepeatingTask
public int scheduleSyncRepeatingTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) - Specified by:
scheduleSyncRepeatingTask
in 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:
scheduleSyncRepeatingTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleAsyncDelayedTask
@Deprecated public int scheduleAsyncDelayedTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay) Deprecated.- Specified by:
scheduleAsyncDelayedTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleAsyncDelayedTask
Deprecated.- Specified by:
scheduleAsyncDelayedTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
scheduleAsyncRepeatingTask
@Deprecated public int scheduleAsyncRepeatingTask(org.bukkit.plugin.Plugin plugin, Runnable task, long delay, long period) Deprecated.- Specified by:
scheduleAsyncRepeatingTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
runTask
public org.bukkit.scheduler.BukkitTask runTask(org.bukkit.plugin.Plugin plugin, Runnable task) throws IllegalArgumentException - Specified by:
runTask
in 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:
runTask
in 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:
runTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
- Throws:
IllegalArgumentException
-
runTaskAsynchronously
public org.bukkit.scheduler.BukkitTask runTaskAsynchronously(org.bukkit.plugin.Plugin plugin, Runnable task) throws IllegalArgumentException - Specified by:
runTaskAsynchronously
in 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:
runTaskAsynchronously
in 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:
runTaskAsynchronously
in 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:
runTaskLater
in 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:
runTaskLater
in 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:
runTaskLater
in 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:
runTaskLaterAsynchronously
in 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:
runTaskLaterAsynchronously
in 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:
runTaskLaterAsynchronously
in 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:
runTaskTimer
in 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:
runTaskTimer
in 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:
runTaskTimer
in 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:
runTaskTimerAsynchronously
in 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:
runTaskTimerAsynchronously
in 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:
runTaskTimerAsynchronously
in interfaceorg.bukkit.scheduler.BukkitScheduler
- Throws:
IllegalArgumentException
-
getMainThreadExecutor
@NotNull public @NotNull Executor getMainThreadExecutor(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) - Specified by:
getMainThreadExecutor
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
callSyncMethod
- Specified by:
callSyncMethod
in 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:
cancelTask
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
cancelTasks
public void cancelTasks(org.bukkit.plugin.Plugin plugin) - Specified by:
cancelTasks
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
cancelAllTasks
public void cancelAllTasks() -
isCurrentlyRunning
public boolean isCurrentlyRunning(int taskId) - Specified by:
isCurrentlyRunning
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
isQueued
public boolean isQueued(int taskId) - Specified by:
isQueued
in interfaceorg.bukkit.scheduler.BukkitScheduler
-
getActiveWorkers
Returns active async tasks.- Specified by:
getActiveWorkers
in interfaceorg.bukkit.scheduler.BukkitScheduler
- Returns:
- active async tasks
-
getPendingTasks
Returns tasks that still have at least one run remaining.- Specified by:
getPendingTasks
in interfaceorg.bukkit.scheduler.BukkitScheduler
- Returns:
- the tasks to be run
-