Class GlobalWorldEventManager
The manager is the persisted universe resource. The universe resource system loads it once at universe start, flushes it on a fixed cadence and at shutdown, and serializes the writes for the file. The codec and the universe can create extra instances, so the constructor has no side effects. The plugin starts the task runner on the loaded instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<GlobalWorldEventManager> static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintUUID[]booleanvoidclear()Removes every active global world-event id and drops the queued start and stop tasks.booleanvoidflush()Writes the active ids now.static GlobalWorldEventManagerget()booleanstatic voidscheduleRestartEventInAllWorlds(UUID eventId) Stops the event in every world, then starts it again.static voidscheduleStartEventInAllWorlds(UUID eventId) voidshutdown()voidstart(Store<EntityStore> store, WorldEventRecord[] events) static booleanstartEvent(UUID eventId) voidstartup()static boolean
-
Field Details
-
ID
- See Also:
-
CODEC
-
-
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.
runTasks()drains and runs the task queue under the same lock. This call and a task run cannot interleave. Either the queue is 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
-
contains
-
activeCount
public int activeCount()- Returns:
- the number of active ids, without the copy that
activeIds()makes
-
activeIds
- Returns:
- a sorted snapshot of the active global world-event ids
-
remove
-
start
-
flush
public void flush()Writes the active ids now.The universe resource system also flushes on a fixed cadence and at shutdown. It serializes the writes for the file, so overlapping flushes cannot race on the temporary file.
-
startup
public void startup() -
shutdown
public void shutdown() -
get
-
startEvent
-
stopEvent
-
scheduleStartEventInAllWorlds
-
scheduleRestartEventInAllWorlds
Stops the event in every world, then starts it again.scheduleStartEventInAllWorlds(UUID)alone cannot restart a running event, becauseEventStartAction.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.
-