本文整理汇总了Java中org.bukkit.event.EventPriority.values方法的典型用法代码示例。如果您正苦于以下问题:Java EventPriority.values方法的具体用法?Java EventPriority.values怎么用?Java EventPriority.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.EventPriority
的用法示例。
在下文中一共展示了EventPriority.values方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.bukkit.event.EventPriority; //导入方法依赖的package包/类
@Override
public void run() {
Map<UUID, Boolean> clone = new HashMap<>(this.grounded);
for (Player player : Bukkit.getOnlinePlayers()) {
Boolean last = clone.get(player.getUniqueId());
boolean current = player.isOnGround();
if (last == null || last != current) {
PlayerOnGroundEvent call = new PlayerOnGroundEvent(player, current);
this.grounded.put(player.getUniqueId(), current);
for (EventPriority priority : EventPriority.values())
EventUtil.callEvent(call, PlayerOnGroundEvent.getHandlerList(), priority);
}
}
// Remove players who have logged out
for (UUID uuid : clone.keySet()) {
if (Bukkit.getPlayer(uuid) == null)
this.grounded.remove(uuid);
}
}
示例2: enable
import org.bukkit.event.EventPriority; //导入方法依赖的package包/类
@Override
public void enable() {
// Find all the @EventWrapper methods in this class and register them at EVERY priority level.
for(final Method method : Methods.annotatedMethods(getClass(), EventWrapper.class)) {
final Class<? extends Event> eventClass = method.getParameterTypes()[0].asSubclass(Event.class);
for(final EventPriority priority : EventPriority.values()) {
Event.register(eventRegistry.bindHandler(new EventHandlerMeta<>(eventClass, priority, false), this, (listener, event) -> {
// Ignore events from non-match worlds
if(matchFinder.getMatch(event) == null) return;
if(!BukkitEvents.isCancelled(event)) {
// At the first priority level, call the event handler method.
// If it decides to generate a BlockTransformEvent, it will be stored in currentEvents.
if(priority == EventPriority.LOWEST) {
if(eventClass.isInstance(event)) {
try {
method.invoke(listener, event);
} catch (InvocationTargetException ex) {
throw new EventException(ex.getCause(), event);
} catch (Throwable t) {
throw new EventException(t, event);
}
}
}
}
// Check for cached events and dispatch them at the current priority level only.
// The BTE needs to be dispatched even after it's cancelled, because we DO have
// listeners that depend on receiving cancelled events e.g. WoolMatchModule.
for(BlockTransformEvent bte : currentEvents.get(event)) {
eventBus.callEvent(bte, priority);
}
// After dispatching the last priority level, clean up the cached events and do post-event stuff.
// This needs to happen even if the event is cancelled.
if(priority == EventPriority.MONITOR) {
finishCauseEvent(event);
}
}));
}
}
}
示例3: PriorityListener
import org.bukkit.event.EventPriority; //导入方法依赖的package包/类
public PriorityListener(int priority) {
this.priority = EventPriority.values()[priority];
}