mirror of
https://github.com/zaaarf/geb.git
synced 2024-11-21 23:54:50 +01:00
fix: nullptr in case where event has no listeners
This commit is contained in:
parent
755a8e3a91
commit
216159feec
1 changed files with 4 additions and 1 deletions
|
@ -6,6 +6,7 @@ import ftbsc.geb.api.IEventDispatcher;
|
||||||
import ftbsc.geb.api.IListener;
|
import ftbsc.geb.api.IListener;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -69,6 +70,8 @@ public class GEB implements IBus {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean handleEvent(IEvent event) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue