[SOLVED]starting a scheduler on pluginEnable PLZ help

Discussion in 'Plugin Development' started by DeadlyScone, Oct 31, 2011.

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

    DeadlyScone

    i am trying to start a repeating task in a private void that is triggered by onEnable, but for some reason i am getting an error that says
    21:10:01 [SEVERE] java.lang.IllegalArgumentException: Plugin cannot be null
    21:10:01 [SEVERE] at org.bukkit.craftbukkit.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:200)

    - when i take the scheduler code out it works fine.
    and there is no code in the scheduler run() void.

    here are the code snippets.

    Code:
    public void onEnable() {
            makeDirectory();
            dateChecker();
    
            log.info("Plugin Enabled.");
        }
    -
    Code:
    private void dateChecker(){
        Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin,
                new Runnable() {
            @Override
                    public void run() {
                     //i++;
                    //log.info(String.valueOf(i));
                    }
        }, 0, 40);
    }
     
  2. Offline

    Kaikz

    > 21:10:01 [SEVERE] java.lang.IllegalArgumentException: Plugin cannot be null

    Something you assigned is null. It'd help if you posted the entire thing so we can see line numbers. (use the java bbcode)
     
  3. Offline

    DeadlyScone

    k, hold on i'am trying to help someone.

    here is the whole stack.
    Code:
    23:42:06 [SEVERE] java.lang.IllegalArgumentException: Plugin cannot be null
    23:42:06 [SEVERE]     at org.bukkit.craftbukkit.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:200)
    23:42:06 [SEVERE]     at me.DeadlyScone.GriefAlert.GriefAlert.dateChecker(GriefAlert.java:118)
    23:42:06 [SEVERE]     at me.DeadlyScone.GriefAlert.GriefAlert.onEnable(GriefAlert.java:50)
    23:42:06 [SEVERE]     at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:170)
    23:42:06 [SEVERE]     at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:957)
    23:42:06 [SEVERE]     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280)
    23:42:06 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:171)
    23:42:06 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:154)
    23:42:06 [SEVERE]     at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:297)
    23:42:06 [SEVERE]     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:284)
    23:42:06 [SEVERE]     at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:152)
    23:42:06 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:348)
    23:42:06 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)
    
    as far as anything throwing null... i have not a clue. everything runs as long as the scheduler part is not there.
    i was guessing it was the scheduler code being wrong... but its the same code i use on other plugins... so therefore i'am stumped again.

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

    Kaikz

    I meant the code. :3
     
  5. Offline

    DeadlyScone

    soz :p
    here is a link with line numbers.
    EDIT: sorry that was the wrong code

    https://pastee.org/jew78

    there is the new link
     
  6. Offline

    Kaikz

    Wrong file. GriefAlert.java is what we need, as said in the stacktrace.
     
  7. Offline

    DeadlyScone

    so you want the file?
    or did you look at the link i sent you? i posted the wrong link at first. i fixed it as said before.

    here is a link to the file.
    http://dl.dropbox.com/u/40600282/GriefAlert.java

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

    Kaikz

    Remove line 39.
    Line 118: Change plugin to this.

    Also, dat "jew" URL.
     
  9. Offline

    DeadlyScone

    wow, it seems the littlest things always get me... thanks a bundle.

    oh and sorry for the weird code.. i'am in the process of upgrading this plugin.

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

    Kaikz

    No problem, just found the URL lulzy.
     
  11. Offline

    DeadlyScone

    wow, someone is bad... jk
     
Thread Status:
Not open for further replies.

Share This Page