From 3fe72154a30b3e2362a7c4dc4e7a62e58c323acd Mon Sep 17 00:00:00 2001 From: PunKeel Date: Sun, 19 Jun 2016 16:48:49 +0200 Subject: [PATCH] Fix slow event detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Time moves forward, so the second call to nanoTime returns a bigger number than the first one, giving a negative elapsed time … defeating the whole purpose of this code. :-( --- .../main/java/net/md_5/bungee/api/plugin/PluginManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index 2426bdb4..44b496a4 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -377,10 +377,10 @@ public class PluginManager eventBus.post( event ); event.postCall(); - long elapsed = start - System.nanoTime(); - if ( elapsed > 250000 ) + long elapsed = System.nanoTime() - start; + if ( elapsed > 1000000 ) { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "Event {0} took more {1}ns to process!", new Object[] + ProxyServer.getInstance().getLogger().log( Level.WARNING, "Event {0} took more {1} than ns to process!", new Object[] { event, elapsed } );