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 Summary
Modifier and TypeMethodDescriptionbooleanhasListeners(@NotNull EventType<?> type, @NotNull EventPhase phase) Lets callers skip building events nobody listens to (§26).<E> Epost(@NotNull EventType<E> type, @NotNull EventPhase phase, E event) Deliverseventto the listeners oftypeinphase.<E> @NotNull Subscriptionsubscribe(@NotNull AddonId owner, @NotNull EventType<E> type, @NotNull EventPhase phase, @NotNull EventPriority priority, @NotNull Consumer<? super E> listener) default <E> @NotNull Subscriptionsubscribe(@NotNull AddonId owner, @NotNull EventType<E> type, @NotNull EventPhase phase, @NotNull Consumer<? super E> listener) voidunsubscribeAll(@NotNull AddonId owner) Removes every listener ofowner, e.g.
-
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) Deliverseventto the listeners oftypeinphase.- Returns:
event, for reading the listeners' changes (e.g. cancellation)
-
hasListeners
Lets callers skip building events nobody listens to (§26). -
unsubscribeAll
Removes every listener ofowner, e.g. when the addon disables.
-