java.lang.Object
dev.bouncingelf10.timelesslib.api.countdown.Countdown

public class Countdown extends Object
  • Method Details

    • cancel

      public boolean cancel()
      Cancels the countdown.
      Returns:
      true if the countdown was cancelled, false if it was already finished or canceled
    • pause

      public boolean pause()
      Pauses the countdown. Note: If the countdown is already paused, this method does nothing.
      Returns:
      true if the countdown was paused, false if it was already finished or canceled
    • resume

      public boolean resume()
      Resumes a paused countdown. Note: If the countdown is not paused, this method does nothing.
      Returns:
      true if the countdown was resumed, false if it was already finished or canceled
    • pauseOrUnpause

      public boolean pauseOrUnpause()
      Toggles to pause or unpause the countdown.
      Returns:
      true if the countdown was changed state, false if it was already finished or canceled
    • isCancelled

      public boolean isCancelled()
    • isPaused

      public boolean isPaused()
    • isFinished

      public boolean isFinished()
    • remaining

      public Duration remaining()
    • getId

      public String getId()
    • onTick

      public Countdown onTick(BiConsumer<Object,Duration> handler)
      Adds a task to execute every countdown tick specified by the tick interval.
      Parameters:
      handler - Handler to execute every countdown tick.
      See Also:
    • onFinish

      public Countdown onFinish(Consumer<Object> handler)
      Adds a task to execute when the countdown finishes.
      Parameters:
      handler - Handler to execute when the countdown finishes.
    • onThreshold

      public Countdown onThreshold(Duration threshold, Consumer<Object> handler)
      Adds a task to execute when the countdown reaches the specified threshold.
      Parameters:
      threshold - Duration threshold to reach.
      handler - Handler to execute when the threshold is reached.
    • every

      public Countdown every(Duration interval, Consumer<Object> handler)
      Adds a task to execute every time the specified interval elapses. (Like onTick(BiConsumer), but with a specified interval instead of the countdown tick interval)
      Parameters:
      interval - Interval at which to execute the handler.
      handler - Handler to execute every time the interval elapses.
    • displayToUser

      public Countdown displayToUser(net.minecraft.server.level.ServerPlayer player)
    • displayToUser

      public Countdown displayToUser(net.minecraft.server.level.ServerPlayer player, TimeFormat timeFormat, String prefix, String suffix)
    • displayAllUsers

      public Countdown displayAllUsers()
    • displayAllUsers

      public Countdown displayAllUsers(TimeFormat timeFormat, String prefix, String suffix)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(net.minecraft.world.phys.Vec3 position, float radius)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(net.minecraft.world.phys.Vec3 position, float radius, TimeFormat timeFormat, String prefix, String suffix)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(net.minecraft.server.level.ServerPlayer player, float radius)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(net.minecraft.server.level.ServerPlayer player, float radius, TimeFormat timeFormat, String prefix, String suffix)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(net.minecraft.core.BlockPos blockPos, float radius)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(net.minecraft.core.BlockPos blockPos, float radius, TimeFormat timeFormat, String prefix, String suffix)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(double x, double y, double z, float radius)
    • displayNearbyUsers

      public Countdown displayNearbyUsers(double x, double y, double z, float radius, TimeFormat timeFormat, String prefix, String suffix)