Class EntityScheduler

java.lang.Object
io.github.retrooper.packetevents.util.folia.EntityScheduler

public class EntityScheduler extends Object
Represents a scheduler for executing entity tasks.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(@NotNull org.bukkit.entity.Entity entity, @NotNull org.bukkit.plugin.Plugin plugin, @NotNull Runnable run, @Nullable Runnable retired, long delay)
    Schedules a task with the given delay.
    run(@NotNull org.bukkit.entity.Entity entity, @NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<Object> task, @Nullable Runnable retired)
    Schedules a task to execute on the next tick.
    runAtFixedRate(@NotNull org.bukkit.entity.Entity entity, @NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<Object> task, @Nullable Runnable retired, long initialDelayTicks, long periodTicks)
    Schedules a repeating task with the given delay and period.
    runDelayed(@NotNull org.bukkit.entity.Entity entity, @NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<Object> task, @Nullable Runnable retired, long delayTicks)
    Schedules a task with the given delay.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EntityScheduler

      protected EntityScheduler()
  • Method Details

    • execute

      public void execute(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Runnable run, @Nullable @Nullable Runnable retired, long delay)
      Schedules a task with the given delay. If the task failed to schedule because the scheduler is retired (entity removed), then returns false. Otherwise, either the run callback will be invoked after the specified delay, or the retired callback will be invoked if the scheduler is retired. Note that the retired callback is invoked in critical code, so it should not attempt to remove the entity, remove other entities, load chunks, load worlds, modify ticket levels, etc.

      It is guaranteed that the run and retired callback are invoked on the region which owns the entity.

      Parameters:
      plugin - Plugin which owns the specified task.
      run - The callback to run after the specified delay, may not be null.
      retired - Retire callback to run if the entity is retired before the run callback can be invoked, may be null.
      delay - The delay in ticks before the run callback is invoked.
    • run

      public TaskWrapper run(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task, @Nullable @Nullable Runnable retired)
      Schedules a task to execute on the next tick. If the task failed to schedule because the scheduler is retired (entity removed), then returns null. Otherwise, either the task callback will be invoked after the specified delay, or the retired callback will be invoked if the scheduler is retired. Note that the retired callback is invoked in critical code, so it should not attempt to remove the entity, remove other entities, load chunks, load worlds, modify ticket levels, etc.

      It is guaranteed that the task and retired callback are invoked on the region which owns the entity.

      Parameters:
      plugin - The plugin that owns the task
      task - The task to execute
      retired - Retire callback to run if the entity is retired before the run callback can be invoked, may be null.
      Returns:
      TaskWrapper instance representing a wrapped task
    • runDelayed

      public TaskWrapper runDelayed(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task, @Nullable @Nullable Runnable retired, long delayTicks)
      Schedules a task with the given delay. If the task failed to schedule because the scheduler is retired (entity removed), then returns null. Otherwise, either the task callback will be invoked after the specified delay, or the retired callback will be invoked if the scheduler is retired. Note that the retired callback is invoked in critical code, so it should not attempt to remove the entity, remove other entities, load chunks, load worlds, modify ticket levels, etc.

      It is guaranteed that the task and retired callback are invoked on the region which owns the entity.

      Parameters:
      plugin - The plugin that owns the task
      task - The task to execute
      retired - Retire callback to run if the entity is retired before the run callback can be invoked, may be null.
      delayTicks - The delay in ticks before the run callback is invoked. Any value less-than 1 is treated as 1.
      Returns:
      TaskWrapper instance representing a wrapped task
    • runAtFixedRate

      public TaskWrapper runAtFixedRate(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<Object> task, @Nullable @Nullable Runnable retired, long initialDelayTicks, long periodTicks)
      Schedules a repeating task with the given delay and period. If the task failed to schedule because the scheduler is retired (entity removed), then returns null. Otherwise, either the task callback will be invoked after the specified delay, or the retired callback will be invoked if the scheduler is retired. Note that the retired callback is invoked in critical code, so it should not attempt to remove the entity, remove other entities, load chunks, load worlds, modify ticket levels, etc.

      It is guaranteed that the task and retired callback are invoked on the region which owns the entity.

      Parameters:
      plugin - The plugin that owns the task
      task - The task to execute
      retired - Retire callback to run if the entity is retired before the run callback can be invoked, may be null.
      initialDelayTicks - The initial delay, in ticks before the method is invoked. Any value less-than 1 is treated as 1.
      periodTicks - The period, in ticks. Any value less-than 1 is treated as 1.
      Returns:
      TaskWrapper instance representing a wrapped task