Package dev.prozilla.pine.common.event
Interface EventDispatcherContext<EventType extends Enum<EventType>,Target,E extends Event<EventType,? super Target>>
- All Known Subinterfaces:
EventDispatcherProvider<EventType,Target, E>
- All Known Implementing Classes:
AssetPoolEventDispatcher,Entity,EventDispatcher,Node,NodeEventDispatcher,SimpleEventDispatcher
@ContextOf(EventDispatcher.class)
public interface EventDispatcherContext<EventType extends Enum<EventType>,Target,E extends Event<EventType,? super Target>>
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionaddListener(EventType eventType, EventListener<E> listener) Adds a listener that listens to a given type of event.default EventListener<E> addListener(EventType eventType, EventListener<E> listener, boolean once) Adds a listener that listens to a given type of event.default EventListener<E> addTargetedListener(EventType eventType, Target target, EventListener<E> listener) Adds a listener that only listens to events of a given type with the given target.default voiddispatchEvent(EventType eventType, Target target) Equivalent ofinvoke(Enum, Object).voidInvokes the event of a given type with a given target.default voidoff(EventType eventType, EventListener<E> listener) Equivalent ofremoveListener(Enum, EventListener).default EventListener<E> on(EventType eventType, EventListener<E> listener) Equivalent ofaddListener(Enum, EventListener).default EventListener<E> once(EventType eventType, EventListener<E> listener) Equivalent ofaddListener(Enum, EventListener, boolean), where the last argument istrue.voidremoveListener(EventType eventType, EventListener<E> listener) Removes a listener that was listening to a given type of event.
-
Method Details
-
on
Equivalent ofaddListener(Enum, EventListener). -
off
Equivalent ofremoveListener(Enum, EventListener). -
once
Equivalent ofaddListener(Enum, EventListener, boolean), where the last argument istrue. -
dispatchEvent
Equivalent ofinvoke(Enum, Object). -
addTargetedListener
default EventListener<E> addTargetedListener(EventType eventType, Target target, EventListener<E> listener) Adds a listener that only listens to events of a given type with the given target.- Parameters:
eventType- The type of event to listen totarget- The target of the eventlistener- The listener that handles events with the given target- Returns:
- The targeted listener that was added.
-
addListener
Adds a listener that listens to a given type of event.Unicity is not required. If a listener is added multiple times, it will be called multiple times per event.
- Parameters:
eventType- The type of event to listen tolistener- The listener to addonce- When set totrue, the event listener will be removed after the first event of the given type- Returns:
- The listener that was added.
-
addListener
Adds a listener that listens to a given type of event.Unicity is not required. If a listener is added multiple times, it will be called multiple times per event.
- Parameters:
eventType- The type of event to listen tolistener- The listener to add- Returns:
- The listener that was added.
-
removeListener
Removes a listener that was listening to a given type of event.- Parameters:
eventType- The type of event that was being listened tolistener- The listener to remove
-
invoke
Invokes the event of a given type with a given target.- Parameters:
eventType- The type of event to invoketarget- The target of the event
-