Scheduler Error

Discussion in 'Plugin Development' started by TheChugBug, May 13, 2014.

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

    TheChugBug

    Whenever I use the Bukkit scheduler, I get an error.
    This is my code:
    Code:
    new BukkitRunnable() {
    public void run() {
        // CODE GOES HERE
    }
     }.runTaskLater(this.plugin, 20L);
    
    This is my error: http://pastebin.com/7RnXbEcL
    (the error happens at line 156, which is }.runTaskLater(this.plugin, 20L); )
     
  2. Offline

    coasterman10

    The stacktrace says the error is caused by IllegalArgumentException: Plugin cannot be null

    This is probably caused by this.plugin, which is probably not initialized. Did you forget to set this variable?
     
  3. Offline

    TheChugBug


    I did:
    public myPlugin plugin;

    Is that enough?

    coasterman10

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

    Jetsinsu

    TheChugBug
    If you are using the Listener in the MainClass try replacing "public myPlugin plugin;" with "myPlugin plugin = this"

    Change the code to this "}.runTaskTimer(plugin, 0, 20L);"
     
  5. Offline

    TheChugBug

    Jetsinsu I have the listener as its own class.
     
  6. Offline

    Jetsinsu

    TheChugBug
    OK try this:
    public ListenerClass(MainClass instance){
    plugin = instance;
    }


    Something like that. As I said I might not get it right out of my head :)
     
Thread Status:
Not open for further replies.

Share This Page