diff --git a/src/main/java/ftbsc/geb/GEB.java b/src/main/java/ftbsc/geb/GEB.java index 3a5adf0..969045f 100644 --- a/src/main/java/ftbsc/geb/GEB.java +++ b/src/main/java/ftbsc/geb/GEB.java @@ -63,6 +63,12 @@ public class GEB implements IBus { ); } + @Override + public boolean isRegistered(IListener listener) { + Set listeners = this.listenerMap.get(listener.getClass()); + return listeners != null && listeners.contains(listener); + } + /** * Dispatches an event, calling all of its listeners that are subscribed to this bus. * @param event the event to fire diff --git a/src/main/java/ftbsc/geb/api/IBus.java b/src/main/java/ftbsc/geb/api/IBus.java index 485cf74..867bf7a 100644 --- a/src/main/java/ftbsc/geb/api/IBus.java +++ b/src/main/java/ftbsc/geb/api/IBus.java @@ -13,11 +13,18 @@ public interface IBus { void registerListener(IListener listener); /** - * Unregister a listener from the bus. + * Unregisters a listener from the bus. * @param listener the listener */ void unregisterListener(IListener listener); + /** + * Tells you whether a listener is currently registered. + * Ideally this should be efficient. + * @return true if the listener is registered + */ + boolean isRegistered(IListener listener); + /** * Dispatches an event, calling all of its listeners that are subscribed to this bus. * @param event the event to fire