Interface EventBus


@NonExtendable public interface EventBus
MachineEngine's own event bus (D12). Events run on the thread performing the operation; listeners must not block. A failing listener is logged and does not stop the others.
  • Method Details

    • subscribe

      @NotNull <E> @NotNull Subscription subscribe(@NotNull @NotNull AddonId owner, @NotNull @NotNull EventType<E> type, @NotNull @NotNull EventPhase phase, @NotNull @NotNull EventPriority priority, @NotNull @NotNull Consumer<? super E> listener)
    • subscribe

      @NotNull default <E> @NotNull Subscription subscribe(@NotNull @NotNull AddonId owner, @NotNull @NotNull EventType<E> type, @NotNull @NotNull EventPhase phase, @NotNull @NotNull Consumer<? super E> listener)
    • post

      @NotNull <E> E post(@NotNull @NotNull EventType<E> type, @NotNull @NotNull EventPhase phase, @NotNull E event)
      Delivers event to the listeners of type in phase.
      Returns:
      event, for reading the listeners' changes (e.g. cancellation)
    • hasListeners

      boolean hasListeners(@NotNull @NotNull EventType<?> type, @NotNull @NotNull EventPhase phase)
      Lets callers skip building events nobody listens to (§26).
    • unsubscribeAll

      void unsubscribeAll(@NotNull @NotNull AddonId owner)
      Removes every listener of owner, e.g. when the addon disables.