public final class EventManager extends Object implements IEventManager
| Modifier and Type | Field and Description |
|---|---|
private Map<Class<? extends Event>,Collection<EventEntity>> |
registeredListeners |
| Constructor and Description |
|---|
EventManager() |
| Modifier and Type | Method and Description |
|---|---|
<T extends Event> |
callEvent(T event)
Call an event and forward it to all
IEventListeners registered
on this event manager. |
void |
clearAll()
Clears all currently registered
EventEntitys from this event
manager instance. |
private Class |
getClazz(IEventListener<?> eventListener) |
<T extends Event> |
registerListener(EventKey eventKey,
IEventListener<T> eventListener)
Registers a new listener that will be called on matching events.
|
<T extends Event> |
registerListeners(EventKey eventKey,
IEventListener<T>... eventListeners)
Registers multiple event listeners at once.
|
void |
unregisterListener(Class<? extends Event> eventClass)
Removes all event listeners for a specific event class.
|
void |
unregisterListener(EventKey eventKey)
Removes all listener from a specific
EventKey from this event manager. |
void |
unregisterListener(IEventListener<? extends Event> eventListener)
Removes an event listener from all
EventEntitys. |
private final Map<Class<? extends Event>,Collection<EventEntity>> registeredListeners
public void clearAll()
EventEntitys from this event
manager instance.public <T extends Event> void registerListener(EventKey eventKey, IEventListener<T> eventListener)
IEventManagerregisterListener in interface IEventManagerT - the type of the events to have the event listener be called oneventKey - the domain of the event listenereventListener - the actual event listener instance that will be called uponIEventManager.registerListeners(EventKey, IEventListener[])@SafeVarargs public final <T extends Event> void registerListeners(EventKey eventKey, IEventListener<T>... eventListeners)
IEventManagerregisterListeners in interface IEventManagerT - the type of the events to have the event listeners be called oneventKey - the domain of the event listenerseventListeners - the event listener instances that will be called uponIEventManager.registerListener(EventKey, IEventListener)public void unregisterListener(EventKey eventKey)
IEventManagerEventKey from this event manager.unregisterListener in interface IEventManagereventKey - the domain of the event listeners that will be removedpublic void unregisterListener(IEventListener<? extends Event> eventListener)
IEventManagerEventEntitys.unregisterListener in interface IEventManagereventListener - the event listener to removepublic void unregisterListener(Class<? extends Event> eventClass)
IEventManagerunregisterListener in interface IEventManagereventClass - the class that should have all its event listeners removedpublic <T extends Event> boolean callEvent(T event)
IEventManagerIEventListeners registered
on this event manager.callEvent in interface IEventManagerT - the type of the event and IEventListener to callevent - the event to calltrue when no IEventListener was called,
false otherwiseprivate Class getClazz(IEventListener<?> eventListener) throws Exception
ExceptionCopyright © 2020. All rights reserved.