Sheduler error

Discussion in 'Plugin Development' started by Vincent1468, Apr 1, 2013.

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

    Vincent1468

    Hello,

    I've got a problem, when I try to call a scheduler I get this error:
    Code:
    10:04:39 [SEVERE] Could not pass event PlayerInteractEvent to FireworkWand v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:477)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:462)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:181)
            at org.bukkit.craftbukkit.v1_5_R2.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:151)
            at net.minecraft.server.v1_5_R2.PlayerConnection.a(PlayerConnection.java
    :612)
            at net.minecraft.server.v1_5_R2.Packet15Place.handle(SourceFile:58)
            at net.minecraft.server.v1_5_R2.NetworkManager.b(NetworkManager.java:292
    )
            at net.minecraft.server.v1_5_R2.PlayerConnection.d(PlayerConnection.java
    :110)
            at net.minecraft.server.v1_5_R2.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.v1_5_R2.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:5
    78)
            at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:2
    25)
            at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:4
    74)
            at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java
    :407)
            at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:5
    73)
    Caused by: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to r
    egister task while disabled
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.validate(Craf
    tScheduler.java:394)
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.runTaskTimer(
    CraftScheduler.java:120)
            at org.bukkit.craftbukkit.v1_5_R2.scheduler.CraftScheduler.scheduleSyncR
    epeatingTask(CraftScheduler.java:116)
            at me.vincent1468.fireworkwand.Listeners.MyPlayerListener.powerRegen(MyP
    layerListener.java:74)
            at me.vincent1468.fireworkwand.Listeners.MyPlayerListener.onPlayerIntera
    ct(MyPlayerListener.java:220)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 16 more
    This is my scheduler code:
    Code:
    void powerRegen() {
        Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) this, new Runnable() {
     
    public void run() {
                                        //Do something
    }  
        }, 100, 100);
      
          }
    void powerRegen() is on line 73.
    On line 220 I call it like this:
    Code:
    powerRegen();
    Does anyone know the solution for this?
    Thanks
     
  2. Offline

    re4ly

    "Plugin attempted to register task while disabled"
    pls more code
     
  3. Offline

    Vincent1468

    This is the full code off the powerRegen():
    Code:
    void powerRegen() {
        Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) this, new Runnable() {
     
    public void run() {
    for(Player p : Bukkit.getServer().getOnlinePlayers()) {
    int oud = cooldown.get(p.getName());
    int nieuw = oud + 2;
     
    if(oud == 10 || oud > 10) {
    cooldown.put(p.getName(), 10);
             } else {
    p.sendMessage(ChatColor.GOLD + "Your power is now: " + nieuw + "/10");
    cooldown.put(p.getName(), nieuw);
    try {
    fplayer.playFirework(p.getWorld(), p.getLocation(), FireworkEffect.builder().with(Type.STAR).withColor(Color.SILVER).build());
          } catch (Exception exc) {
       }
    }
    }
     
    }
        
        }, 100, 100);
        
          }
    And it gets called in a playerInteractEvent, when the player right clicks
     
  4. Offline

    techboy291

    Yeah, I'm having the same problem when running a scheduler in my plugin, too. It appears to only happen in the newest build (1.5.1-R0.1). I think this error is happening to basically everyone who uses a scheduler in their plugin. I'm sure the Bukkit team will fix it in the next build.
     
  5. Offline

    trigger281

    You're sure to blame the new Bukkit?
     
  6. Offline

    Score_Under

    What's the latest dev build that it does work on?
    What code do you have in your onEnable/onDisable?
    Did you /reload?
     
  7. Offline

    techboy291

    trigger281

    1. I'm not blaming it, I'm just saying that the bug seems to have started to occur in that build.

    2. I am almost positive that the bug was first created in 1.5.1-R0.1. There is no evidence to suggest otherwise (as far as I know).
     
  8. Offline

    McMhz

    No, Don't blame them. Blame the failed code ;)

    Well, Maybe they changed some of the methods, So maybe you need to do something in a different way.
    For example, Now you cant have any events functioning without the @EventHandler.
    So. You should go check that out.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  9. Offline

    Vincent1468

    Seriously? This thread is 5 months old.
     
    techboy291 and McMhz like this.
  10. Offline

    McMhz

    And? :Þ

    I like your profile post :Þ
    "Why do Java developers wear glasses? Because they don't C#!"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  11. Offline

    Vincent1468

    You shouln't bump it.
     
  12. Offline

    techboy291

    Yes, I have always used @EventHandler. The error occures when you pass "new <pluginname>()" as the plugin object in a scheduler, which of course would be an empty, invalid plugin instance. It can just be resolved by making a constructor in the class that you're putting the scheduler in, and passing in the plugin's instance to the contructor in the plugin class's onEnable(). Also, it's not like having to use the @EventHandler annotation is a recent thing -- it's been around since 1.1 or so. And telling me that I "need to do something in a different way" doesn't really help me that much. :p
     
  13. Offline

    McMhz

    Sorry for trying to help :)
     
Thread Status:
Not open for further replies.

Share This Page