Class ServerCountdownManager

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

public final class ServerCountdownManager extends Object
Countdown factory running against the MinecraftServer context.
Obtain the shared instance through TimelessLib.countdowns() - this class cannot be constructed by other mods.
  • Constructor Details

    • ServerCountdownManager

      public ServerCountdownManager(InternalAccess access, Supplier<net.minecraft.server.MinecraftServer> contextProvider)
    • ServerCountdownManager

      public ServerCountdownManager(InternalAccess access, Supplier<net.minecraft.server.MinecraftServer> contextProvider, int poolSize)
  • Method Details

    • start

      public ServerCountdown start(Duration totalDuration)
      Starts a countdown with a tick interval of 50ms and the game time source.
      Parameters:
      totalDuration - Duration of the countdown.
      Returns:
      ServerCountdown
      See Also:
    • startRealtime

      public ServerCountdown startRealtime(Duration totalDuration)
      Starts a countdown with a tick interval of 50ms and the real time source.
      Parameters:
      totalDuration - Duration of the countdown.
      Returns:
      ServerCountdown
      See Also:
    • start

      public ServerCountdown start(Duration totalDuration, Duration tickInterval, TimeSource timeSource)
      Starts a countdown with the specified tick interval and time source.
      Parameters:
      totalDuration - Duration of the countdown.
      tickInterval - Tick interval of the countdown.
      timeSource - Time source to use.
      Returns:
      ServerCountdown
      See Also:
    • get

      public Optional<TaskHandle> get(net.minecraft.resources.Identifier id)
      Looks up an active countdown by its ID.
      Parameters:
      id - Countdown ID
      Returns:
      TaskHandle or empty if no active countdown has that ID
    • activeCountdownCount

      public int activeCountdownCount()
      Returns:
      the number of currently active countdowns.
    • cancelAll

      public boolean cancelAll()
      Cancels every currently active countdown.
      Returns:
      true if at least one countdown was cancelled
    • shutdown

      public void shutdown()
      If you're getting the countdown manager through TimelessLib.countdowns() or the client counterpart you should NOT call this method.
    • shutdownGracefully

      public void shutdownGracefully(long timeout, TimeUnit unit) throws InterruptedException
      If you're getting the countdown manager through TimelessLib.countdowns() or the client counterpart you should NOT call this method.
      Throws:
      InterruptedException
    • isShutdown

      public boolean isShutdown()
    • isTerminated

      public boolean isTerminated()