summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2024-06-02 17:11:06 +0200
committer zaaarf <me@zaaarf.foo>2024-06-02 17:11:42 +0200
commit216159feecf779d86484764943495ec47c5a8ced (patch)
tree39a2b42fdc89887bf27e0ef9e8b26f3690b1fdd6
parent755a8e3a91153c865e95c3753318bd60bab49270 (diff)
fix: nullptr in case where event has no listeners0.3.1
-rw-r--r--src/main/java/ftbsc/geb/GEB.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/ftbsc/geb/GEB.java b/src/main/java/ftbsc/geb/GEB.java
index 86e9be5..3a5adf0 100644
--- a/src/main/java/ftbsc/geb/GEB.java
+++ b/src/main/java/ftbsc/geb/GEB.java
@@ -6,6 +6,7 @@ import ftbsc.geb.api.IEventDispatcher;
import ftbsc.geb.api.IListener;
import java.util.Map;
+import java.util.Optional;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -69,6 +70,8 @@ public class GEB implements IBus {
*/
@Override
public boolean handleEvent(IEvent event) {
- return this.dispatchMap.get(event.getClass()).callListeners(event, this.listenerMap);
+ return Optional.ofNullable(this.dispatchMap.get(event.getClass()))
+ .map(dispatcher -> dispatcher.callListeners(event, this.listenerMap))
+ .orElse(true);
}
}