Need help with canceling countdown

Discussion in 'Spigot Plugin Development' started by Snowmite, May 15, 2016.

  1. Code: http://hastebin.com/kehuzepiwi.coffee
    Whenever I make a countdown from 30, it works fine, but when it reaches to 0, it spams what I have to broadcast. The code is above. If anybody could please help I would really appreciate it! Thanks..
     
  2. its because you stop counting down at this point so its forever 0 ticks
     
  3. and you can cancel the task at the end with Bukkit.getScheduler().cancelTask(arg0); arg0 is the id of your task that you get on creating it
     
    • Use switch statements to tidy up your code and for efficiency.
    • To cancel it, you can use:

    cancel
    ()
    Attempts to cancel this task.
     
  4. he don't use a BukkitRunnable so just cancel() will not work ^^
     
  5. Ah, whoops. My bad, thought he was.

    @essem2 solution is correct.
     
    • Agree Agree x 1