Most Efficient Way to Give Players Countdown Timers?

Discussion in 'Plugin Development' started by NerdsWBNerds, Jun 2, 2014.

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

    NerdsWBNerds

    So I need to know the best way to give a seperate countdown timer to different people. I can either store their info in a HashMap, with their current time remaining, and run an async task to remove 1 from all the players currently alive, or I could create 1 async task for every player that automatically tracks the data. Which way would be better for a lot of people? Is there an even better way?

    Also, same thing for if I have a bunch of games running on a single plugin, should I have 1 async task loop through the games and call game.tick() on all of them, or have each of them have their own task?
     
  2. Offline

    Lolmewn

    Either options are fine, really. You either have a function iterating over a bunch of players/games or a function iterating over a bunch of classes. I implemented it myself by creating a Countdown object for each player and having a sync task in there (it implements Runnable, too).
     
  3. Offline

    NerdsWBNerds


    What do you mean sync task (it implements runnable too)?
     
  4. Offline

    Lolmewn

    NerdsWBNerds The class I made (Countdown) implements runnable and in the constructor it schedules itself to a sync task.
     
Thread Status:
Not open for further replies.

Share This Page