Package dev.cwhead.GravesX.manager
Class SchedulerManager
java.lang.Object
dev.cwhead.GravesX.manager.SchedulerManager
Fire-and-forget scheduler wrapper around
GlobalScheduler.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classReturnable scheduler API for when a task handle is needed.static final classManaged task wrapper that retains the owningSchedulerManager. -
Constructor Summary
ConstructorsConstructorDescriptionSchedulerManager(@NotNull org.bukkit.plugin.Plugin plugin) Creates a scheduler manager for the given plugin. -
Method Summary
Modifier and TypeMethodDescription<T> @NotNull Future<T> callSyncMethod(@NotNull Callable<T> task) Calls a task on the global/main thread and returns aFuture.voidcancel(int taskId) Cancels a task by id.voidcancel(@Nullable me.croabeast.scheduler.GlobalTask task) Cancels a task handle if present.voidCancels all tasks scheduled by the owning plugin.voidcancelAll(@NotNull org.bukkit.plugin.Plugin plugin) Cancels all tasks scheduled by the specified plugin.voidExecutes a task on the global/main thread.voidExecutes a task on the region that owns the provided location.voidExecutes a task on the region that owns the provided entity.@NotNull org.bukkit.plugin.PluginReturns the owningPlugin.@NotNull me.croabeast.scheduler.GlobalSchedulerReturns the backingGlobalScheduler.booleanisEntityThread(@NotNull org.bukkit.entity.Entity entity) Checks if the current thread owns the specified entity's region.booleanChecks if the current thread is the global scheduler thread for this runtime.booleanisRegionThread(@NotNull org.bukkit.Location location) Checks if the current thread owns the region containing the specified location.booleanChecks if the current thread is the tick/primary thread.@NotNull SchedulerManager.ReturnableReturns the handle-returning API.voidSchedules a task for the next tick (global/main).voidSchedules a task on the region that owns the provided location.voidSchedules a task on the region that owns the provided entity.voidDeprecated.voidrunTaskAsynchronously(@NotNull Runnable runnable) Schedules an async task immediately.voidrunTaskAsynchronously(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable runnable) Deprecated.voidrunTaskLater(@NotNull Runnable runnable, long delay) Schedules a delayed task (global/main).voidrunTaskLater(@NotNull org.bukkit.Location location, @NotNull Runnable runnable, long delay) Schedules a delayed task on the region that owns the provided location.voidrunTaskLater(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable runnable, long delay) Schedules a delayed task on the region that owns the provided entity.voidrunTaskLater(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable runnable, long delay) Deprecated.voidrunTaskLaterAsynchronously(@NotNull Runnable runnable, long delay) Schedules an async task after a delay.voidrunTaskLaterAsynchronously(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable runnable, long delay) Deprecated.voidrunTaskTimer(@NotNull Runnable runnable, long delay, long period) Schedules a repeating task (global/main).voidrunTaskTimer(@NotNull org.bukkit.Location location, @NotNull Runnable runnable, long delay, long period) Schedules a repeating task on the region that owns the provided location.voidrunTaskTimer(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable runnable, long delay, long period) Schedules a repeating task on the region that owns the provided entity.voidrunTaskTimer(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable runnable, long delay, long period) Deprecated.voidrunTaskTimerAsynchronously(@NotNull Runnable runnable, long delay, long period) Schedules a repeating async task.voidrunTaskTimerAsynchronously(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable runnable, long delay, long period) Deprecated.voidscheduleSyncDelayedTask(@NotNull Runnable runnable) Deprecated.UserunTask(Runnable).voidscheduleSyncDelayedTask(@NotNull Runnable runnable, long delay) Deprecated.voidscheduleSyncRepeatingTask(@NotNull Runnable runnable, long delay, long period) Deprecated.
-
Constructor Details
-
SchedulerManager
public SchedulerManager(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) Creates a scheduler manager for the given plugin.- Parameters:
plugin- owning plugin
-
-
Method Details
-
getScheduler
@NotNull public @NotNull me.croabeast.scheduler.GlobalScheduler getScheduler()Returns the backingGlobalScheduler.- Returns:
- scheduler instance
-
getPlugin
@NotNull public @NotNull org.bukkit.plugin.Plugin getPlugin()Returns the owningPlugin.- Returns:
- plugin instance
-
returnable
Returns the handle-returning API.- Returns:
- returnable helper
-
isGlobalThread
public boolean isGlobalThread()Checks if the current thread is the global scheduler thread for this runtime.- Returns:
- true if on global thread, otherwise false
-
isTickThread
public boolean isTickThread()Checks if the current thread is the tick/primary thread.- Returns:
- true if on tick thread, otherwise false
-
isEntityThread
public boolean isEntityThread(@NotNull @NotNull org.bukkit.entity.Entity entity) Checks if the current thread owns the specified entity's region.- Parameters:
entity- entity to check- Returns:
- true if the current thread owns the entity region, otherwise false
-
isRegionThread
public boolean isRegionThread(@NotNull @NotNull org.bukkit.Location location) Checks if the current thread owns the region containing the specified location.- Parameters:
location- location to check (world must be non-null)- Returns:
- true if the current thread owns the region, otherwise false
-
callSyncMethod
Calls a task on the global/main thread and returns aFuture.- Type Parameters:
T- result type- Parameters:
task- callable to execute- Returns:
- future result
-
runTask
Schedules a task for the next tick (global/main).- Parameters:
runnable- task to run
-
runTask
@Deprecated public void runTask(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable) Deprecated.UserunTask(Runnable).Schedules a task for the next tick (legacy signature).- Parameters:
plugin- plugin (legacy parameter)runnable- task to run
-
runTaskLater
Schedules a delayed task (global/main).- Parameters:
runnable- task to rundelay- delay in ticks
-
runTaskLater
@Deprecated public void runTaskLater(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay) Deprecated.Schedules a delayed task (legacy signature).- Parameters:
plugin- plugin (legacy parameter)runnable- task to rundelay- delay in ticks
-
runTaskTimer
Schedules a repeating task (global/main).- Parameters:
runnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
runTaskTimer
@Deprecated public void runTaskTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay, long period) Deprecated.Schedules a repeating task (legacy signature).- Parameters:
plugin- plugin (legacy parameter)runnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
runTask
public void runTask(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable) Schedules a task on the region that owns the provided location.- Parameters:
location- location contextrunnable- task to run
-
runTaskLater
public void runTaskLater(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable, long delay) Schedules a delayed task on the region that owns the provided location.- Parameters:
location- location contextrunnable- task to rundelay- delay in ticks
-
runTaskTimer
public void runTaskTimer(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable, long delay, long period) Schedules a repeating task on the region that owns the provided location.- Parameters:
location- location contextrunnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
runTask
public void runTask(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable) Schedules a task on the region that owns the provided entity.- Parameters:
entity- entity contextrunnable- task to run
-
runTaskLater
public void runTaskLater(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable, long delay) Schedules a delayed task on the region that owns the provided entity.- Parameters:
entity- entity contextrunnable- task to rundelay- delay in ticks
-
runTaskTimer
public void runTaskTimer(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable, long delay, long period) Schedules a repeating task on the region that owns the provided entity.- Parameters:
entity- entity contextrunnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
runTaskAsynchronously
Schedules an async task immediately.- Parameters:
runnable- task to run
-
runTaskAsynchronously
@Deprecated public void runTaskAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable) Deprecated.Schedules an async task immediately (legacy signature).- Parameters:
plugin- plugin (legacy parameter)runnable- task to run
-
runTaskLaterAsynchronously
Schedules an async task after a delay.- Parameters:
runnable- task to rundelay- delay in ticks
-
runTaskLaterAsynchronously
@Deprecated public void runTaskLaterAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay) Deprecated.Schedules an async task after a delay (legacy signature).- Parameters:
plugin- plugin (legacy parameter)runnable- task to rundelay- delay in ticks
-
runTaskTimerAsynchronously
public void runTaskTimerAsynchronously(@NotNull @NotNull Runnable runnable, long delay, long period) Schedules a repeating async task.- Parameters:
runnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
runTaskTimerAsynchronously
@Deprecated public void runTaskTimerAsynchronously(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable runnable, long delay, long period) Deprecated.Schedules a repeating async task (legacy signature).- Parameters:
plugin- plugin (legacy parameter)runnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
scheduleSyncDelayedTask
Deprecated.UserunTask(Runnable).Legacy alias forrunTask(Runnable).- Parameters:
runnable- task to run
-
scheduleSyncDelayedTask
Deprecated.Legacy alias forrunTaskLater(Runnable, long).- Parameters:
runnable- task to rundelay- delay in ticks
-
scheduleSyncRepeatingTask
@Deprecated public void scheduleSyncRepeatingTask(@NotNull @NotNull Runnable runnable, long delay, long period) Deprecated.Legacy alias forrunTaskTimer(Runnable, long, long).- Parameters:
runnable- task to rundelay- initial delay in ticksperiod- period in ticks
-
execute
Executes a task on the global/main thread.- Parameters:
runnable- task to run
-
execute
public void execute(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable runnable) Executes a task on the region that owns the provided location.- Parameters:
location- location contextrunnable- task to run
-
execute
public void execute(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable runnable) Executes a task on the region that owns the provided entity.- Parameters:
entity- entity contextrunnable- task to run
-
cancel
public void cancel(@Nullable @Nullable me.croabeast.scheduler.GlobalTask task) Cancels a task handle if present.- Parameters:
task- task handle (nullable)
-
cancel
public void cancel(int taskId) Cancels a task by id.- Parameters:
taskId- task id
-
cancelAll
public void cancelAll()Cancels all tasks scheduled by the owning plugin. -
cancelAll
public void cancelAll(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) Cancels all tasks scheduled by the specified plugin.- Parameters:
plugin- target plugin
-
runTask(Runnable).