本文整理汇总了Java中org.bukkit.plugin.EventExecutor类的典型用法代码示例。如果您正苦于以下问题:Java EventExecutor类的具体用法?Java EventExecutor怎么用?Java EventExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventExecutor类属于org.bukkit.plugin包,在下文中一共展示了EventExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEventTimingsByPlugin
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public static Map<String, MonitorRecord> getEventTimingsByPlugin(Plugin plg) {
Map<String, MonitorRecord> record = new HashMap<>();
if (plg == null) {
return record;
}
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
try {
FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor", EventExecutor.class);
EventExecutor executor = field.get(listener);
if (executor instanceof EventExecutorInjector) {
EventExecutorInjector eventExecutorInjector = (EventExecutorInjector) executor;
String eventName = eventExecutorInjector.getEventName();
if (eventName != null) {
MonitorRecord monitorRecord = getMonitorRecord(eventName, eventExecutorInjector.getTotalTime(), eventExecutorInjector.getTotalCount(),
eventExecutorInjector.getMaxExecuteTime());
if (record.containsKey(eventName)) {
MonitorRecord otherMonitorRecord = record.get(eventName);
record.put(eventName, otherMonitorRecord.merge(monitorRecord));
} else {
record.put(eventName, monitorRecord);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return record;
}
示例2: inject
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
/**
*
* @author jiongjionger,Vlvxingze
*/
// 将监听器原本的EventExecutor替换成带性能统计的版本
public static void inject(Plugin plg) {
if (plg != null) {
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
try {
FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor", EventExecutor.class);
EventExecutor fieldEventExecutor = field.get(listener);
field.set(listener, new EventExecutorInjector(plg, fieldEventExecutor));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例3: registerEvent
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
@Override
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled) {
Validate.notNull(listener, "Listener cannot be null");
Validate.notNull(priority, "Priority cannot be null");
Validate.notNull(executor, "Executor cannot be null");
Validate.notNull(plugin, "Plugin cannot be null");
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
}
if (useTimings) {
getEventListeners(event).register(new TimedRegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
} else {
getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
}
}
示例4: getEventTimingsByPlugin
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public static Map<String, MonitorRecord> getEventTimingsByPlugin(Plugin plg) {
Map<String, MonitorRecord> record = new HashMap<>();
if (plg == null) {
return record;
}
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
try {
FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor",
EventExecutor.class);
EventExecutor executor = field.get(listener);
if (executor instanceof EventExecutorInjector) {
EventExecutorInjector eventExecutorInjector = (EventExecutorInjector) executor;
String eventName = eventExecutorInjector.getEventName();
if (eventName != null) {
MonitorRecord monitorRecord = getMonitorRecord(eventName, eventExecutorInjector.getTotalTime(),
eventExecutorInjector.getTotalCount(), eventExecutorInjector.getMaxExecuteTime());
if (record.containsKey(eventName)) {
MonitorRecord otherMonitorRecord = record.get(eventName);
record.put(eventName, otherMonitorRecord.merge(monitorRecord));
} else {
record.put(eventName, monitorRecord);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return record;
}
示例5: tryRegisterEvent
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
private static void tryRegisterEvent(Listener listener, Method method, AutoEventHandler eventHandler, Plugin plugin) {
final Annotation[][] parameterAnnotations = method.getParameterAnnotations();
final Class<?>[] parameterTypes = method.getParameterTypes();
if(parameterTypes.length == 0 || !Event.class.isAssignableFrom(parameterTypes[0])) {
Bukkit.getLogger().severe(plugin.getDescription().getFullName() + " attempted to register an invalid AutoEventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass());
return;
} else if(parameterTypes.length == 1) {
Bukkit.getLogger().warning(plugin.getDescription().getFullName() + " attempted to register an EventHandler method signature \"" + method.toGenericString() + "\" as AutoEventHandler in " + listener.getClass());
}
final Class<? extends Event> eventType = parameterTypes[0].asSubclass(Event.class);
final MethodHandle mainHandle;
try {
mainHandle = MethodHandles.lookup().unreflect(method);
} catch (IllegalAccessException e) {
return;
}
final MethodHandle[] handles = getParameterHandles(listener, method, plugin, parameterAnnotations, parameterTypes, eventType);
if (handles == null) return;
EventExecutor executor = createEventExecutor(parameterTypes, eventType, mainHandle, handles);
Bukkit.getPluginManager().registerEvent(eventType, listener, eventHandler.priority(), executor, plugin, eventHandler.ignoreCancelled());
}
示例6: uninject
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public static void uninject(Plugin plg) {
if (plg != null) {
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
try {
FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor", EventExecutor.class);
EventExecutor executor = field.get(listener);
if (executor instanceof EventExecutorInjector) {
field.set(listener, ((EventExecutorInjector) executor).getEventExecutor());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例7: inject
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public static void inject(Plugin plg) {
if (plg != null) {
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
try {
FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor", EventExecutor.class);
EventExecutor fieldEventExecutor = field.get(listener);
field.set(listener, new EventExecutorInjector(plg, fieldEventExecutor));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例8: EventListener
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public EventListener(OurTown pl) {
this.plugin = pl;
pl.getServer().getPluginManager().registerEvents(this, pl);
if (plugin.config.handle_player_respawn) {
plugin.getServer().getPluginManager().registerEvent(PlayerRespawnEvent.class, this,
plugin.config.respawn_listener_priority, new EventExecutor() {
@Override
public void execute(Listener listener, Event event) throws EventException {
((EventListener) listener).onPlayerRespawn((PlayerRespawnEvent) event);
}
}, plugin, true);
}
}
示例9: inject
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public static void inject(Plugin plugin) {
List<RegisteredListener> listeners = HandlerList.getRegisteredListeners(plugin);
for (RegisteredListener listener : listeners) {
HandlerList.unregisterAll(listener.getListener());
FieldAccessor<EventExecutor> executorField = Reflection
.getField(RegisteredListener.class, "executor", EventExecutor.class);
EventExecutor originalExecutor = executorField.get(listener);
ListenerInjector listenerInjector = new ListenerInjector(originalExecutor);
executorField.set(listener, listenerInjector);
}
}
示例10: uninject
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public static void uninject(Plugin plugin) {
List<RegisteredListener> listeners = HandlerList.getRegisteredListeners(plugin);
for (RegisteredListener listener : listeners) {
HandlerList.unregisterAll(listener.getListener());
FieldAccessor<EventExecutor> executorField = Reflection
.getField(RegisteredListener.class, "executor", EventExecutor.class);
EventExecutor executor = executorField.get(listener);
if (executor instanceof ListenerInjector) {
executorField.set(listener, ((ListenerInjector) executor).originalExecutor);
}
}
}
示例11: registerEvent
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
@Override
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority,
EventExecutor executor, Plugin plugin) {
catchError(plugin, () -> delegate
.registerEvent(event, listener, priority, getWrappedExecutor(executor), plugin));
}
示例12: registerChatEvent
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public final static void registerChatEvent(final EventPriority priority, final EventExecutor executor, final boolean ignoreCancelled) {
if (Skript.classExists("org.bukkit.event.player.AsyncPlayerChatEvent"))
Bukkit.getPluginManager().registerEvent(AsyncPlayerChatEvent.class, new Listener() {}, priority, executor, Skript.getInstance(), ignoreCancelled);
else
Bukkit.getPluginManager().registerEvent(PlayerChatEvent.class, new Listener() {}, priority, executor, Skript.getInstance(), ignoreCancelled);
}
示例13: registerEvent
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
@Override
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin) {
pm.registerEvent(event, listener, priority, executor, plugin);
}
示例14: TimedRegisteredListener
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public TimedRegisteredListener(Listener pluginListener, EventExecutor eventExecutor, EventPriority eventPriority, Plugin registeredPlugin, boolean listenCancelled) {
super(pluginListener, eventExecutor, eventPriority, registeredPlugin, listenCancelled);
}
示例15: EventExecutorInjector
import org.bukkit.plugin.EventExecutor; //导入依赖的package包/类
public EventExecutorInjector(Plugin plugin, EventExecutor eventExecutor) {
super(plugin);
this.eventExecutor = eventExecutor;
}