Try and prevent inefficient plugins by nagging when events take longer than 0.25ms to process. Someone let me know if this spams and I need to increase the max time.

This commit is contained in:
md_5 2013-03-19 17:21:54 +11:00
parent 5a15d5387c
commit 2bae6cafc2

View File

@ -19,6 +19,7 @@ import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.event.LoginEvent;
import org.yaml.snakeyaml.Yaml;
/**
@ -226,7 +227,17 @@ public class PluginManager
*/
public <T extends Event> T callEvent(T event)
{
long start = System.nanoTime();
eventBus.post( event );
// TODO: No exceptions!
if ( !( event instanceof LoginEvent ) )
{
long elapsed = start - System.nanoTime();
if ( elapsed > 250000 )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Event {0} took more than 0.25ms to process!", event );
}
}
return event;
}