Class GlobalWorldEventManager

java.lang.Object
com.hypixel.hytale.builtin.adventure.worldevents.GlobalWorldEventManager

@ThreadSafe public final class GlobalWorldEventManager extends Object
  • Field Details

  • Constructor Details

    • GlobalWorldEventManager

      public GlobalWorldEventManager()
  • Method Details

    • clear

      public void clear()
      Removes every active global world-event id and drops the queued start and stop tasks.

      The caller must stop the running events itself. This method only clears the manager.

      Does not touch taskBuffer. runTasks() drains and runs that list under the same lock, so this call and a task run cannot interleave: the queue is either wiped before a task is drained, or the drained tasks run to completion first. A reset cannot race a mid-drain task and leave a global event running in worlds it just reset.

    • add

      public boolean add(@Nonnull UUID eventId)
    • contains

      public boolean contains(@Nonnull UUID eventId)
    • activeCount

      public int activeCount()
      Returns:
      the number of active ids, without the copy that activeIds() makes
    • activeIds

      @Nonnull public UUID[] activeIds()
      Returns:
      a sorted snapshot of the active global world-event ids
    • remove

      public boolean remove(@Nonnull UUID eventId)
    • start

      public void start(@Nonnull Store<EntityStore> store, @Nonnull WorldEventRecord[] events)
    • loadAsync

    • saveAsync

      public void saveAsync()
    • startup

      public void startup()
    • shutdown

      public void shutdown()
    • startEvent

      public static boolean startEvent(@Nonnull UUID eventId)
    • stopEvent

      public static boolean stopEvent(@Nonnull UUID eventId)
    • scheduleStartEventInAllWorlds

      public static void scheduleStartEventInAllWorlds(@Nonnull UUID eventId)
    • scheduleRestartEventInAllWorlds

      public static void scheduleRestartEventInAllWorlds(@Nonnull UUID eventId)
      Stops the event in every world, then starts it again.

      scheduleStartEventInAllWorlds(UUID) alone cannot restart a running event, because EventStartAction.startEvent(ComponentAccessor, WorldEventRecord) refuses an id that the world already runs. Both halves run in one task, so each world receives the stop before the start. The removal that the stop queues is applied before the start task runs, so the start then sees a free id.