Cancelling a Schedule Task.

Discussion in 'Plugin Development' started by Taizzz, Sep 28, 2013.

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

    Taizzz

    Hey,

    Is it possible to cancel a scheduled task? I'm sure it is, I just can't find out how.

    Thanks!
     
  2. Taizzz Yes, a scheduling task always returns an id; so just do int id = Bukkit.getScheduler().schedule..... and then do Bukkit.getScheduler().cancelTask(id);
     
  3. Offline

    Taizzz

    CaptainBern Yeah, I tried that! :/

    I ended up getting the error: "Type mismatch: cannot convert from BukkitTask to int"
     
  4. Taizzz Well then use this way:
    Code:java
    1.  
    2. new BukkitRunnable(){
    3. @Override
    4. public void run(){
    5. this.cancel(); //cancels it
    6. return;
    7. }
    8. }
    9. }.runTaskTimer(instance, 20L, 20L);
    10.  
     
    Taizzz likes this.
  5. Offline

    Taizzz


    CaptainBern Yeah that's worked, thanks a lot! :)
     
  6. Taizzz No problem, happy coding!
     
Thread Status:
Not open for further replies.

Share This Page