(New) Timer Loop Issue

Discussion in 'Plugin Development' started by Jason Malouin, Jun 8, 2015.

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

    Jason Malouin

    So, Say I Have A Timer Loop Like This

    Code:
    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    public void run() {
    
    //LOOP until Directed
    
    }
    
    }, 0, 6 * 20);
    
    }
    
    How would I end this loop and continue with the section of code under after directed to. (noob question) Thanks :)
     
  2. First of all, this isn't a loop. That's a repeating task.
    It will sort of start a new thread which doesn't affect the main thread (it just continues with your code after the repeating task but the repeating task will do something else in the same time)
     
  3. ^ What FisheyLP said.

    Plus, it seems like you want it so that the code underneath is run after a certain time?

    http://wiki.bukkit.org/Scheduler_Programming#Example_2

    If you want to just run a repeated task, and then cancel it after a certain time, stored the ID of the repeated task in a variable (global), and then cancel it within the Runnable like: Bukkit.getServer().getScheduler().cancelTask(id);
     
  4. Offline

    Jason Malouin

    Thanks
     
Thread Status:
Not open for further replies.

Share This Page