Solved IllegalPluginAccessException

Discussion in 'Plugin Help/Development/Requests' started by BizarrePlatinum, May 2, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    BizarrePlatinum

    Code:
    public void onEnable() {
            this.plugin = this;
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    if(Bukkit.getServer().getWorld("world").getTime() >= 18000 && Bukkit.getServer().getOnlinePlayers() != null) {
                        for(Player all : Bukkit.getServer().getOnlinePlayers()) {
                            if(!all.isSleeping() && !tiredLevel.containsKey(all) && !all.getGameMode().equals(GameMode.CREATIVE)) {
                                all.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10000, 2));
                                all.sendMessage(ChatColor.RED + "You grow tired. You must sleep!");
                                tiredLevel.put(all, 1);
                            }
                        }
                        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                            public void run() {
                                if(Bukkit.getServer().getWorld("world").getTime() > 18000) {
                                    for(Player all : Bukkit.getServer().getOnlinePlayers()) {
                                        if(!all.isSleeping() && tiredLevel.get(all) == 1 && !all.getGameMode().equals(GameMode.CREATIVE)) {
                                            all.removePotionEffect(PotionEffectType.SLOW);
                                            all.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10000, 4));
                                            all.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 10000, 2));
                                            all.sendMessage(ChatColor.RED + "You grow more weary. You begin to hallucinate.");
                                            tiredLevel.put(all, 2);
                                        }
                                    }
                                }
                            }
                        }, 1000L);
                       
                        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                            public void run() {
                                if(Bukkit.getServer().getWorld("world").getTime() > 18000) {
                                    for(Player all : Bukkit.getServer().getOnlinePlayers()) {
                                        if(!all.isSleeping() && tiredLevel.get(all) == 2 && !all.getGameMode().equals(GameMode.CREATIVE)) {
                                            all.removePotionEffect(PotionEffectType.SLOW);
                                            all.removePotionEffect(PotionEffectType.CONFUSION);
                                            all.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10000, 6));
                                            all.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 10000, 4));
                                            all.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10000, 2));
                                            all.sendMessage(ChatColor.RED + "You grow even more weary. You begin to lose your sight.");
                                            tiredLevel.put(all, 3);
                                        }
                                    }
                                }
                            }
                        }, 2000L);
                       
                        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                            public void run() {
                                if(Bukkit.getServer().getWorld("world").getTime() > 18000) {
                                    for(Player all : Bukkit.getServer().getOnlinePlayers()) {
                                        if(!all.isSleeping() && tiredLevel.get(all) == 3 && !all.getGameMode().equals(GameMode.CREATIVE)) {
                                            all.getWorld().createExplosion(all.getLocation(), 0.0F, false);
                                            all.remove();
                                            all.sendMessage(ChatColor.RED + "The loss of sleep caused you to combust.");
                                            tiredLevel.remove(all);
                                        }
                                    }
                                }
                            }
                        }, 5000L);
                    }
                }
            }, 0L, 20L);
        }
    
    I am getting an IllegalPluginAccessException on this method in my console, causing it not to fire any of my code. If someone could provide insight on why this is happening, that would be great.

    Code:
    [14:44:51] [Server thread/ERROR]: Error occurred while enabling BetterMechanics v1.0 (Is it up to date?)
    org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event org.bukkit.event.player.PlayerEvent
        at org.bukkit.plugin.SimplePluginManager.getRegistrationClass(SimplePluginManager.java:585) ~[craftbukkit-1.8.jar:git-Bukkit-7658819]
        at org.bukkit.plugin.SimplePluginManager.getRegistrationClass(SimplePluginManager.java:583) ~[craftbukkit-1.8.jar:git-Bukkit-7658819]
        at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:527) ~[craftbukkit-1.8.jar:git-Bukkit-7658819]
        at com.bizarreplatinum.bettermechanics.BetterMechanics.onEnable(BetterMechanics.java:27) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[craftbukkit-1.8.jar:git-Bukkit-7658819]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:327) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:340) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:312) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:394) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:362) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:317) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:190) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:473) [craftbukkit-1.8.jar:git-Bukkit-7658819]
        at java.lang.Thread.run(Unknown Source)
    
     
  2. Offline

    BizarrePlatinum

  3. It's probably on the line that you register the event for the class, it contains an EventHandler that refers to a method that uses PlayerEvent. When a listener gets registered the server looks for each method in the class that has an event as parameter, but the event also needs to have the method getHandlerList() in it, if it doesn't, it won't work. You need to use the direct events instead.
     
  4. Offline

    BizarrePlatinum

    @megamichiel I see what you're saying; I was using a PlayerBucketEvent (wanted to cancel drinking milk to rid the effects) because I couldn't find a consume event. I've replaced it with PlayerItemConsumeEvent, which appears to have fixed the problem. Thanks :).
     
Thread Status:
Not open for further replies.

Share This Page