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


    It writes less often than that, but v5 will work through PHP instead so the plugin won't be so slow.
  3. Offline


    why did you decided to work through PHP, I should cause more CPU usage due to usage PHP every time when inserting new data. Native work with database from only plugin should be better.
  4. Offline


    It may cause more work by PHP, but takes the pressure of the plugin which the PHP won't affect gameplay at all, which is desirable. Also, MySQL and Java don't play as nice as I'd like which makes my job harder and seems to be causing a lot of problems.
  5. Offline


    Awesome, can't wait for version 5 Valrix. All of your decisions make sense that I have read thus far.
  6. Offline


    why does netstats store data in /players/ when it's using mysql?
  7. Offline


    It was using a Hybrid method of storing data to reduce the number of database writes so the server wouldn't be swamped by a call every time someone did anything. I couldn't imagine over 100 database calls per second going well. Instead of doing that, I'm now phasing out the database aspect from the Java and it'll now be handled by the PHP and data will be constantly written to file while the server is running and when the PHP needs to know everyone's stats it'll ask directly, but if the server is down it'll ask the database. This not only heavily reduces database calls, but the amount of resources needed to run the server. It's win-win for everyone.
  8. Offline


    Not quite sure what this means, but it wont be a problem minecraft runs at server #1, and PHP at server #2, right? As I have a dedicated minecraft server, and MySQL+web on another box
  9. Offline


    My general idea about achievements will be that I will make it possible to hook into Netstats and pull out stats so other devs will be able to make their own achievement plugins and use Netstats for the data. This doesn't mean I won't be trying to work on my own achievement setup, but will allow more options.

    Correct, it won't pose any problem at all and actually will fix a good number of older problems.

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


    Here's a question - can this stats system handle input/data from multiple worlds? Ideally, we need a stats system that can calculate the stats of the same players playing on half a dozen different worlds.

    Is this possible?
  11. Offline


    Once I get it into v5 and see how well it performs to see if I need to do some performance tweaking and bug fixes, etc. and everything is working safely then I will be working on multi-world support. I remember someone before suggesting how it works and I'm sure it won't be that hard. I think I'll just have to see if I can keep track of which world the player is in and keep a different set of stats depending on the world. Though I'll need to make sure I can check when they begin changing worlds so I can stop all stats when they start transferring, then when they join make it act like they just joined the server. I'm not sure how world changes are currently handled, but once I get it worked out and fully understand it I will definitely be adding support for it. Until then, however, all stats are just per person on the server as a whole.

    Good news for everyone: Yesterday I got a LOT of work done on Netstats by phasing out nearly all database dependencies and altering the config file. I'm also going to start allowing the admin to change the config from within the game for even more dynamic tracking. Netstats will also be getting it's own /reload function by doing /netstats reload as well as having a /netstats update and an option to have it do update checks every now and then to keep up on the latest versions. I hope to get even more done today and maybe get rid of all DB connections and start working in the new stuff. Sadly it's a long, slow process while improving old code. Just thought you'd all like to know about the progress I've made.

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


    Keep up the good work! Can't wait to see how it works once updated. :)
    LuigiPeace likes this.
  13. Offline


    And what can I do if my Webserver and MySQL is not in one PC
    And If I do not have default (3306) port, there is no config file where I could change that...
  14. Offline


    You can have all 3 on different servers and it won't matter. PHP can connect to MySQL wherever it is as long as it has the right config, which the PHP has a config file, so YES there is a config for that (pun intended). The plugin server, and webserver are standalone and can talk as long as they're given the right locations to talk to each other, which is the same as the webserver and the database. v5 will just use the PHP as a load mediator when it needs to do database stuff so calls are kept to a minimum and performance is increased.
  15. Offline


    Okey, but I still cannot find the line in the config file where to change the port... There are hostname, user, password, database but no port.. So my guess is that PHP use default port.. But I do not have default port, so how can I add that?
  16. Offline


    You would include the port in the hostname. So as an example:
    $host = "";
    Would use port 5555 for host
  17. Offline


    Can you view their time in-game? I see no commands for this, what so ever.
  18. Offline


    Currently it has no in-game commands, but v5 will have commands like:
    /netstats help|? - Returns this list
    /netstats update - Safely updates Netstats
    /netstats reload - Reloads Netstats
    /netstats get:config <option> - Check a config option
    /netstats set:config <option> - Set a config option
    /netstats get:stats [stat] <name> - Get a player's stat(s)
  19. Offline


    When will the v5 be ready?
    The playtime in the stats, are really fucked up. Remember to fix that! :)
  20. Offline


    I've been working on the monitoring classes the past few days and have been working on phasing out all database calls and calculating playtime quickly, and efficiently as well as very, very accurately. The block and player listeners are almost done, then I just have to work on death, attacking, etc. and finally delete the database class and work in it's replacement for data transfer, which has been partially worked in already.

    I've also been replacing the old commands with the new ones I'll be adding while trying to keep the cyclic complexity to a minimum. Luckily these changes are removing tons of code and old checks that were in. For instance, now instead of each function doing a check to see if the player exists in the players list, when Netstats first starts it'll add all currently online players to the list. This being in the onEnable should make the server stop while it loads everyone (if there's a LOT of players) so nobody's stats can get fucked up while it's enabling itself after a reload or something.

    The plugin's server is also a blocking server (sits and waits for a connection before it does anything) and runs on a different thread so each ping it gets it won't slow the game at all. In addition, all messages between the server and PHP are going to be single strings of all the player's data so it gets sent quickly, and without taking up a very large request.
    rmbell and LuigiPeace like this.
  21. Offline


    Alright everyone, I'm over half done with v5 and finished the Block/Player/Death tracking classes today so all that's left is to finish server-to-PHP communication, automatic updates, and the class to update everyone's stats to the database.
    ScottCameron and LuigiPeace like this.
  22. Offline


    On a rough note, how long are we looking at for this to be released?
  23. Offline


    Quite soon. If lucky I'll be able to finish at least one more of the class files. Once the plugin is done I will have to finish working on the PHP to accept data from the plugin's server then I will release the update. Next week are my finals so I won't have much, if any, time to work on any plugins but after that I'll have all the time in the world. So my goal is sometime during the week, but that's just me being hopeful. Realistically, the week after would be when I would release it depending on the 1.7 update.

    It's looking great guys! Everything is actually working as it should when it comes to tracking. I still need to test multiple-worlds and see how that acts to be safe. But a few questions:
    How should the plugin keep track of time? At the moment it keeps absolute track up to the number of days, should it keep track of weeks, months, and years as well? If so, how should they be kept track of? Weeks will be easy, but months vary in length and I'm not sure what number to choose as a year. The normal 365 days, or the "business year" of 360 days?

    Ok, now that the questions are done, here's what I've done today and the past few days:
    Today: I changed tracking to be based off each player's UUID which was recently implemented into the game. This way I don't have to care about how crazy a player's name is. I've also finished the server and re-writing everything so the plugin never has to even think of a database. Instead, the PHP will handle that.

    What's left to do? Well, I need to make sure it works with multiple worlds, integrate it with the PHP so they can communicate, finish the updater, and test the hell out of it to make sure it'll work seamlessly when I release it. I also have to finish the PHP because it'll be the only way for you to keep your old stats. The database will also be changing quite a bit as well. When it's time to release the update, there will be very specific instructions on how to safely update, otherwise you WILL lose EVERYTHING.

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


    No news is good news? Or?
  25. Offline


    What you mean? You did read the latest post right?
  26. Offline


    This is awesome news Valrix, I'm very happy to hear that v5 is coming along nicely! How's other plugin info looking for that version (iConomy mostly) ?
  27. Offline


    Getting info from other plugins will be handled by the PHP asking the database for info.
  28. Offline


    Glad to hear everything's looking good. For the sake of simplicity, I would just go with tracking years and weeks, with a year defined as the standard 365 days. If you really want to track the number of months, I guess the way to do it would be to have an associative array of the months and number of days associated with each, parse the month the user joined from their timestamp, and then loop through the array starting at that month subtracting the number of days from their total until it it's less than the value at that current month in your loop. In my opinion, that's not going to be a terribly demanded feature and it's overly complicated. A user would need to clock about two years in game time before it would rollover the weeks to three digits even.
  29. Offline


    I decided to keep it at days and the rest can be calculate with the PHP however the admin wants.
  30. Offline


    Props for keeping it simple. Has the release of the new RB prompted any new bugs/roadblocks for v5?
  31. Offline


    Actually, it came up with a fix. When they added UUIDs for each player in 860 I was able to convert all references of player names to instead check their UUID which is always the same and I don't have to deal with uppercase/lowercase issues. It helped me cut down a few lines of code and be more accurate when referencing a player. I stumbled a bit when it came to the server having to reload when Netstats or the whole server is reloaded, but now that works just fine. It'll default to listen on port 9999, but will have an option to change which port you want it to listen on.

    A new feature I'm happy with is being able to change the config from within the game, and to make sure only the admin can do it, I've left the admin property in the config and it'll match the person sending the command to the config to make sure only the admin can change anything. I would love to get rid of having to use a database since it's so slow and harder to alter, but the tradeoff would mean to use files in a PHP folder called "data" or something similar. The perk to doing this is it would no longer need a MySQL database which means less configuration, faster data access times when the server is down since it's just reading from files, and a lot less resource usage. I know I've tried to do this before, but the way I went around it last time wasn't very good. This time, not using a database would be easy and have less chances to go wrong.

    A general question for people: How about getting rid of the MySQL database again, but this time it can work for everyone's different kinds of setups because it'll only need you to install the plugin and set up the PHP like normal, but without providing database information. Instead it'll save to small files like it does for the plugin so when the server is down or Netstats is being reloaded, the data is still there. Using this method is many, many times faster and safer while requiring no need to mess with the database which seems to be the main reason for all the problems everyone has. The new method will work for everyone, I can assure you. Plus it means getting v5 out sooner for you all to use, but I'm asking to be fair to the people who will be using it.

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

Share This Page