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 a6d717f2..b3effc8a 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 @@ -42,6 +42,8 @@ public class EventBus { for ( EventHandlerMethod method : handlers ) { + long start = System.nanoTime(); + try { method.invoke( event ); @@ -55,6 +57,15 @@ public class EventBus { logger.log( Level.WARNING, MessageFormat.format( "Error dispatching event {0} to listener {1}", event, method.getListener() ), ex.getCause() ); } + + long elapsed = System.nanoTime() - start; + if ( elapsed > 20000000 ) + { + logger.log( Level.WARNING, "Plugin listener {0} took {1}ms to process event {2}!", new Object[] + { + method.getListener().getClass().getName(), elapsed / 1000000, event + } ); + } } } }