Interface Scheduler
@NonExtendable
public interface Scheduler
Runs code on the thread that owns what it touches (D35), on Paper and Folia alike: on Paper every
thread below is the main thread, on Folia it is the global region, the region owning a location, or
the region owning an entity. Get one with
MachineEngine.scheduler(plugin): its tasks belong to
that plugin and stop when it is disabled.
Delays and periods are in ticks; anything below 1 counts as 1. Once the server is stopping,
nothing is scheduled (such a task would never run): run does nothing, runLater and
runTimer return a cancelled task, and the entity variants return false or null.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisFolia()booleanisOwnedByCurrentThread(@NotNull org.bukkit.Location location) booleanisOwnedByCurrentThread(@NotNull org.bukkit.World world, int chunkX, int chunkZ) booleanisOwnedByCurrentThread(@NotNull org.bukkit.entity.Entity entity) voidRunstaskon the next tick.voidRunstaskon the next tick of the region owninglocation.voidRunstaskon the next tick of the region owning the chunk.booleanRunstaskon the next tick of the region owningentity.voidRunstaskon a pooled thread.@NotNull Task@NotNull Task@NotNull TaskrunLater(@NotNull org.bukkit.World world, int chunkX, int chunkZ, @NotNull Runnable task, long delay) @Nullable TaskrunLater(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired, long delay) Likerun(Entity, Runnable, Runnable), afterdelay.@NotNull Task@NotNull Task@Nullable TaskrunTimer(@NotNull org.bukkit.entity.Entity entity, @NotNull Runnable task, @Nullable Runnable retired, long delay, long period) Runstaskeveryperioduntil cancelled or the entity is removed; thenretiredruns.
-
Method Details
-
isFolia
boolean isFolia()- Returns:
- whether the server is Folia (regions on several threads)
-
run
Runstaskon the next tick. -
runLater
-
runTimer
-
run
Runstaskon the next tick of the region owninglocation. -
run
void run(@NotNull @NotNull org.bukkit.World world, int chunkX, int chunkZ, @NotNull @NotNull Runnable task) Runstaskon the next tick of the region owning the chunk. -
runLater
-
runLater
-
runTimer
-
run
boolean run(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired) Runstaskon the next tick of the region owningentity. If the entity is removed first,retiredruns instead (on the entity's last thread, or at once).- Returns:
- false, and nothing is scheduled, if the entity is no longer valid (a player who left)
-
runLater
@Nullable @Nullable Task runLater(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delay) Likerun(Entity, Runnable, Runnable), afterdelay.- Returns:
- the task, or null, and nothing is scheduled, if the entity is no longer valid
-
runTimer
@Nullable @Nullable Task runTimer(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Runnable task, @Nullable @Nullable Runnable retired, long delay, long period) Runstaskeveryperioduntil cancelled or the entity is removed; thenretiredruns.- Returns:
- the task, or null, and nothing is scheduled, if the entity is no longer valid
-
runAsync
Runstaskon a pooled thread. It must not touch worlds, entities or players. -
isOwnedByCurrentThread
boolean isOwnedByCurrentThread(@NotNull @NotNull org.bukkit.Location location) - Returns:
- whether the current thread may touch
location(Paper: the main thread)
-
isOwnedByCurrentThread
boolean isOwnedByCurrentThread(@NotNull @NotNull org.bukkit.World world, int chunkX, int chunkZ) - Returns:
- whether the current thread may touch the chunk (Paper: the main thread)
-
isOwnedByCurrentThread
boolean isOwnedByCurrentThread(@NotNull @NotNull org.bukkit.entity.Entity entity) - Returns:
- whether the current thread may touch
entity(Paper: the main thread)
-