Counter in Java?

Discussion in 'Plugin Development' started by olimoli123, May 3, 2012.

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

    olimoli123

    Hey guys, i'm making this quick counter which has 1 added to it every second and i need it to limit at 300, because im doing a 5 minute delay for something. What would be the best way to achieve this?
    I tried a while loop but it didnt work every second instead it worked quicker..
     
  2. Offline

    CompuIves

  3. Offline

    pers2981

    ItsHarry likes this.
  4. Offline

    olimoli123

    Alright thank you guys, one more question.. would it be possible to start a new scheduler for every person when they log out? like seperatley
     
  5. Offline

    Darq

    yes, yes it is.
     
  6. Offline

    olimoli123

    How so? :)
     
  7. Offline

    Craftiii4

    Make it start on player join?
     
  8. Offline

    olimoli123

    So it just automatically seperates the players when the scheduler starts?
     
  9. Offline

    Craftiii4

    If you final player then yes.
     
  10. Offline

    Darq

    I'd create a class that implements runnable, and have hashmap with a Player key and that class as a value. you get it.
     
  11. Offline

    Komak57

    Code:
    public void run(Player player) {
        // functions to run 5 minutes after logout
    }
     
    // snippet to add in the onPlayerLogout handler
    myPlugin.getServer().getScheduler().scheduleAsyncRepeatingTask(myPlugin, new Runnable() { run(player); }, 6000L);
    That should be what you're looking for? Seperating the run(player) is not necessary, but may make it cleaner.
     
Thread Status:
Not open for further replies.

Share This Page