mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-24 14:34:15 +08:00
Use computeIfAbsent in EventBus (#2138)
This commit is contained in:
parent
ed0a4c8cf4
commit
6f70da51f9
@ -31,8 +31,7 @@ public final class EventBus {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Event> EventManager<T> channel(Class<T> clazz) {
|
||||
events.putIfAbsent(clazz, new EventManager<>());
|
||||
return (EventManager<T>) events.get(clazz);
|
||||
return (EventManager<T>) events.computeIfAbsent(clazz, ignored -> new EventManager<>());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
Loading…
Reference in New Issue
Block a user