Problems with using BukkitTask

Discussion in 'Plugin Development' started by OverDodo, Jul 1, 2017.

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

    OverDodo

    So I want to create a TaskTimer that cancells itself after repeating something for 10 seconds..
    I want to use it in my Listener, but it always gives me the Error "PluginName cannot be null"

    I deleted my code thanks to rage, so could you please help me with bukkittasks? I also canĀ“t use an extra class for the Task, because in my run() part, i have local variables and stuff :c
     
  2. Online

    timtower Moderator Moderator

  3. Offline

    OverDodo

    As i said, i deleted it.. It was something like this:
    PHP:
    new BukkitRunnable() {

    public 
    void run() {
    p.playEffect....

    }
    }.
    runTaskTimer(plugin2010000);
     
  4. Online

    timtower Moderator Moderator

  5. Offline

    Plugers11

    Use this
    Code:
    new BukkitRunnable(){
    int seconds = 0;
    public void run(){
    seconds++;
    //do stuff each second
    if(seconds >= 10){
    //cancel it
    }
    }.runTaskTimer(plugin,20L, 20L);
    Main - class extended from JavaPlugin
    you can use Main.getPlugin(Main.class) instaed of plugin.
     
Thread Status:
Not open for further replies.

Share This Page