Inactive [INFO/WEB] Netstats v5.0.4 - Keeps track of player playtime and online status [RB 1.1-R3]

Discussion in 'Inactive/Unsupported Plugins' started by Valrix, Feb 13, 2011.

  1. Offline


    Netstats v5:
    Keep up with development in BukkitDev!
    Netstats - Player Monitoring Plugin:
    Plugin Version: v5.0
    Web Version: v3.0

    Netstats watches players as they join and leave the server and keeps track of how long they've been logged into the server as well as keeping track of their current online/offline status while using very little system resources. The information is stored in a database which is defined by the user. First time using Netstats it will create the config file then disable itself until you change the config to match your database. Then you can reload or restart the server and it'll start collecting information immediately.
    Source Code: Netstats

    OLD CHANGELOG (open)

    Version 4.7
    • Bug fixes
    • If you don't supply a "database" in the config it will attempt to make it's own database named "NetStats" then create the table "netstats" inside it.
    • Fixed repetitive code and unnecessary MySQL connections when doing multiple queries one-after-another (reduces database calls, speeds up the code, and uses less resources).
    • Reduced code complexity (simplified certain calls and removed hacky functions to improve code performance by around 5-10% in my tests)
    Version 4.6
    • Fixed the bug that happened when trying to change the name of your stats table.
    • Fixed the bug that messed up everyone's total play time (sorry)
    • Code improvements and uses less code for database calls
    Version 4.5
    • Fixed the bug where folders weren't being made.
    Version 4.4
    • Converts the total play time to be saved as seconds instead of milliseconds to increase maximum play time. This will now match the PHP code, so if you changed it, change it back.
    • Now disables and re-enables itself instead of reloading the server when doing a wipe
    • Some code improvements
    Version 4.3
    • No longer requires the /lib/ folder since CB already contains the needed drivers
    • v5 is close to being ready and will bring large speed improvements
    Version 4.2
    • Fixes the bug that creates .stats folders instead of files.
    Version 4.1
    • Many code improvements to improve speed and memory usage.
    • Thanks to @jascotty2 for the code to fix how player and mob kills are handled
    Version 4.0
    • Many bug fixes
    • Changed how total play time was saved to the database
    • Fixed a bug with timed events
    • A new and improved Web update is nearly finished
    Version 3.9
    • Should work with RB 617
    Version 3.8
    • Fixed an issue with how files were handled.
    Version 3.7
    • Fixes issue of logged-in users being shown as offline after a reload
    • Fixed file creation bug where .stat files weren't being made properly
    Version 3.6
    • Fixed a bug where, depending on your region, your IP address was logged twice in the database. This was more of an issue with how the IP address was being grabbed than a problem with how it was stored.
    • Few other small fixes to prevent possible future bugs.
    Version 3.5
    • Changed how paths are managed by the plugin to be more OS-independent, hopefully fixing all "file not found" errors.
    • Removed checking if a database password exists or not.
    Version 3.4
    • Improved error logger that create a special log file with the exact info I'll need to find out what caused the problem.
    • Numerous bug fixes and speed tweaks
    Version 3.3
    • Added tracking of distance traveled
    • Added tracking of number of monsters a player has killed
    • Added tracking of number of other players a player has killed
    • Added the date of when the player first joined the server (after this version of Netstats has been installed, will only be correct after a full wipe of other stats)
    • Database will auto-build if it doesn't exist, otherwise it'll add columns if they're needed (so you don't have to do anything to update your database)
    • Config file now auto-updates and allows for comments (they need their own line however)
    • Many other code improvements and fixes to help it run faster and more efficiently.
    Version 3.2
    • Fixed the problem with saving to the database that everyone's been getting. (Only need the JAR)
    Version 3.1
    • Changed the namespace to com.sparkedia.valrix since I did the Java bit.
    Version 3.0
    • Rebuild of v1 to be more efficient.
    • Customized tracking based on "true" or "false"
    • What you don't want tracked won't be watched which improves performance
    • Timed updates (default is 90 seconds)
    • Fixed updating based on total actions user has done (default is 32)
    • Numerous performance tweaks
    • A "pretty" config file
    • Improved web script performance and added customized tracking (make it match your main config, variables are named the same for simplicity)
    • Web view tells when a player is still online and makes their name green if online, red if offline
    • Uses the "hybrid" method of player data saving like v1 to put less strain on the database
    • When saving to a database it is done dynamically so that only changed things are saved to cut down on the code needed and make smaller, faster calls to the database when saving (this was a big improvement on all previous versions)
    • Table name has been changed to "netstats" to not conflict with any other tables
    • NOTICE: You will need to remove your old data since it is outdated and the table is named differently with a few field name changes so make sure to use the .sql file to add it to your database. Please, before complaining about losing all the old data, realize that there's a 99% chance that it's wrong.
    Version 2.0
    • Complete revamp!
    • Now uses only flatfiles to store data, no more database issues!
    • Lots of code removed and improved for faster speed and less resource use
    • Customizable timed updates (default is every 30 seconds)
    • Customized tracking also reduces resource use by registering (or not registering) events as per your config so it only watches events that you want it to.
    • Web script will search for your CraftBukkit server when you first look at the web page.
    • You can choose where the server will save every player's .stats file by setting the "path" option in the config. The path is relative to your main server folder (where the world folder should be at). So if you set "path=../players/" then the .stats files will be in a folder called "players" in the folder that your server is in.
    • Table of player data is built depending on what your tracking and will change as you change the Netstats config file, nice and easy!
    • There are a few rules to setting paths that are listed above, make sure to read them!
    Version 1.8
    • Various code fixes and changes to improve how it runs.
    • Creates a new blank config file if it can't find one.
    • Only JAR has been changed. Get the newest one above, which I'll just reference from now on since it's faster than posting the same link over and over again.
    Version 1.7
    • Changed how files are accessed which should fix the "Too many files open" bug on Linux machines. Update the [JAR]
    Version 1.6
    • Hopefully fixed bug with connecting multiple times to a property file for each user. Only [JAR] needs updating.
    Version 1.5
    • Fixed a critical bug where user property files (where it saved your data before moving it to the database) wasn't re-defined when the plugin was reloaded. Now it looks for it after everything you do to make sure your data is always being recorded. Only the [JAR] needs to be updated.
    Version 1.4
    • Updated the files to work with the new constructor. You'll need only the [JAR] for this update.
    Version 1.3
    • Fixed a bug with how the plugin saves user data after a server crash
    • Added an Update.sql to add new columns to database table [] (only for those upgrading from v1.2)
    Version 1.2
    • Added tracking of blocks broken
    • Added tracking of blocks placed
    • Added tracking of player deaths
    • Added more frequent tracking of total time online
    • Implemented new "safety" storage system
    • New storage system reduces number of database calls
    • Improved the way data is stored to database to take less code
    • The table of data is now ordered by who is online
    Version 1.1
    • Added tracking of player's last used IP address
    Version 1.0
    • Release of Netstats
    WEB CHANGELOG (open)

    Version 2.1
    • Some code cleanup and fixes as well as a better auto-updater that makes sure that the updater is the latest version before doing the actual update process.
    • Localization support for 7 different languages.
    • File name changes to be more netstats-specific which will prevent clashes of CSS and other pages.
    • Better include() and require() calls so a page is only added once which speeds up all the pages and keeps them from destroying each other.
    Version 2.0
    • Improved layout
    • Automatic code updates
    Version 1.0
    • Initial release of web code

    Donations: Don't forget to give amd3th some love too since he helped in making Netstats and came up with the idea (you rock!) as well as @marshall007 since he's been awesome by helping me in his spare time.
    Phaedrus, Niemand, D-Lew and 5 others like this.
  2. Offline


    He might, but he's only just started to get the real hang of the hooks and stuff. Heck, I'm still learning new ways to program in order to make the code better.
  3. Offline


    I've finished my modifications to the PHP files Valrix created.

    Here is a brief list of changes I made:
    • Dumped all the path auto-detection code in favour of letting admins simply configure their paths
    • Added some quick error checking to make sure files can be read and configuration variables are set
    • Over killed commenting the code
    • Fixed the missing </table> tag at the end of the table for HTML compliance
    • PHP script to import the flat files into a MySQL database
    • Fix up the CSS styles I hard coded in the table (oops)
    • Work on cleaning up the table layout a bit
    I've got to run but I'll be back later tonight to do some more work on this. I'm also struggling to figure out how Google Code works but I think I've got the jist of it now.

    You can download my files from here:

    Installation instructions:
    1. Extract the PHP files into your www directory
    2. Edit 'config.php' and set the paths to your Netstat config.txt and your player .stats files
    3. Include the 'getStatsTable.php' file in what ever page on your website you'd like stats display or simply link to it. If you include it your sites existing styles will apply to the HTML.
    An example can be found here:

    To get the results you see in the example my page source looks like this:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Minecraft on</title>
    <link rel="stylesheet" type="text/css" href="/styles.css" />
    <h1><img src="/images/logo.jpg" width="314" height="84" alt="Logo" longdesc="/images/logo.jpg" />  <img src="/images/dirtGrassBlock32.png" width="32" height="32" alt="Dirt and grass" longdesc="/images/dirtGrassBlock32.png" /><a href="/index.php">Home</a> <img src="/images/stoneBlock32.png" width="32" height="32" alt="Stone" longdesc="/images/stoneBlock32.png" /><a href="/maps.php">Maps</a> <img src="/images/bedrockBlock32.png" width="32" height="32" alt="Bedrock" longdesc="/images/bedrockBlock32.png" /><a href="/stats.php">Player Stats</a></h1>
    <?php include "stats/getStatsTable.php"; //Include the player stats from Netstats ?>
    The relevant line from the above example is:
    <?php include "stats/getStatsTable.php"//Include the player stats from Netstats ?>

    Please submit bugs and suggestions to the Google Code page:
  4. Offline


    i run ubunto 10_04 X86_64 i run my server like this after i log in, /test/run
    is that the directory id use or is there more to it?
  5. Offline


  6. Offline


    No MySQL anymore? So my old table is useless? Such as the plugin now?
  7. Offline


    Good suggestion. I'll see if I can make my bridge use the existing table so you guys won't lose any existing data.
  8. Offline


    im confused I grabbed someone's index.php or w/e and copy and pasted that but how do I get this on my website?
  9. Offline


    Seeing as how not many (if any) people seem to like the change, I will just go back to the old way of doing it and fix things up from there. It'll take me a bit, but I'll get to it.
  10. Offline


    @Valrix: I'm happy with the flatfile but I don't need updates of the files every second for online user. For me It's enough to write the file with connect/disconnect => will save IO Performance with many online users.
  11. Offline


    Thanks for the great plugin!

    Unfortunately the "Last Login/Last Seen"-Time doesn't work (in my timezone?)!

    date( [..] ,$playerData['enter']/1000) tells me that my last login is ~50 days ago (in 1970).
    What is that "enter" value in the stat files? The milliseconds since 01.01. of the current year?
  12. Offline


    1. Look at LWC's sqlite coding(i thinks its lwc) he seems to be quite good at optimizing performance in sql
    2. You could add sqlite, but you would need to figure out howto get it workin with the website.. it can be done though =]

    good luck and bring back MySql!
  13. Offline


    sqlite is completly useless if you run a mysql server anyway...
  14. Offline


    sqlite make no performance improvement against the current flat file system.
  15. Offline


    So MySQL support is gone? When did that happen? I liked the simplicity of this plugin since I could connect to the mysql table with the wordpress plugin I wrote and the table was fast & efficient. Looks like i'm not updating this plugin.

    If somebody were making a website, and they have mysql installed, mysql is hands down the better choice over sqlite because as soon as you have concurrency involved sqlite fails hardcore.
  16. Offline


    Alright, did a reset on the git repo and now I'm back to right before the whole revamp happened. From here I will fix the issues with saving user data, it'll still be based on the number of actions as well as having it updated based on time. I will implement a few of the new things I had in 2.0 and the new version will then become 3.0 with an improved web interface that I'm going to stick amd3th with. This'll take some work so please be patient while this all happens. I'll try to build up a working version to tide everyone over. But remember, the old data you have now is most likely wrong. There's a 1% chance that any of it is correct due to an old bug. It will suck that you have to clear it all, but that way you'll have accurate information. Sorry for all this but this kinda happens when doing a lot of new things without many ways to test every problem. However, v3 will make up for it, I promise you.
  17. Offline

    Lord Chaos

    Is there a setup guide somewhere? Because I am a bit at a loss as to how this works.
  18. Offline


    Currently I'm rebuilding it again because the current way of using it doesn't seem to work for as many people as I thought it would. So now I'm going back to using databases. Until then think of it as being broken...again.
  19. Offline

    Lord Chaos

    Ok, whats the time estimate on the new version? Thanks for the hard work. :)

    I donated some money to keep you motivated :)
  20. Offline


    Well in the time I've had this morning I've reworked a large bit of it. I'd say a week or less depending on how much time my finals take up.
  21. Offline


    Wah, after 2 hours of trial and error i finally got it working :D
    Its a great thing you are working on, hope there are coming a few more stats ;)
    And maybe a less trickier install would be great
  22. Offline


    Yeah, I'm rebuilding it again to work with a database instead of flatfiles since it seems like nobody liked the flatfile method of doing it. It'll be easy again and I'll definitely be adding more to it as time goes on.
  23. Offline


    That sounds great :)
  24. Offline


    Yeah, I'm working on it now and making pretty good progress so far. It's going to use a lot less code and should be a bit easier on the database too. I've also renamed the table so it won't conflict with any other tables someone may have on their database. It's a pretty big makeover.

    Ok, Netstats v3.0 is nearly done and will be ready for release after I finish the last bits tomorrow shortly after I wake up.

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


    Netstats v3.0 GO!!!

    Ok there, now the namespace is changed and I think a few other small fixes were done. Grab the latest version and enjoy!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  26. i have a little problem with this plugin:
    The date and the time, the plugin writes in the stats of the players, is wrong.
    5 minutes ago i tested it and I got the following:
    seen= 15.06.1943 - 12:38 Uhr
    total= 15.06.1943 - 12:01 Uhr
    enter= 14.06.1943 - 14:25 Uhr
    (i converted the time ;) )

    this can't be the real time :D so, what should I do?

  27. Offline


    It's getting the time based on the server's time and I think the PHP shows it based on your time. Time is always a touchy thing to play with because depending on location and the rules of how their time works it can be wrong. I'm not really sure how to get it to be correct for everyone, but the plugin only assumes that the server it's running on has the correct date and time. So by the looks of it you either didn't change it correctly or the server's time is very, very wrong.
  28. you are right, this time is really really wrong :D I will look at my server configs, but thanks for the help ;)
    And this is a really great plugin! I hope, you will develop it in the future too, because i am going to use it from now on :D

  29. Offline


    Glad to be of help! Yes, I will be adding more tracking as time goes on and the more people suggest then the faster I will update.
  30. Offline

    Lord Chaos

    How do you run this if you have two servers on the same machine that needs to be monitored? Can they use the same table without messing up the data? Or can you costumize the table name?

    You forgot to write that you apparently have to create the table to get it to work. Can you provide the needed SQL for this?

    Or perhaps make it so it creates the table itself if its missing?

    2011-03-20 13:51:12 [SEVERE] [Netstats]: Could not fetch data for mysql: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'minecraft.netstats' doesn't exist
    2011-03-20 13:51:12 [SEVERE] [Netstats]: Could not set data for com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'minecraft.netstats' doesn't exist
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  31. Offline


    The .sql file is in the Web folder.

    Currently you can't customize the table name but I'll do that for the next update. Then you'll be able to set the table name in the config so each server can use a different table. If you have multiple databases then you can also have one per database. I'll have that new option ready in a day or few depending on how much I want to pass my finals :p

Share This Page