Skip to content

Commit

Permalink
feat: isRegistered method on IBus
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaarf committed Jun 4, 2024
1 parent 216159f commit 3dc755f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/java/ftbsc/geb/GEB.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void unregisterListener(IListener listener) {
);
}

@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
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/ftbsc/geb/api/IBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3dc755f

Please sign in to comment.