Java 类org.bukkit.plugin.IllegalPluginAccessException 实例源码

项目:VoxelGamesLibv2    文件:LoggedPluginManager.java   
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;

    } catch (NoSuchMethodException e) {
        if ((clazz.getSuperclass() != null)
                && (!clazz.getSuperclass().equals(Event.class))
                && (Event.class.isAssignableFrom(clazz.getSuperclass()))) {
            return getRegistrationClass(clazz.getSuperclass().asSubclass(
                    Event.class));
        }
    }
    throw new IllegalPluginAccessException(
            "Unable to find handler list for event " + clazz.getName());
}
项目:ExilePearl    文件:TestPluginManager.java   
@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));
       }
}
项目:Uranium    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:VoxelGamesLibv2    文件:LoggedPluginManager.java   
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());
    }
}
项目:ThermosRebased    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Brynhildr    文件:NukkitScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:ExilePearl    文件:TestPluginManager.java   
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());
    }
}
项目:ExilePearl    文件:TestPluginManager.java   
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;
    } catch (NoSuchMethodException e) {
        if (clazz.getSuperclass() != null
                && !clazz.getSuperclass().equals(Event.class)
                && Event.class.isAssignableFrom(clazz.getSuperclass())) {
            return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
        } else {
            throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName() + ". Static getHandlerList method required!");
        }
    }
}
项目:Pokkit    文件:BukkitEventManager.java   
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());
    }
}
项目:Pokkit    文件:BukkitEventManager.java   
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;
    } catch (NoSuchMethodException e) {
        if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(Event.class)
                && Event.class.isAssignableFrom(clazz.getSuperclass())) {
            return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
        } else {
            throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName()
                    + ". Static getHandlerList method required!");
        }
    }
}
项目:Pokkit    文件:BukkitEventManager.java   
public void registerEvents(Listener listener, Plugin plugin) {
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled");
    }

    for (Map.Entry<Class<? extends Event>, Set<RegisteredListener>> entry : plugin.getPluginLoader()
            .createRegisteredListeners(listener, plugin).entrySet()) {
        getEventListeners(getRegistrationClass(entry.getKey())).registerAll(entry.getValue());
    }

}
项目:Thermos    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:KCauldron    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:CauldronGit    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Cauldron-Old    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Cauldron-Reloaded    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:FFoKC    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:CraftBukkit    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Craftbukkit    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:NovaGuilds    文件:LoggedPluginManager.java   
/**
 * Gets event listeners
 *
 * @param type event type
 * @return handler list
 */
private HandlerList getEventListeners(Class<? extends Event> type) {
    try {
        Method method = Reflections.getMethod(type, "getHandlerList");
        method.setAccessible(true);
        return (HandlerList) method.invoke(null);
    }
    catch(Exception e) {
        throw new IllegalPluginAccessException(e.toString());
    }
}
项目:NovaGuilds    文件:LoggedPluginManager.java   
/**
 * Gets registration class
 *
 * @param clazz event class
 * @return the class
 */
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;

    }
    catch(NoSuchMethodException e) {
        if((clazz.getSuperclass() != null) && (!clazz.getSuperclass().equals(Event.class)) && (Event.class.isAssignableFrom(clazz.getSuperclass()))) {
            return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
        }
    }
    throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());
}
项目:Reporter    文件:BukkitUtil.java   
/**
 * Gets a Bukkit plugin.
 *
 * @param plugin The name of the plugin to get.
 * @return A Bukkit plugin.
 */
