Class BukkitFoliaScheduler
java.lang.Object
io.artificial.enchantments.internal.BukkitFoliaScheduler
- All Implemented Interfaces:
FoliaScheduler
FoliaLib-backed implementation of
FoliaScheduler.
On Folia this delegates to region/entity/global schedulers through FoliaLib. On Paper/Purpur it resolves to the normal main-thread scheduler.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.artificial.enchantments.internal.FoliaScheduler
FoliaScheduler.ScheduledTask -
Constructor Summary
ConstructorsConstructorDescriptionBukkitFoliaScheduler(@NotNull org.bukkit.plugin.Plugin plugin) Creates a new Bukkit folia scheduler. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the current thread is the primary server thread.voidrunAtEntity(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task) Executes a task on the entity's scheduler.voidrunAtLocation(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.Location location, @NotNull Runnable task) Executes a task on the region thread for the given location.voidExecutes a task on the global region thread.@NotNull FoliaScheduler.ScheduledTaskrunGlobalDelayed(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable task, long delayTicks) Schedules a delayed task on the global region thread.@NotNull FoliaScheduler.ScheduledTaskrunGlobalTimer(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<FoliaScheduler.ScheduledTask> task, long delayTicks, long periodTicks) Schedules a repeating task on the global region thread.
-
Constructor Details
-
BukkitFoliaScheduler
public BukkitFoliaScheduler(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) Creates a new Bukkit folia scheduler.- Parameters:
plugin- the owning plugin
-
-
Method Details
-
runGlobal
public void runGlobal(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task) Executes a task on the global region thread.- Specified by:
runGlobalin interfaceFoliaScheduler- Parameters:
plugin- the plugin scheduling the tasktask- the task to execute
-
runAtLocation
public void runAtLocation(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Runnable task) Executes a task on the region thread for the given location.- Specified by:
runAtLocationin interfaceFoliaScheduler- Parameters:
plugin- the plugin scheduling the tasklocation- the location determining which region threadtask- the task to execute
-
runAtEntity
public void runAtEntity(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task) Executes a task on the entity's scheduler.- Specified by:
runAtEntityin interfaceFoliaScheduler- Parameters:
plugin- the plugin scheduling the taskentity- the entity to schedule the task fortask- the task to execute
-
runGlobalDelayed
@NotNull public @NotNull FoliaScheduler.ScheduledTask runGlobalDelayed(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable task, long delayTicks) Schedules a delayed task on the global region thread.- Specified by:
runGlobalDelayedin interfaceFoliaScheduler- Parameters:
plugin- the plugin scheduling the tasktask- the task to executedelayTicks- the delay in ticks- Returns:
- a task handle that can be used to cancel the task
-
runGlobalTimer
@NotNull public @NotNull FoliaScheduler.ScheduledTask runGlobalTimer(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<FoliaScheduler.ScheduledTask> task, long delayTicks, long periodTicks) Schedules a repeating task on the global region thread.- Specified by:
runGlobalTimerin interfaceFoliaScheduler- Parameters:
plugin- the plugin scheduling the tasktask- the task to executedelayTicks- the initial delay in ticksperiodTicks- the period between executions in ticks- Returns:
- a task handle that can be used to cancel the task
-
isPrimaryThread
public boolean isPrimaryThread()Returns true if the current thread is the primary server thread.- Specified by:
isPrimaryThreadin interfaceFoliaScheduler- Returns:
- true if on main thread
-