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();
}
}
}
Aggregations