Solved Delay in for loop

Discussion in 'Plugin Development' started by Marcohan, Dec 25, 2015.

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

    Marcohan

    Hi! So I'm trying to loop all players

    Code:
    for (Player p : Bukkit.getOnlinePlayers()){
    but I want a 30 second break in between each player. I tried to put a delayed task in there but the loop fires before its finished.

    If anyone can give me a hand that would be great.
     
  2. Online

    timtower Administrator Administrator Moderator

    @Marcohan Use that loop, in the loop y0u start a delayed task for 30 seconds * counter, increment counter by 1.
    Everybody dies 30 seconds after each other
     
    Areoace likes this.
  3. Offline

    Marcohan

    Could i have an example of this? just to make sure I'm on the right track
     
  4. Online

    timtower Administrator Administrator Moderator

    I won't spoonfeed.
     
    Zombie_Striker likes this.
  5. Offline

    mine-care

    I was thinking that you could run a repeating task with a 30*20 between passes, (so it will run every 30 sec) and each time the 'run' method executes you get the next player (keep a pointer int outside the method and increment by 1 every time making sure it doesnt exceed the online player size) and kill them.
     
    Zombie_Striker likes this.
  6. Offline

    Areoace

    Examples are all over the internet if you need, try and error is a good way to start out and teach yourself.
     
    Zombie_Striker likes this.
  7. Offline

    Marcohan

    All good, I ended up getting it
     
    Areoace likes this.
  8. Offline

    Zombie_Striker

    @Marcohan
    Mark this thread as solved if solved.
     
Thread Status:
Not open for further replies.

Share This Page