Package org.geysermc.event.bus.impl
Class OwnedEventBusImpl<O,E,S extends OwnedSubscriber<O,? extends E>>
java.lang.Object
org.geysermc.event.bus.impl.OwnedEventBusImpl<O,E,S>
- All Implemented Interfaces:
BaseBus<E,,S> OwnedEventBus<O,E, S>
public abstract class OwnedEventBusImpl<O,E,S extends OwnedSubscriber<O,? extends E>>
extends Object
implements OwnedEventBus<O,E,S>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T extends U,U>
Set<T>castGenericNullableSet(@Nullable Set<U> o) protected <T extends Subscriber<U>,U>
Set<T>eventSubscribers(Class<U> eventType) protected <T extends E>
voidfindSubscriptions(@NonNull Object listener, TriConsumer<Class<T>, Subscribe, BiConsumer<Object, T>> consumer) Fires the given event and log all exceptions that occur while executing this event.fireSilently(E event) Fires the given event silently.protected abstract <T extends E,B extends OwnedSubscriber<O, T>>
BmakeSubscription(@NonNull O owner, @NonNull Class<T> eventClass, @NonNull Consumer<T> handler, @NonNull PostOrder postOrder) protected abstract <L,T extends E, B extends OwnedSubscriber<O, T>>
BmakeSubscription(@NonNull O owner, @NonNull Class<T> eventClass, @NonNull Subscribe subscribe, @NonNull L listener, @NonNull BiConsumer<L, T> handler) voidRegisters events for the given listener.protected <T extends E>
voidsortedSubscribers(Class<?> eventClass) <T extends E,U extends OwnedSubscriber<O, T>>
@NonNull USubscribes to the given event seeSubscriber.<T extends E,U extends OwnedSubscriber<O, T>>
@NonNull Usubscribe(@NonNull O owner, @NonNull Class<T> eventClass, @NonNull Consumer<T> handler, @NonNull PostOrder postOrder) Subscribes to the given event seeSubscriber.<T extends E>
@NonNull Set<? extends OwnedSubscriber<O,T>> subscribers(@NonNull Class<T> eventClass) Gets the subscriptions for the given event class.voidunregisterAll(@NonNull O owner) Unregisters all events from a given owner.voidunsubscribe(S subscription) Unsubscribes the givenSubscriber.protected voidprotected voidunsubscribeMany(Iterable<S> subscriptions) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.geysermc.event.bus.BaseBus
fire, fireSilently, unsubscribe
-
Constructor Details
-
OwnedEventBusImpl
public OwnedEventBusImpl()
-
-
Method Details
-
makeSubscription
protected abstract <L,T extends E, B makeSubscriptionB extends OwnedSubscriber<O, T>> (@NonNull O owner, @NonNull Class<T> eventClass, @NonNull Subscribe subscribe, @NonNull L listener, @NonNull BiConsumer<L, T> handler) -
makeSubscription
-
subscribe
public <T extends E,U extends OwnedSubscriber<O, @NonNull U subscribeT>> (@NonNull O owner, @NonNull Class<T> eventClass, @NonNull Consumer<T> handler) Description copied from interface:OwnedEventBusSubscribes to the given event seeSubscriber.The difference between this method and is that this method takes in an extension parameter which allows for the event to be unsubscribed upon extension disable and reloads.
- Specified by:
subscribein interfaceOwnedEventBus<O,E, S extends OwnedSubscriber<O, ? extends E>> - Type Parameters:
T- the event class- Parameters:
owner- the extension to subscribe the event toeventClass- the class of the eventhandler- the consumer for handling the event- Returns:
- the event subscription
-
subscribe
public <T extends E,U extends OwnedSubscriber<O, @NonNull U subscribeT>> (@NonNull O owner, @NonNull Class<T> eventClass, @NonNull Consumer<T> handler, @NonNull PostOrder postOrder) Description copied from interface:OwnedEventBusSubscribes to the given event seeSubscriber.The difference between this method and is that this method takes in an extension parameter which allows for the event to be unsubscribed upon extension disable and reloads.
- Specified by:
subscribein interfaceOwnedEventBus<O,E, S extends OwnedSubscriber<O, ? extends E>> - Type Parameters:
T- the event class- Parameters:
owner- the extension to subscribe the event toeventClass- the class of the eventhandler- the consumer for handling the eventpostOrder- the order of the subscriber- Returns:
- the event subscription
-
register
Description copied from interface:OwnedEventBusRegisters events for the given listener.- Specified by:
registerin interfaceOwnedEventBus<O,E, S extends OwnedSubscriber<O, ? extends E>> - Parameters:
owner- the extension registering the eventlistener- the listener
-
unregisterAll
Description copied from interface:OwnedEventBusUnregisters all events from a given owner.- Specified by:
unregisterAllin interfaceOwnedEventBus<O,E, S extends OwnedSubscriber<O, ? extends E>> - Parameters:
owner- the extension
-
subscribers
public <T extends E> @NonNull Set<? extends OwnedSubscriber<O,T>> subscribers(@NonNull Class<T> eventClass) Description copied from interface:BaseBusGets the subscriptions for the given event class.- Specified by:
subscribersin interfaceBaseBus<O,E> - Specified by:
subscribersin interfaceOwnedEventBus<O,E, S extends OwnedSubscriber<O, ? extends E>> - Type Parameters:
T- the value- Parameters:
eventClass- the event class- Returns:
- the subscriptions for the event class
-
register
-
findSubscriptions
protected <T extends E> void findSubscriptions(@NonNull Object listener, TriConsumer<Class<T>, Subscribe, BiConsumer<Object, T>> consumer) -
unsubscribe
Description copied from interface:BaseBusUnsubscribes the givenSubscriber.- Specified by:
unsubscribein interfaceBaseBus<E,S extends Subscriber<? extends E>> - Parameters:
subscription- the event subscription
-
unsubscribeMany
-
unsubscribeAll
protected void unsubscribeAll() -
fire
Description copied from interface:BaseBusFires the given event and log all exceptions that occur while executing this event.- Specified by:
firein interfaceBaseBus<E,S extends Subscriber<? extends E>> - Parameters:
event- the event to fire
-
fireSilently
Description copied from interface:BaseBusFires the given event silently.- Specified by:
fireSilentlyin interfaceBaseBus<E,S extends Subscriber<? extends E>> - Parameters:
event- the event to fire- Returns:
- the result of firing the given event
-
sortedSubscribers
-
eventSubscribers
-
castGenericNullableSet
-