Class Sequence<T>

java.lang.Object
dev.bouncingelf10.timelesslib.api.scheduler.Sequence<T>

public final class Sequence<T> extends Object
A builder for a chain of delayed steps that run one after another - "wait, then do this, then wait, then do that".
Unlike nesting after(...) calls inside each other, a sequence is a single cancellable/pausable TaskHandle for the whole chain. Obtained through Scheduler.sequence() / Scheduler.sequence().
  • Method Details

    • then

      public Sequence<T> then(Duration delay, Consumer<T> action)
      Adds a step that runs the given delay after the previous step finishes (or after the sequence starts, for the first step).
    • then

      public Sequence<T> then(Duration delay, Runnable action)
      Adds a step that runs the given delay after the previous step finishes, without needing the context.
    • start

      public TaskHandle start()
      Starts the sequence.
      Returns:
      TaskHandle for the whole chain - cancelling it stops the sequence, pausing it pauses whichever step is currently pending.
    • start

      public TaskHandle start(net.minecraft.resources.ResourceLocation id)
      Starts the sequence under the given ID.
      Throws:
      IllegalArgumentException - if a task with the specified ID already exists