2424 */
2525package org .spongepowered .api .event ;
2626
27- import io .leangen .geantyref .TypeToken ;
2827import org .spongepowered .plugin .PluginContainer ;
2928
3029/**
3130 * Manages the registration of event listeners and the dispatching of events.
3231 */
3332public interface EventManager {
3433
34+ /**
35+ * Submits a new {@link EventListenerRegistration listener registration} to this manager.
36+ * @param registration The registration
37+ * @param <E> The event type
38+ * @return This manager, for fluency
39+ */
40+ <E extends Event > EventManager registerListener (EventListenerRegistration <E > registration );
41+
3542 /**
3643 * Registers {@link Event} methods annotated with @{@link Listener} in the
3744 * specified object.
@@ -41,129 +48,23 @@ public interface EventManager {
4148 *
4249 * @param plugin The plugin container
4350 * @param obj The object
51+ * @return This manager, for fluency
4452 */
45- void registerListeners (PluginContainer plugin , Object obj );
46-
47- /**
48- * Registers an event listener for a specific event class.
49- *
50- * <p>Normally, the annotation-based way in
51- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
52- * method exists primarily to support dynamic event registration like needed
53- * in scripting plugins.</p>
54- *
55- * @param plugin The plugin instance
56- * @param eventClass The event to listen to
57- * @param listener The listener to receive the events
58- * @param <T> The type of the event
59- */
60- <T extends Event > void registerListener (PluginContainer plugin , Class <T > eventClass , EventListener <? super T > listener );
61-
62- /**
63- * Registers an event listener for a specific event {@link TypeToken}.
64- *
65- * <p>Normally, the annotation-based way in
66- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
67- * method exists primarily to support dynamic event registration like needed
68- * in scripting plugins.</p>
69- *
70- * @param plugin The plugin instance
71- * @param eventType The event to listen to
72- * @param listener The listener to receive the events
73- * @param <T> The type of the event
74- */
75- <T extends Event > void registerListener (PluginContainer plugin , TypeToken <T > eventType , EventListener <? super T > listener );
76-
77- /**
78- * Registers an event listener with the specified order for a specific event
79- * class.
80- *
81- * <p>Normally, the annotation-based way in
82- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
83- * method exists primarily to support dynamic event registration like needed
84- * in scripting plugins.</p>
85- *
86- * @param plugin The plugin instance
87- * @param eventClass The event to listen to
88- * @param order The order the listener will get called at
89- * @param listener The listener to receive the events
90- * @param <T> The type of the event
91- */
92- <T extends Event > void registerListener (PluginContainer plugin , Class <T > eventClass , Order order , EventListener <? super T > listener );
93-
94- /**
95- * Registers an event listener with the specified order for a specific event
96- * {@link TypeToken}.
97- *
98- * <p>Normally, the annotation-based way in
99- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
100- * method exists primarily to support dynamic event registration like needed
101- * in scripting plugins.</p>
102- *
103- * @param plugin The plugin instance
104- * @param eventType The event to listen to
105- * @param order The order the listener will get called at
106- * @param listener The listener to receive the events
107- * @param <T> The type of the event
108- */
109- <T extends Event > void registerListener (PluginContainer plugin , TypeToken <T > eventType , Order order , EventListener <? super T > listener );
110-
111- /**
112- * Registers an event listener with the specified order for a specific event
113- * class.
114- *
115- * <p>Normally, the annotation-based way in
116- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
117- * method exists primarily to support dynamic event registration like needed
118- * in scripting plugins.</p>
119- *
120- * @param plugin The plugin instance
121- * @param eventClass The event to listen to
122- * @param order The order the listener will get called at
123- * @param beforeModifications Whether to call the listener before other
124- * server modifications
125- * @param listener The listener to receive the events
126- * @param <T> The type of the event
127- */
128- <T extends Event > void registerListener (PluginContainer plugin , Class <T > eventClass , Order order , boolean beforeModifications ,
129- EventListener <? super T > listener );
130-
131- /**
132- * Registers an event listener with the specified order for a specific event
133- * class.
134- *
135- * <p>Normally, the annotation-based way in
136- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
137- * method exists primarily to support dynamic event registration like needed
138- * in scripting plugins.</p>
139- *
140- * @param plugin The plugin instance
141- * @param eventType The event to listen to
142- * @param order The order the listener will get called at
143- * @param beforeModifications Whether to call the listener before other
144- * server modifications
145- * @param listener The listener to receive the events
146- * @param <T> The type of the event
147- */
148- <T extends Event > void registerListener (PluginContainer plugin , TypeToken <T > eventType , Order order , boolean beforeModifications ,
149- EventListener <? super T > listener );
53+ EventManager registerListeners (PluginContainer plugin , Object obj );
15054
15155 /**
15256 * Un-registers an object from receiving {@link Event}s.
15357 *
154- * @param obj The object
155- */
156- void unregisterListeners (Object obj );
157-
158- /**
159- * Un-registers all event listeners of a plugin.
58+ * <p>If the provided object is a {@link PluginContainer plugin}, all events associated
59+ * with that plugin will be unregistered.</p>
16060 *
161- * @param plugin The plugin instance
61+ * @param obj The object
62+ * @return This manager, for fluency
16263 */
163- void unregisterPluginListeners ( PluginContainer plugin );
64+ EventManager unregisterListeners ( Object obj );
16465
16566 /**
166- * Calls a {@link Event} to all listeners that listen to it.
67+ * Calls an {@link Event} to all listeners that listen to it.
16768 *
16869 * @param event The event
16970 * @return True if cancelled, false if not
0 commit comments