当前位置: 首页>>代码示例>>Java>>正文


Java EventPriority.values方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:24,代码来源:OnGroundTask.java

示例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);
                }
            }));
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:44,代码来源:BlockTransformListener.java

示例3: PriorityListener

import org.bukkit.event.EventPriority; //导入方法依赖的package包/类
public PriorityListener(int priority) {
  this.priority = EventPriority.values()[priority];
}
 
开发者ID:btk5h,项目名称:skript-mirror,代码行数:4,代码来源:EvtByReflection.java


注:本文中的org.bukkit.event.EventPriority.values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。