Interface EventCondition

All Known Subinterfaces:
EventCondition.Event<T>, EventCondition.Ticking, EventCondition.TrackedEvent<T>
All Known Implementing Classes:
EnterInstanceTeleporterCondition, EnterPortalCondition, EventEndCondition, GameFlagLevelCondition, IntervalCondition, LocationCondition, NoCondition, ProximityCondition, SignalCondition, TimeCondition, WorldClosedCondition

public interface EventCondition
Gates progression from one world event stage to the next. A stage does not advance until every condition assigned to it returns true from test().

Choose a sub-interface based on how the condition should be driven:

All condition classes must have a corresponding EventCondition.Type constant registered via WorldEventsPlugin.registerConditionType(), and a EventCondition.Config inner class that acts as the asset-side factory.

  • Field Details

  • Method Details

    • test

      boolean test()
      Returns true when this condition has been satisfied.

      This method is called frequently and must be side-effect free. Update internal state in EventCondition.Ticking.tick(float, Store) or EventCondition.Event.handle(World, T) instead.

      Returns:
      true if the condition is met
    • reset

      void reset()
      Resets the condition to its unsatisfied state before a new stage iteration begins.

      Called before onStart(WorldEvent) at the start of a stage. All transient fields (timers, flags, cached context references) should be cleared here.

    • onStart

      default boolean onStart(@Nonnull WorldEvent event)
      Called when the stage this condition belongs to begins, after reset().

      Implementations typically use this to look up values in the event context that the condition needs in order to operate (e.g. a location or a child event reference). If a required context value is absent, log a warning and return false to abort the stage immediately.

      Parameters:
      event - the world event whose stage is starting
      Returns:
      false to abort the stage before it runs
    • onComplete

      default boolean onComplete(@Nonnull WorldEvent event)
      Called after all conditions in the stage have returned true from test(), before the stage's actions are run.

      This is the correct place to write results into the event context (e.g. LocationCondition writes the chosen location as a LocationContext here). Return false if the condition cannot produce a valid result, which will treat the stage as failed.

      Parameters:
      event - the world event whose stage just completed
      Returns:
      false to treat the stage as failed
    • onCancel

      default void onCancel(@Nonnull WorldEvent event)
      Called if the condition belongs to a Fork that has been canceled due to a different Fork at the same Stage completing first.

      Implementations should use this to clean up any Context that they added to the WorldEvent in onStart(WorldEvent) that they would have removed in onComplete(WorldEvent) if the Fork were successful.

      Parameters:
      event - the world event whose fork just canceled
    • merge

      default void merge(@Nonnull EventCondition other)
      Copies runtime state from other into this condition.

      Called when a persisted condition is restored from storage. The (this) condition is built from its asset config, and the loaded state from the (other) condition is merged into it.

      Parameters:
      other - the loaded condition to merge state from.