summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-08-23 23:50:24 +0200
committer zaaarf <zaaarf@proton.me>2023-08-23 23:50:24 +0200
commitb68b0cb0f6468d9b085338d271ab6d1e6dbff3d8 (patch)
tree5bc6e45bb2db4106a47b968415e1744a7644bbdb
parentfd87c90d636b98f398b2f40cca83305cb0316e4e (diff)
feat: unregisterListener0.2.0origin/dev
-rw-r--r--src/main/java/ftbsc/geb/GEB.java9
-rw-r--r--src/main/java/ftbsc/geb/api/IBus.java9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/geb/GEB.java b/src/main/java/ftbsc/geb/GEB.java
index 31a88c0..4d802f6 100644
--- a/src/main/java/ftbsc/geb/GEB.java
+++ b/src/main/java/ftbsc/geb/GEB.java
@@ -44,6 +44,15 @@ public class GEB implements IBus {
}
/**
+ * Unregister a listener from the bus.
+ * @param listener the listener
+ */
+ @Override
+ public void unregisterListener(IListener listener) {
+ this.listenerMap.remove(listener.getClass());
+ }
+
+ /**
* Dispatches an event, calling all of its listeners that are subscribed to this bus.
* @param event the event to fire
* @return true if the event was canceled, false otherwise
diff --git a/src/main/java/ftbsc/geb/api/IBus.java b/src/main/java/ftbsc/geb/api/IBus.java
index 6a56243..f27004b 100644
--- a/src/main/java/ftbsc/geb/api/IBus.java
+++ b/src/main/java/ftbsc/geb/api/IBus.java
@@ -13,6 +13,15 @@ public interface IBus {
void registerListener(IListener listener);
/**
+ * Unregister a listener from the bus.
+ * While sensible implementations can get this quite fast, it's generally
+ * faster to use {@link IListener#isActive()}, so only use this if you
+ * *mean* to unregister for good.
+ * @param listener the listener
+ */
+ void unregisterListener(IListener listener);
+
+ /**
* Dispatches an event, calling all of its listeners that are subscribed to this bus.
* @param event the event to fire
* @return true if the event was canceled, false otherwise