本文整理汇总了Java中org.spongepowered.api.event.impl.AbstractEvent类的典型用法代码示例。如果您正苦于以下问题:Java AbstractEvent类的具体用法?Java AbstractEvent怎么用?Java AbstractEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractEvent类属于org.spongepowered.api.event.impl包,在下文中一共展示了AbstractEvent类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: post
import org.spongepowered.api.event.impl.AbstractEvent; //导入依赖的package包/类
private boolean post(Event event, Collection<RegisteredListener<?>> listeners,
ThrowableConsumer<RegisteredListener, Exception> handler) {
checkNotNull(event, "event");
final CauseStack causeStack = CauseStack.currentOrEmpty();
for (RegisteredListener listener : listeners) {
// Add the calling plugin to the cause stack
causeStack.pushCause(listener.getPlugin());
try (CauseStack.Frame ignored = causeStack.pushCauseFrame()) {
if (event instanceof AbstractEvent) {
((AbstractEvent) event).currentOrder = listener.getOrder();
}
handler.accept(listener);
} catch (Throwable e) {
this.logger.error("Could not pass {} to {}", event.getClass().getSimpleName(),
listener.getPlugin(), e);
}
causeStack.popCause();
}
if (event instanceof AbstractEvent) {
((AbstractEvent) event).currentOrder = null;
}
return event instanceof Cancellable && ((Cancellable) event).isCancelled();
}