Search in sources :

Example 1 with IllegalPluginAccessException

use of org.bukkit.plugin.IllegalPluginAccessException 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());
    }
}
Also used : HandlerList(org.bukkit.event.HandlerList) IllegalPluginAccessException(org.bukkit.plugin.IllegalPluginAccessException) Method(java.lang.reflect.Method) UnknownDependencyException(org.bukkit.plugin.UnknownDependencyException) InvalidDescriptionException(org.bukkit.plugin.InvalidDescriptionException) MalformedURLException(java.net.MalformedURLException) IllegalPluginAccessException(org.bukkit.plugin.IllegalPluginAccessException) AuthorNagException(org.bukkit.plugin.AuthorNagException) InvalidPluginException(org.bukkit.plugin.InvalidPluginException)

Example 2 with IllegalPluginAccessException

use of org.bukkit.plugin.IllegalPluginAccessException in project Dragonet-Legacy by DragonetMC.

the class MixedPluginManager method registerEvent.

/**
     * Registers the given event to the specified listener using a directly
     * passed EventExecutor
     *
     * @param event Event class to register
     * @param listener PlayerListener to register
     * @param priority Priority of this event
     * @param executor EventExecutor to register
     * @param plugin Plugin to register
     * @param ignoreCancelled Do not call executor if event was already
     *     cancelled
     */
@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));
    }
}
Also used : IllegalPluginAccessException(org.bukkit.plugin.IllegalPluginAccessException) TimedRegisteredListener(org.bukkit.plugin.TimedRegisteredListener) TimedRegisteredListener(org.bukkit.plugin.TimedRegisteredListener) RegisteredListener(org.bukkit.plugin.RegisteredListener)

Aggregations

IllegalPluginAccessException (org.bukkit.plugin.IllegalPluginAccessException)2 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 HandlerList (org.bukkit.event.HandlerList)1 AuthorNagException (org.bukkit.plugin.AuthorNagException)1 InvalidDescriptionException (org.bukkit.plugin.InvalidDescriptionException)1 InvalidPluginException (org.bukkit.plugin.InvalidPluginException)1 RegisteredListener (org.bukkit.plugin.RegisteredListener)1 TimedRegisteredListener (org.bukkit.plugin.TimedRegisteredListener)1 UnknownDependencyException (org.bukkit.plugin.UnknownDependencyException)1