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 java.lang.Object implements OwnedEventBus<O,E,S>
-
-
Constructor Summary
Constructors Constructor Description OwnedEventBusImpl()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static <T extends U,U>
java.util.Set<T>castGenericSet(java.util.Set<U> o)protected <T extends Subscriber<U>,U>
java.util.Set<T>eventSubscribers(java.lang.Class<U> eventType)protected <T extends E>
voidfindSubscriptions(@NonNull java.lang.Object listener, TriConsumer<java.lang.Class<T>,Subscribe,java.util.function.BiConsumer<java.lang.Object,T>> consumer)FireResultfire(@NonNull E event)Fires the given event and log all exceptions that occur while executing this event.FireResultfireSilently(@NonNull E event)Fires the given event silently.protected abstract <T extends E,B extends OwnedSubscriber<O,T>>
BmakeSubscription(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler, @NonNull PostOrder postOrder)protected abstract <L,T extends E,B extends OwnedSubscriber<O,T>>
BmakeSubscription(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull Subscribe subscribe, @NonNull L listener, @NonNull java.util.function.BiConsumer<L,T> handler)voidregister(@NonNull O owner, @NonNull java.lang.Object listener)Registers events for the given listener.protected <T extends E>
voidregister(java.lang.Class<T> eventClass, S subscriber)protected java.util.List<S>sortedSubscribers(java.lang.Class<?> eventClass)<T extends E,U extends OwnedSubscriber<O,T>>
@NonNull Usubscribe(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler)Subscribes to the given event seeSubscriber.<T extends E,U extends OwnedSubscriber<O,T>>
@NonNull Usubscribe(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler, @NonNull PostOrder postOrder)Subscribes to the given event seeSubscriber.<T extends E>
@NonNull java.util.Set<? extends OwnedSubscriber<O,T>>subscribers(@NonNull java.lang.Class<T> eventClass)Gets the subscriptions for the given event class.voidunregisterAll(@NonNull O owner)Unregisters all events from a given owner.voidunsubscribe(@NonNull S subscription)Unsubscribes the givenSubscriber.protected voidunsubscribeAll()protected voidunsubscribeMany(java.lang.Iterable<S> subscriptions)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.geysermc.event.bus.BaseBus
fire, fireSilently, unsubscribe
-
-
-
-
Method Detail
-
makeSubscription
protected abstract <L,T extends E,B extends OwnedSubscriber<O,T>> B makeSubscription(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull Subscribe subscribe, @NonNull L listener, @NonNull java.util.function.BiConsumer<L,T> handler)
-
makeSubscription
protected abstract <T extends E,B extends OwnedSubscriber<O,T>> B makeSubscription(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> handler, @NonNull PostOrder postOrder)
-
subscribe
public <T extends E,U extends OwnedSubscriber<O,T>> @NonNull U subscribe(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.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,T>> @NonNull U subscribe(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.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
public void register(@NonNull O owner, @NonNull java.lang.Object listener)
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
public void unregisterAll(@NonNull O owner)
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 java.util.Set<? extends OwnedSubscriber<O,T>> subscribers(@NonNull java.lang.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
protected <T extends E> void register(java.lang.Class<T> eventClass, S subscriber)
-
findSubscriptions
protected <T extends E> void findSubscriptions(@NonNull java.lang.Object listener, TriConsumer<java.lang.Class<T>,Subscribe,java.util.function.BiConsumer<java.lang.Object,T>> consumer)
-
unsubscribe
public void unsubscribe(@NonNull S subscription)
Description copied from interface:BaseBusUnsubscribes the givenSubscriber.- Specified by:
unsubscribein interfaceBaseBus<E,S extends Subscriber<? extends E>>- Parameters:
subscription- the event subscription
-
unsubscribeMany
protected void unsubscribeMany(java.lang.Iterable<S> subscriptions)
-
unsubscribeAll
protected void unsubscribeAll()
-
fire
public FireResult fire(@NonNull E event)
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
public FireResult fireSilently(@NonNull E event)
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
protected java.util.List<S> sortedSubscribers(java.lang.Class<?> eventClass)
-
eventSubscribers
protected <T extends Subscriber<U>,U> java.util.Set<T> eventSubscribers(java.lang.Class<U> eventType)
-
castGenericSet
protected static <T extends U,U> java.util.Set<T> castGenericSet(java.util.Set<U> o)
-
-