runnable problem

Discussion in 'Plugin Development' started by ulsa, Jul 24, 2014.

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

    ulsa

    guys im trying to make a runnable that does change the delay between 2 executions
    is it possible in some way

    Code:java
    1.  
    2. int num = 0;
    3. ad = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    4. @Override
    5. public void run() {
    6. if (i>0){
    7. sender.sendMessage("Counting down: " + i);
    8. i--;} else {sender.sendMessage(ChatColor.RED + "Done");Bukkit.getScheduler().cancelTask(ad);}
    9. num = rand.nextInt((4 - 0) + 1) + 0;}
    10. }, num , 12);}
     
  2. Offline

    Gater12

    ulsa
    Schedule another task after that one is done?
     
  3. Offline

    ulsa

    Gater12 no the problem is that i want "Counting down: " text to come at random delays not with same delay
     
  4. Offline

    Zettelkasten

    ulsa Once you have used scheduleRepeatingTaks(), you cannot change the time of it. So you will have to use a normal delayed task and run a new task from that task.
    Also, your time calculation is very weird: The delay is in server ticks, and 1 second = 20 server ticks. (So your code would use at maximum a fifth of a second as delay)
     
  5. Offline

    ulsa

    Zettelkasten is there a way so that i can get the time 1st task ends and run a task after it ?
     
  6. Offline

    Garris0n

    Declare a variable?
     
Thread Status:
Not open for further replies.

Share This Page