Search in sources :

Example 1 with CREEventException

use of com.laytonsmith.core.exceptions.CRE.CREEventException in project CommandHelper by EngineHub.

the class EventUtils method FireListeners.

public static void FireListeners(SortedSet<BoundEvent> toRun, Event driver, BindableEvent e) {
    // Sort our event handlers by priorities
    BoundEvent.ActiveEvent activeEvent = new BoundEvent.ActiveEvent(e);
    for (BoundEvent b : toRun) {
        if (activeEvent.canReceive() || b.getPriority().equals(Priority.MONITOR)) {
            try {
                // We must re-set the active event's bound event and parsed event
                activeEvent.setBoundEvent(b);
                activeEvent.setParsedEvent(driver.evaluate(e));
                b.trigger(activeEvent);
            } catch (FunctionReturnException ex) {
            // We also know how to deal with this
            } catch (EventException ex) {
                throw new CREEventException(ex.getMessage(), Target.UNKNOWN, ex);
            } catch (ConfigRuntimeException ex) {
                // An exception has bubbled all the way up
                ConfigRuntimeException.HandleUncaughtException(ex, b.getEnvironment());
            }
        }
    }
    for (BoundEvent b : toRun) {
        activeEvent.setBoundEvent(b);
        if (activeEvent.isCancelled()) {
            activeEvent.executeCancelled();
        } else {
            activeEvent.executeTriggered();
        }
    }
}
Also used : EventException(com.laytonsmith.core.exceptions.EventException) CREEventException(com.laytonsmith.core.exceptions.CRE.CREEventException) CREEventException(com.laytonsmith.core.exceptions.CRE.CREEventException) FunctionReturnException(com.laytonsmith.core.exceptions.FunctionReturnException) ConfigRuntimeException(com.laytonsmith.core.exceptions.ConfigRuntimeException)

Aggregations

CREEventException (com.laytonsmith.core.exceptions.CRE.CREEventException)1 ConfigRuntimeException (com.laytonsmith.core.exceptions.ConfigRuntimeException)1 EventException (com.laytonsmith.core.exceptions.EventException)1 FunctionReturnException (com.laytonsmith.core.exceptions.FunctionReturnException)1