From 15fd1373cef7053b1af53a98d2b476d82a4f9b65 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Sun, 1 Sep 2024 12:54:33 +0200 Subject: [PATCH] feat: generic IEventDispatcher --- src/main/java/ftbsc/geb/api/IEventDispatcher.java | 7 ++++--- src/main/java/ftbsc/geb/api/annotations/Listen.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/ftbsc/geb/api/IEventDispatcher.java b/src/main/java/ftbsc/geb/api/IEventDispatcher.java index ef13f0b..c356284 100644 --- a/src/main/java/ftbsc/geb/api/IEventDispatcher.java +++ b/src/main/java/ftbsc/geb/api/IEventDispatcher.java @@ -7,19 +7,20 @@ import java.util.Set; * The interface that the generated dispatchers will all use. * This interface isn't really meant to be used by humans, but it should work if your * use case requires it. + * @param the event this is for * @since 0.1.1 */ -public interface IEventDispatcher { +public interface IEventDispatcher { /** * Calls all listeners for the given event. * @param event the event to call * @param listeners a map mapping each {@link IListener} class to its instances * @return the value {@link IBus#handleEvent(IEvent)} will return for this */ - boolean callListeners(IEvent event, Map, Set> listeners); + boolean callListeners(T event, Map, Set> listeners); /** * @return the {@link Class} representing the event this dispatcher works with */ - Class eventType(); + Class eventType(); } diff --git a/src/main/java/ftbsc/geb/api/annotations/Listen.java b/src/main/java/ftbsc/geb/api/annotations/Listen.java index a3643bf..ff00320 100644 --- a/src/main/java/ftbsc/geb/api/annotations/Listen.java +++ b/src/main/java/ftbsc/geb/api/annotations/Listen.java @@ -11,7 +11,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Marks the method as a listener. Its parent must implement the {@link IListener} interface + * Marks the method as a listener. + * If the method is not static, its parent must implement the {@link IListener} interface * and be registered an at least one GEB instance with {@link IBus#registerListener(IListener)}. * The annotated method should only take a single input value, an instance of {@link IEvent} or * {@link IEventCancelable}.