Solved Repeating a delayed task

Discussion in 'Plugin Development' started by Coopah, Feb 22, 2019.

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

    Coopah

    Hello, I've aware that repeated tasks are just straight up not great to use. I've heard of a work around but I'm not sure how to do it and it's that you can run a delayedtask and have the task repeat itself if a condition is met.

    Any ideas?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Coopah BukkitRunnable.runTaskTimer()
     
  3. Offline

    Coopah

    @timtower

    Yeah I understood that part, just curious on assigning the runnables. They only seem to take ints?
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Coopah You can do the check inside the runnable and then perform cancel()
     
  5. Offline

    Coopah

    @timtower

    Yeah I knew how to do this with repeated tasks, which I guess I will just go with because the alternative seems not much better anyways. I was more asking how do I have a scheduleSyncDelayedTask repeat itself, basically not using repeatedTasks but instead just repeating the delayed task if a parameter was met but registering it.

    I figured it out. For anyone in the future wondering how to do this, you use BukkitTask and cast it to scheduled runTaskLater Runnable.

    For example,
    Code:
    BukkitTask runnable = Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
    
                public void run() {
    
                   
                }
               
            }, 20);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 22, 2019
Thread Status:
Not open for further replies.

Share This Page