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

The following examples show how to use org.bukkit.event.Event#isAsynchronous() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimedRegisteredListener.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void callEvent(Event event) throws EventException {
    if (event.isAsynchronous()) {
        super.callEvent(event);
        return;
    }
    count++;
    Class<? extends Event> newEventClass = event.getClass();
    if (this.eventClass == null) {
        this.eventClass = newEventClass;
    } else if (!this.eventClass.equals(newEventClass)) {
        multiple = true;
        this.eventClass = getCommonSuperclass(newEventClass, this.eventClass).asSubclass(Event.class);
    }
    long start = System.nanoTime();
    super.callEvent(event);
    totalTime += System.nanoTime() - start;
}
 
Example 2
Source File: Sniper.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
private void callEvent(Event event) {
    if (Fawe.isMainThread()) {
        Bukkit.getPluginManager().callEvent(event);
    } else {
        if (event.isAsynchronous()) {
            Bukkit.getPluginManager().callEvent(event);
        } else {
            try {
                PluginManager plm = Bukkit.getPluginManager();
                Class<? extends PluginManager> clazz = plm.getClass();
                Method methodFireEvent = clazz.getDeclaredMethod("fireEvent", Event.class);
                methodFireEvent.setAccessible(true);
                methodFireEvent.invoke(plm, event);
            } catch (Throwable ignore) {}
        }
    }
}
 
Example 3
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 5 votes vote down vote up
private void checkSafety(Event eventType) {
    //async executing of sync event
    String eventName = eventType.getEventName();
    if (!eventType.isAsynchronous()) {
        actionManager.checkThreadSafety(eventName);
    }
}
 
Example 4
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 5 votes vote down vote up
private void checkSafety(Event eventType) {
    //async executing of sync event
    String eventName = eventType.getEventName();
    if (!eventType.isAsynchronous()) {
        actionManager.checkThreadSafety(eventName);
    }
}