Interface EventBus
public interface EventBus
Platform-independent event bus. Listeners are called on the server (main/region) thread,
in
EventPriority order; a listener throwing an exception is logged and skipped.
Subscription sub = SepareWorldItems.get().events().subscribe(GroupSwitchPreEvent.class, e -> {
if (e.to().group().equals("minigames") && isInCombat(e.playerUuid())) e.setCancelled(true);
});
// later: sub.unsubscribe();
Subscribing to a supertype (e.g. PlayerEvent) receives every subtype.-
Method Summary
Modifier and TypeMethodDescription<E extends SwiEvent>
Epost(E event) Dispatches an event to its listeners.<E extends SwiEvent>
@NotNull Subscriptionsubscribe(@NotNull Class<E> type, @NotNull EventPriority priority, @NotNull Consumer<? super E> listener) <E extends SwiEvent>
@NotNull Subscription
-
Method Details
-
subscribe
@NotNull <E extends SwiEvent> @NotNull Subscription subscribe(@NotNull @NotNull Class<E> type, @NotNull @NotNull Consumer<? super E> listener) -
subscribe
@NotNull <E extends SwiEvent> @NotNull Subscription subscribe(@NotNull @NotNull Class<E> type, @NotNull @NotNull EventPriority priority, @NotNull @NotNull Consumer<? super E> listener) -
post
Dispatches an event to its listeners.- Returns:
- the same event, so callers can read
Cancellable.isCancelled()
-