Package net.draycia.carbon.api.event
Interface CarbonEventHandler
@DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
public interface CarbonEventHandler
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescription<T extends CarbonEvent>
voidemit(T event) Emits the supplied event.<T extends CarbonEvent>
CarbonEventSubscription<T> subscribe(Class<T> eventClass, int order, boolean acceptsCancelled, CarbonEventSubscriber<T> subscriber) Registers a subscriber for the given event class.
Includes extra values to control when the consumer is executed.<T extends CarbonEvent>
CarbonEventSubscription<T> subscribe(Class<T> eventClass, CarbonEventSubscriber<T> subscriber) Registers a subscriber for the given event class.
-
Method Details
-
subscribe
<T extends CarbonEvent> CarbonEventSubscription<T> subscribe(Class<T> eventClass, CarbonEventSubscriber<T> subscriber) Registers a subscriber for the given event class.- Type Parameters:
T- the class to listen for- Parameters:
eventClass- the class to listen forsubscriber- the subscriber that's executed when the event is emitted- Returns:
- the subscription, so that it may be unregistered
- Since:
- 2.0.0
-
subscribe
<T extends CarbonEvent> CarbonEventSubscription<T> subscribe(Class<T> eventClass, int order, boolean acceptsCancelled, CarbonEventSubscriber<T> subscriber) Registers a subscriber for the given event class.
Includes extra values to control when the consumer is executed.- Type Parameters:
T- the class to listen for- Parameters:
eventClass- the class to listen fororder- the order of the consumeracceptsCancelled- if the consumer should be executed if the event is cancelled earlysubscriber- the consumer that's executed when the event is emitted- Returns:
- the subscription, so that it may be unregistered
- Since:
- 2.0.0
-
emit
Emits the supplied event.Events are modified in place, meaning you must keep a reference to the event yourself if you wish to inspect it's state after this call.
- Type Parameters:
T- the class to emit- Parameters:
event- the event to be emitted- Since:
- 2.0.0
-