MonthlyPlayTime [FORMATTED]

Discussion in 'Archived: Plugin Requests' started by np98765, Jun 4, 2012.

  1. Offline

    np98765

    Plugin category: Umm...

    Suggested name: MonthlyPlayTime?

    A bit about me: I'm a small server owner. Don't be nosy. :p

    What I want: A playtime tracker. Most of them are outdated, there is one or two that are extremely feature deprived. I believe tracking someone's playtime is simple (I might be wrong), so that's why I'm asking for a "whole 'nother plugin". (EDIT: Scratch that. I tried every one I could find, and they gave me errors on start up >.<)

    Basically, it would track the users playtime, but here's where it gets complicated: There would be two trackers going on, monthly and all-time. Basically, I want a contest-type thing, and users with the most playtime at the end of the month will get a reward. Monthly playtimes would restart every month (ironic, huh? :p) and all-time would count... All-time playtime of a user.

    Giving the top user something would be nice (option in a config.yml), but definitely isn't necessary. If you do want to implement this, basically, as soon as the #1 player for the previous month logs in after the playtime count has been reset, they'd get a configurable item(s).

    Ideas for commands:

    /playtime: Checks your playtime
    /playtime <player>: Checks <player>'s playtime
    /playtime month top [x]: Prints the top [x] amount of playtimes this month.
    /playtime alltime top [x]: Prints the top [x] amount of playtimes alltime.

    Ideas for permissions:

    playtime.check.own
    playtime.check.others
    playtime.top.month
    playtime.top.alltime

    When I'd like it by: Well, I was hoping for a monthly contest. So, let's say July? :p Anytime before would be great!

    Additional In-for-ma-tion: You can use MySQL or SQLite. I don't really care, although personally I would prefer the file, just because I seem to have lots of problems with MySQL.

    Actually, you can use anything. YAML or txt or I don't care :p

    Please?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. Offline

    lol768

    I'll have a look into this. I would store join time and leave time, and when the player leaves I would calculate play time in minutes and add it to a running total. When the player leaves the session total will be added to a config.

    There are a few issues I can identify. Firstly, if a player logs in and the server is reloaded before they logout then thier session time will be lost. To combat this I will probably save it when the plugin detects a reload.
     
  3. Offline

    Elon_Than

    @lol768
    One of my plugins (ForceSleep) is tracking player online time.
    It's checking if player is online every few seconds and increases online time. On disconnect or server reload, plugin saves this time to file.

    It won't work if server will crash, but it's easy to add saving data to file every eg. 5 minutes.
     
  4. Offline

    lol768

    Elon_Than Isn't that a bit inefficient though? At the moment I'm using System.currentTimeMillis(); and storing it in a HashMap with the Player and the join time. Then when they disconnect it will find how long they have been online and store it. That way, you're not adding to a variable repeatedly, which saves CPU time. During a reload/server shutting down the onDisable event is called anyway, so you can use that to store data.
     
  5. Offline

    Elon_Than

    In my case tracking online time isn't main task. I have to check repeatedly, if user doesn't have to go to bed, so tracking online time is only "side effect" ;)
     
  6. Offline

    lol768

    To the OP: This plugin is nearly complete, just testing it now.
     
  7. Offline

    Edge209

    onTime is close to what you want, but it only supports daily or weekly in addition to total playtime. It would be pretty simple for me to add a monthly option. I have new version planned for next week, I'll see if I can add the monthly option, in the meantime check it out.

    http://dev.bukkit.org/server-mods/ontime/

    Btw it does not have the exact function right now, but most of the code is already there such that the plugin could automatically issue the reward at the end of each month. And there are lots of reward types already supported by the plugin so you should find what you need already there as far as actual rewards go.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  8. Offline

    lol768

  9. Offline

    np98765

    Edge209 Ah, I didn't see that for some reason. It didn't come up in any search result? Maybe I just assumed I'd already used. Anyways, thanks!
    lol768 Thanks! I'm actually (attempting) to learn Java, so this might help. I'm an example learner. :p
     
  10. Offline

    lol768

    np98765 Glad you got it sorted out and the code is of some use to you :)
     
  11. Offline

    np98765

    Thanks!! :)
     

Share This Page