Solved [UNSOLVED] checking if a timer is stopped

Discussion in 'Plugin Development' started by jthort, Nov 27, 2013.

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

    jthort

    Hey I created this timer, and when it reaches the last message it stops and works perfectly. Here is my code..

    Code:java
    1. timer = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    2. public void run(){
    3.  
    4. switch(messages){
    5. case 0:
    6. Bukkit.broadcastMessage("");
    7. messages++;
    8. break;
    9. case 1:
    10. Bukkit.broadcastMessage("");
    11. messages++;
    12. break;
    13. case 2:
    14. Bukkit.broadcastMessage("");
    15. messages++;
    16. break;
    17. case 3:
    18. Bukkit.broadcastMessage("");
    19. getServer().getScheduler().cancelTask(timer);
    20.  
    21. break;
    22.  
    23. }
    24.  
    25. }
    26. }, 0, 24000);


    Next I want to put something like if the "timer" is done, do this. I don't want to put everything else in my code in"case 3: ". I found this

    Code:java
    1. public boolean isCurrentlyRunning(int taskId);


    But when I put put "timer" as the "taskId" it gives an error when I use this in a new method. Any help? Sorry, I'm new to java and plugin development.
     
  2. Offline

    Commander9292

    jthort Why not just check if the timer is equal to 4 because it only goes up to case 3? And what are you trying to make? There might be an easier way.
     
  3. Offline

    jthort

    I'm using the integer "messager" in the cases, not "timer". Timer is set to the timer

    I'm trying to run this timer, and when it's done start the rest of the code

    I'm just going to create a new class and call the class in at case 3. Solved

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page