How to preform action every 5 seconds?

Discussion in 'Plugin Development' started by ImPhantom, Apr 15, 2014.

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


    So i am creating a mob bar that will run at the top of my server. But i want it to display a List<String> of messages and cycle through them every 5 seconds. How would i do this? And how would i make it so when they join it automatically assigns it to them but they have the option to turn the messages off?
  2. Offline


  3. Offline


    So... I got the scheduler working. But one more question. How would i loop through a string list every 20ticks in the scheduler?
  4. Offline


    I think you could just put the scheduler in a for loop
    for(String s : List<String>){
    do something
  5. Offline


    You could also use a Repeating Scheduler (Code has been taken from the link I sent you earlier):
    2. public void onEnable() {
    3. BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
    4. scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
    5. @Override
    6. public void run() {
    7. // Run Whatever code you might have
    8. }
    9. //0L stands for how many times you want to run it. 0L is forever
    10. //20L stands for how many ticks until the code will be executed
    11. //So this will make the Code run forever every twenty ticks
    12. }, 0L, 20L);
    13. }
Thread Status:
Not open for further replies.

Share This Page