diff options
-rw-r--r-- | src/main/java/ftbsc/geb/GEB.java | 9 | ||||
-rw-r--r-- | src/main/java/ftbsc/geb/api/IBus.java | 9 |
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 |