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

The following examples show how to use org.bukkit.event.Event#isAsynchronous() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@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
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 Project: LagMonitor   File: ThreadSafetyListener.java    License: 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 Project: LagMonitor   File: ThreadSafetyListener.java    License: 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);
    }
}