public static Plugin getPlugin(final String plugin) {
    if (!Bukkit.getPluginManager().isPluginEnabled(plugin)) {
        throw new IllegalPluginAccessException(String.format("The plugin [%s] is not enabled!", plugin));
    }
    return Bukkit.getPluginManager().getPlugin(plugin);
}
项目:Reporter    文件:BukkitUtilTest.java   
@Test(expected = IllegalPluginAccessException.class)
public void testGetPluginNotFound() {
    final String pluginName = "Test plugin";
    final PluginManager pluginManager = mock(PluginManager.class);
    when(pluginManager.isPluginEnabled(pluginName)).thenReturn(false);
    mockStatic(Bukkit.class);
    when(Bukkit.getPluginManager()).thenReturn(pluginManager);

    try {
        BukkitUtil.getPlugin(pluginName);
    } finally {
        verify(pluginManager).isPluginEnabled(pluginName);
        verifyStatic();
    }
}
项目:Almura-Server    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:VarScript    文件:BukkitEventTrigger.java   
private static Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;
    } catch (NoSuchMethodException e) {
        if (clazz.getSuperclass() != null
                && !clazz.getSuperclass().equals(Event.class)
                && Event.class.isAssignableFrom(clazz.getSuperclass())) {
            return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
        } else {
            throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());
        }
    }
}
项目:VarScript    文件:BukkitEventTrigger.java   
private static HandlerList getHandlerList(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());
    }
}
项目:Tweakkit-Server    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Cauldron    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Pore    文件:PoreBukkitScheduler.java   
private static void validate(Plugin plugin, Object task) {
    Preconditions.checkState(plugin != null, "Plugin is null");
    Preconditions.checkNotNull(task, "task");
    //noinspection ConstantConditions
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:SpigotSource    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:Reporter    文件:BukkitUtil.java   
/**
 * Gets a Bukkit plugin.
 *
 * @param plugin The name of the plugin to get.
 * @return A Bukkit plugin.
 */
public static Plugin getPlugin(final String plugin) {
    if (!Bukkit.getPluginManager().isPluginEnabled(plugin)) {
        throw new IllegalPluginAccessException(String.format("The plugin [%s] is not enabled!", plugin));
    }
    return Bukkit.getPluginManager().getPlugin(plugin);
}
项目:Reporter    文件:BukkitUtilTest.java   
@Test(expected = IllegalPluginAccessException.class)
public void testGetPluginNotFound() {
    final String pluginName = "Test plugin";
    final PluginManager pluginManager = mock(PluginManager.class);
    when(pluginManager.isPluginEnabled(pluginName)).thenReturn(false);
    mockStatic(Bukkit.class);
    when(Bukkit.getPluginManager()).thenReturn(pluginManager);

    try {
        BukkitUtil.getPlugin(pluginName);
    } finally {
        verify(pluginManager).isPluginEnabled(pluginName);
        verifyStatic();
    }
}
项目:Craft-city    文件:CraftScheduler.java   
private static void validate(final Plugin plugin, final Object task) {
    Validate.notNull(plugin, "Plugin cannot be null");
    Validate.notNull(task, "Task cannot be null");
    if (!plugin.isEnabled()) {
        throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
    }
}
项目:UltimateSurvivalGames    文件:UserManager.java   
public void setState(Player p, UserState state) {
    p.teleport(state.getLocation());
    p.setFallDistance(state.getFallDistance());
    p.setGameMode(state.getGameMode());
    p.setAllowFlight(state.getAllowFlight());
    p.setFlying(state.isFlying());
    p.setLevel(state.getLevel());
    p.setExp(state.getExp());
    p.setFireTicks(state.getFireTicks());
    p.setMaxHealth(state.getMaxHealth());
    p.setHealth(state.getHealth());
    p.setFoodLevel(state.getFoodLevel());
    p.setWalkSpeed(state.getWalkSpeed());
    p.setFlySpeed(state.getFlySpeed());

    for (Iterator<PotionEffect> i = p.getActivePotionEffects().iterator(); i.hasNext();) {
        p.removePotionEffect(i.next().getType());
    }
    p.addPotionEffects(state.getActivePotionEffects());
    p.getInventory().setHeldItemSlot(state.getHeldItemSlot());

    final String name = p.getName();
    final ItemStack[] contents = state.getContents();
    final ItemStack[] armorcontents = state.getArmorContents();

    try {
        Bukkit.getScheduler().scheduleSyncDelayedTask(SurvivalGames.instance, new Runnable() {
            public void run() {
                Player fp = Bukkit.getPlayer(name);

                if(fp != null) {
                    fp.getInventory().setContents(contents);
                    fp.getInventory().setArmorContents(armorcontents);
                    fp.updateInventory();
                }
            }
        }, 2L);
    } catch(IllegalPluginAccessException e) {
        p.getInventory().setContents(contents);
        p.getInventory().setArmorContents(armorcontents);
        p.updateInventory();
    }
}
项目:Pokkit    文件:BukkitEventManager.java   
/**
 * 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
 */
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");
    }

    getEventListeners(event)
            .register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
}