Java Code Examples for org.bukkit.event.Event.isAsynchronous()

The following are Jave code examples for showing how to use isAsynchronous() of the org.bukkit.event.Event class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: EscapeLag   File: EventExecutorInjector.java   Source Code and License Vote up 6 votes
@Override
// 计算调用次数和花费总时间以及花费最多的时间
public void execute(Listener listener, Event e) throws EventException {
	if (e.isAsynchronous()) {
		this.eventExecutor.execute(listener, e);
	} else {
		long startTime = System.nanoTime();
		try {
			try{
				this.eventExecutor.execute(listener, e);
			}catch(Throwable ex){
				MonitorUtils.AExceptionCatcher(plugin, ex);
			}
		} finally {
			long endTime = System.nanoTime();
			long executeTime = endTime - startTime;
			if(ConfigFunction.MonitorPluginLagWarningenable){
				if(executeTime/1000000 > ConfigFunction.MonitorPluginLagWarningPeriod){
					AzureAPI.log("警告!服务器主线程陷入停顿超过配置设定值!因为插件" + this.getPlugin().getName() + " 执行了一次耗时 " + executeTime/1000000 + " 毫秒的位于 " + listener.getClass().getName() + " 的监听器 " + e.getEventName() + " 的操作!");
				}
			}
			this.record(e.getEventName(), executeTime);
		}
	}
}
 
Example 2
Project: NeverLag   File: EventExecutorInjector.java   Source Code and License Vote up 6 votes
@Override
// 计算调用次数和花费总时间以及花费最多的时间
public void execute(Listener listener, Event e) throws EventException {
	if (e.isAsynchronous()) {
		this.eventExecutor.execute(listener, e);
	} else {
		long startTime = System.nanoTime();
		try {
			this.eventExecutor.execute(listener, e);
		} finally {
			long endTime = System.nanoTime();
			long executeTime = endTime - startTime;
			this.record(e.getEventName(), executeTime);
		}
	}
}