Wait X seconds before executing code, but not in a Scheduler

Discussion in 'Spigot Plugin Development' started by Nore, May 5, 2015.

  1. I am making a plugin that has a lot of code that needs to be executed after X seconds, but not using a Scheduler or stopping the main thread. I have looked everywhere for this answer, but it just says to use a Schedular.

    Example of what I mean:
    Code (Text):
    if(player.getHealth() <= 20) return;

    //This part of code needs to be held until X seconds.
    //If something happens, like the player types a specific word, this cancels.
    //Summons a fireball towards a player
  2. Simply use an other thread :)
    • Winner Winner x 1
  3. Why don't you want to use the scheduler?
  4. Because he has to stop it if a condition is true whether I have understand ^^
    • Agree Agree x 1
  5. Haven't thought of using that. I tested it and it works. Thanks :).
    • Winner Winner x 1
  6. However you can use the cancelTask if you use a Scheduler.
    • Agree Agree x 1
  7. Use the provided scheduler.