Save an amount of hours played in that week?

Discussion in 'Plugin Development' started by CraftCreeper6, Mar 1, 2015.

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

    CraftCreeper6

    Welp, how would I get the amount of hours a player has played in one week? It's confusing me :/ I can get the day, but not cross reference to check if it's in the current week :/
     
  2. Offline

    1Rogue

    Keep a track of the different durations they spent online, then add them. From there you can use the raw data however you like.
     
  3. looks simple:

    PlayerJoinEvent:
    Save currentTimeMillis. (time1)

    PlayerQuitEvent:
    Save currentTimeMillis. (time2)

    Save int played = (time2 - time1) * 3600000;
    Reset time1 & time2.

    Then you need to add played hours to the old value.

    (do all of it with config)
     
  4. Offline

    CraftCreeper6

    @FisheyLP
    Except, that time needs to get reset every week ;p
     
  5. Yes.
    @CraftCreeper6
    A good way to do this, is saving the hours played like this: "players.playername.monday"
    And reset all values except monday, if the weekday (get with Calender) is monday
     
    Last edited: Mar 2, 2015
  6. Offline

    Zombie_Striker

    Make a map that holds a UUID and an Integer.If a player join, add their uuid to the map with the number they had that day. When they leave, it get saved to the config and removed from the map. Allow for 8 values (because the last one wont be read), and every day move the spot up from one (e.g. 7 goes to 8, 6 goes to 7....)
     
Thread Status:
Not open for further replies.

Share This Page