mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 12:46:05 +01:00
#3221: Use computeIfAbsent method in EventBus
This commit is contained in:
parent
51eb1ac623
commit
2479fab632
@ -88,18 +88,8 @@ public class EventBus
|
||||
} );
|
||||
continue;
|
||||
}
|
||||
Map<Byte, Set<Method>> prioritiesMap = handler.get( params[0] );
|
||||
if ( prioritiesMap == null )
|
||||
{
|
||||
prioritiesMap = new HashMap<>();
|
||||
handler.put( params[0], prioritiesMap );
|
||||
}
|
||||
Set<Method> priority = prioritiesMap.get( annotation.priority() );
|
||||
if ( priority == null )
|
||||
{
|
||||
priority = new HashSet<>();
|
||||
prioritiesMap.put( annotation.priority(), priority );
|
||||
}
|
||||
Map<Byte, Set<Method>> prioritiesMap = handler.computeIfAbsent( params[0], k -> new HashMap<>() );
|
||||
Set<Method> priority = prioritiesMap.computeIfAbsent( annotation.priority(), k -> new HashSet<>() );
|
||||
priority.add( m );
|
||||
}
|
||||
}
|
||||
@ -114,20 +104,10 @@ public class EventBus
|
||||
{
|
||||
for ( Map.Entry<Class<?>, Map<Byte, Set<Method>>> e : handler.entrySet() )
|
||||
{
|
||||
Map<Byte, Map<Object, Method[]>> prioritiesMap = byListenerAndPriority.get( e.getKey() );
|
||||
if ( prioritiesMap == null )
|
||||
{
|
||||
prioritiesMap = new HashMap<>();
|
||||
byListenerAndPriority.put( e.getKey(), prioritiesMap );
|
||||
}
|
||||
Map<Byte, Map<Object, Method[]>> prioritiesMap = byListenerAndPriority.computeIfAbsent( e.getKey(), k -> new HashMap<>() );
|
||||
for ( Map.Entry<Byte, Set<Method>> entry : e.getValue().entrySet() )
|
||||
{
|
||||
Map<Object, Method[]> currentPriorityMap = prioritiesMap.get( entry.getKey() );
|
||||
if ( currentPriorityMap == null )
|
||||
{
|
||||
currentPriorityMap = new HashMap<>();
|
||||
prioritiesMap.put( entry.getKey(), currentPriorityMap );
|
||||
}
|
||||
Map<Object, Method[]> currentPriorityMap = prioritiesMap.computeIfAbsent( entry.getKey(), k -> new HashMap<>() );
|
||||
currentPriorityMap.put( listener, entry.getValue().toArray( new Method[ 0 ] ) );
|
||||
}
|
||||
bakeHandlers( e.getKey() );
|
||||
|
Loading…
Reference in New Issue
Block a user