summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2024-06-04 23:01:35 +0200
committer zaaarf <me@zaaarf.foo>2024-06-04 23:01:35 +0200
commit3dc755f0c7b2385daddea1563ba91c727b37a07b (patch)
tree0c82834ea3fea66b224540d5d5914a95f691f49c
parent216159feecf779d86484764943495ec47c5a8ced (diff)
feat: isRegistered method on IBus
-rw-r--r--src/main/java/ftbsc/geb/GEB.java6
-rw-r--r--src/main/java/ftbsc/geb/api/IBus.java9
2 files changed, 14 insertions, 1 deletions
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<IListener> 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,12 +13,19 @@ 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
* @return false if the event was canceled, true otherwise