From d0e5ee4e09adf827ced252cc79e4228c0296a464 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Thu, 5 Sep 2013 21:59:31 -0700 Subject: [PATCH] Don't try to bake handlers when there are no more handlers. Remove them instead! --- .../java/net/md_5/bungee/event/EventBus.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/event/src/main/java/net/md_5/bungee/event/EventBus.java b/event/src/main/java/net/md_5/bungee/event/EventBus.java index 6df5870f..2d8f632d 100644 --- a/event/src/main/java/net/md_5/bungee/event/EventBus.java +++ b/event/src/main/java/net/md_5/bungee/event/EventBus.java @@ -176,22 +176,28 @@ public class EventBus private void bakeHandlers(Class eventClass) { Map> handlersByPriority = byListenerAndPriority.get( eventClass ); - List handlersList = new ArrayList<>( handlersByPriority.size() * 2 ); - for ( EventPriority value : EventPriority.values() ) + if ( handlersByPriority != null ) { - Map handlersByListener = handlersByPriority.get( value ); - if ( handlersByListener != null ) + List handlersList = new ArrayList<>( handlersByPriority.size() * 2 ); + for ( EventPriority value : EventPriority.values() ) { - for ( Map.Entry listenerHandlers : handlersByListener.entrySet() ) + Map handlersByListener = handlersByPriority.get( value ); + if ( handlersByListener != null ) { - for ( Method method : listenerHandlers.getValue() ) + for ( Map.Entry listenerHandlers : handlersByListener.entrySet() ) { - EventHandlerMethod ehm = new EventHandlerMethod( listenerHandlers.getKey(), method ); - handlersList.add( ehm ); + for ( Method method : listenerHandlers.getValue() ) + { + EventHandlerMethod ehm = new EventHandlerMethod( listenerHandlers.getKey(), method ); + handlersList.add( ehm ); + } } } } + byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ handlersList.size() ] ) ); + } else + { + byEventBaked.put( eventClass, null ); } - byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ handlersList.size() ] ) ); } }