Timer

Discussion in 'Plugin Development' started by JoTyler, Jan 19, 2014.

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

    JoTyler

    What would be the best way to have a 7 day timer , but not just 1 timer. I need a timer like this.


    Someone buys a shop . They own it for 7 days then after 7 days the shop will return to open, but i need it to be like . I can buy a 7 day shop and you can buy one 3 days later and my 7 day timer stays continues to go and your time just started. Also i need it to only tick when the server in online.
     
  2. Offline

    Compressions

    JoTyler System.currentTimeMillis()
     
  3. Offline

    JoTyler

    Compressions that doesn't help at all ... Thanks anyway
     
  4. Offline

    Compressions

    JoTyler But it does. You would store that at a certain time and calculate 7 days in milliseconds to be able to check when the time is up.
     
    Konkz likes this.
  5. Offline

    JoTyler

    Compressions Ok thats fine .. i get that but i don't want the time to pass when the server is off.
     
  6. Offline

    Maurdekye

    Is that real life days or minecraft days? I'm going to assume minecraft days for this explanaton.
    If one second is 1 tick, and a minecraft day-night cycle repeats every 20 minutes, that's (ticks per second)*(seconds per minute)*(minutes in a minecraft day), or 20*60*20, which is 24000. Therefore, every minecraft day lasts 24000. You can set up a scheduler to repeat once a day, or every 24000 ticks. You could create a HashMap<String, HashMap<String, Integer>> to, for each player, hold a list of HashMaps full of timers and the names of the timers, giving certain permissions to players depending on which timers have time left in them.
     
  7. Offline

    JoTyler

    Maurdekye actually I need it for real days ..
     
  8. Offline

    Maurdekye

    Then use currentTimeMillis(). You could take load off by evaulating the method once every couple minutes or so, and if it's more than 86400000 milliseconds greater than the previous cycle, then run your command.
     
  9. Offline

    Warreo

    JoTyler Maurdekye remember you need to take into account that hopefully the server is going to restart at some point within that time span so onDisable the required information about said timer will have to be written to a file, then reread and restart the timer in onEnable.
     
Thread Status:
Not open for further replies.

Share This Page