use of org.bukkit.event.HandlerList in project MassiveCore by MassiveCraft.
the class EventUtil method callEventAt.
public static void callEventAt(Event event, EventPriority priority) {
HandlerList handlers = event.getHandlers();
RegisteredListener[] listeners = handlers.getRegisteredListeners().clone();
for (RegisteredListener registration : listeners) {
try {
EventPriority thisPriority = (EventPriority) fieldRegisteredListenerDotPriority.get(registration);
if (thisPriority != priority)
continue;
} catch (Exception e) {
e.printStackTrace();
continue;
}
fireEventRegistration(event, registration);
}
}
use of org.bukkit.event.HandlerList in project MassiveCore by MassiveCraft.
the class EventUtil method callEventAfter.
public static void callEventAfter(Event event, Listener listener, EventPriority priority) {
HandlerList handlers = event.getHandlers();
RegisteredListener[] listeners = handlers.getRegisteredListeners().clone();
boolean run = false;
for (RegisteredListener registration : listeners) {
if (run) {
fireEventRegistration(event, registration);
} else {
try {
EventPriority thisPriority = (EventPriority) fieldRegisteredListenerDotPriority.get(registration);
Listener thisListener = (Listener) fieldRegisteredListenerDotListener.get(registration);
if (thisListener == listener && thisPriority == priority)
run = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.bukkit.event.HandlerList in project VoxelGamesLibv2 by VoxelGamesLib.
the class LoggedPluginManager method getEventListeners.
private HandlerList getEventListeners(Class<? extends Event> type) {
try {
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
} catch (Exception e) {
throw new IllegalPluginAccessException(e.toString());
}
}
use of org.bukkit.event.HandlerList in project Denizen-For-Bukkit by DenizenScript.
the class ServerTagBase method getHandlerPluginList.
public static ListTag getHandlerPluginList(Class eventClass) {
if (Event.class.isAssignableFrom(eventClass)) {
HandlerList handlers = BukkitScriptEvent.getEventListeners(eventClass);
if (handlers != null) {
ListTag result = new ListTag();
HashSet<String> deduplicationSet = new HashSet<>();
for (RegisteredListener listener : handlers.getRegisteredListeners()) {
if (deduplicationSet.add(listener.getPlugin().getName())) {
result.addObject(new PluginTag(listener.getPlugin()));
}
}
return result;
}
}
return null;
}
use of org.bukkit.event.HandlerList in project Dragonet-Legacy by DragonetMC.
the class MixedPluginManager method getEventListeners.
private HandlerList getEventListeners(Class<? extends Event> type) {
try {
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
} catch (Exception e) {
throw new IllegalPluginAccessException(e.toString());
}
}
Aggregations