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,131 +48,23 @@ public interface EventManager {
4148 *
4249 * @param plugin The plugin instance
4350 * @param obj The object
44- * @throws IllegalArgumentException Thrown if {@code plugin} is not a plugin
45- * instance
46- */
47- void registerListeners (PluginContainer plugin , Object obj );
48-
49- /**
50- * Registers an event listener for a specific event class.
51- *
52- * <p>Normally, the annotation-based way in
53- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
54- * method exists primarily to support dynamic event registration like needed
55- * in scripting plugins.</p>
56- *
57- * @param plugin The plugin instance
58- * @param eventClass The event to listen to
59- * @param listener The listener to receive the events
60- * @param <T> The type of the event
51+ * @return This manager, for fluency
6152 */
62- <T extends Event > void registerListener (PluginContainer plugin , Class <T > eventClass , EventListener <? super T > listener );
63-
64- /**
65- * Registers an event listener for a specific event {@link TypeToken}.
66- *
67- * <p>Normally, the annotation-based way in
68- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
69- * method exists primarily to support dynamic event registration like needed
70- * in scripting plugins.</p>
71- *
72- * @param plugin The plugin instance
73- * @param eventType The event to listen to
74- * @param listener The listener to receive the events
75- * @param <T> The type of the event
76- */
77- <T extends Event > void registerListener (PluginContainer plugin , TypeToken <T > eventType , EventListener <? super T > listener );
78-
79- /**
80- * Registers an event listener with the specified order for a specific event
81- * class.
82- *
83- * <p>Normally, the annotation-based way in
84- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
85- * method exists primarily to support dynamic event registration like needed
86- * in scripting plugins.</p>
87- *
88- * @param plugin The plugin instance
89- * @param eventClass The event to listen to
90- * @param order The order the listener will get called at
91- * @param listener The listener to receive the events
92- * @param <T> The type of the event
93- */
94- <T extends Event > void registerListener (PluginContainer plugin , Class <T > eventClass , Order order , EventListener <? super T > listener );
95-
96- /**
97- * Registers an event listener with the specified order for a specific event
98- * {@link TypeToken}.
99- *
100- * <p>Normally, the annotation-based way in
101- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
102- * method exists primarily to support dynamic event registration like needed
103- * in scripting plugins.</p>
104- *
105- * @param plugin The plugin instance
106- * @param eventType The event to listen to
107- * @param order The order the listener will get called at
108- * @param listener The listener to receive the events
109- * @param <T> The type of the event
110- */
111- <T extends Event > void registerListener (PluginContainer plugin , TypeToken <T > eventType , Order order , EventListener <? super T > listener );
112-
113- /**
114- * Registers an event listener with the specified order for a specific event
115- * class.
116- *
117- * <p>Normally, the annotation-based way in
118- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
119- * method exists primarily to support dynamic event registration like needed
120- * in scripting plugins.</p>
121- *
122- * @param plugin The plugin instance
123- * @param eventClass The event to listen to
124- * @param order The order the listener will get called at
125- * @param beforeModifications Whether to call the listener before other
126- * server modifications
127- * @param listener The listener to receive the events
128- * @param <T> The type of the event
129- */
130- <T extends Event > void registerListener (PluginContainer plugin , Class <T > eventClass , Order order , boolean beforeModifications ,
131- EventListener <? super T > listener );
132-
133- /**
134- * Registers an event listener with the specified order for a specific event
135- * class.
136- *
137- * <p>Normally, the annotation-based way in
138- * {@link #registerListeners(PluginContainer, Object)} should be preferred over this way. This
139- * method exists primarily to support dynamic event registration like needed
140- * in scripting plugins.</p>
141- *
142- * @param plugin The plugin instance
143- * @param eventType The event to listen to
144- * @param order The order the listener will get called at
145- * @param beforeModifications Whether to call the listener before other
146- * server modifications
147- * @param listener The listener to receive the events
148- * @param <T> The type of the event
149- */
150- <T extends Event > void registerListener (PluginContainer plugin , TypeToken <T > eventType , Order order , boolean beforeModifications ,
151- EventListener <? super T > listener );
53+ EventManager registerListeners (PluginContainer plugin , Object obj );
15254
15355 /**
15456 * Un-registers an object from receiving {@link Event}s.
15557 *
156- * @param obj The object
157- */
158- void unregisterListeners (Object obj );
159-
160- /**
161- * 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>
16260 *
163- * @param plugin The plugin instance
61+ * @param obj The object
62+ * @return This manager, for fluency
16463 */
165- void unregisterPluginListeners ( PluginContainer plugin );
64+ EventManager unregisterListeners ( Object obj );
16665
16766 /**
168- * Calls a {@link Event} to all listeners that listen to it.
67+ * Calls an {@link Event} to all listeners that listen to it.
16968 *
17069 * @param event The event
17170 * @return True if cancelled, false if not
0 commit comments