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


  3. Offline


    ( ! ) Warningmysql_fetch_array() expects parameter 1 to be resourceboolean given in C:\wamp\www\netstat\data.php on line 153
    Call Stack
    #    Time    Memory    Function    Location
    1    0.0004    670488    {main}( )    ..\index.php:0
    2    0.0052    846200    
    require_once( 'C:\wamp\www\netstat\data.php' )    ..\index.php:23
    3    0.0058    846792    mysql_fetch_array 
    ( )    ..\data.php:153

    meep can anyone help :(
  4. Offline


    I'm glad you got it all working and like it! It's taken quite a lot of work for it to get where it is, even though it is a bit broken for some. The support is appreciated :)
  5. Offline


    [24-May-2011 15:16:39PHP Warning:  rsort() expects parameter 1 to be array, boolean given in C:\inetpub\wwwroot\netstats\updateManager.php on line 14
    [24-May-2011 15:16:39PHP Warning:  Invalid argument supplied for foreach() in C:\inetpub\wwwroot\netstats\updateManager.php on line 15
    a little help with that?? anyone know?
  6. Offline


    my playtime still dont upgrade itself its normal? it add 1 seconds every 10 minuts.. pls help me!
    i use the same old table of old release! cb 766 and latest netstats.jar mysql innodb
  7. Offline


    That means that somehow the script failed when getting a list of files from my ftp server even though it successfully connected. I'll patch that now. As a side note, it doesn't mean anything bad happened, just that you couldn't get a list of files from the server. Later I'll add a case to check if that fails and if so it'll try to look for updates using another method.

    Yes, I've already stated numerous times that the playtime is still messed up. There hasn't been a plugin update yet so it's not fixed. Wait until v5 is ready because that'll fix the problem.

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


    how do you retrive it? i hope u will not use a counter or a timer for this features, like in mmoprg like wow and lineage 2 i coded playedtime in this way;

    Disconnect player time - entry player time ; and if a player crashes and cant load event onplayerdisconnect i set every 10 minuts a control that if he doesnt found the player online set disconnect time = entrytime+10minuts. forgive me for my horrible english i want to give only some help!
  9. Offline


    I do it as play time += (current time - time last seen) which there are config options to specify when player data is saved. In v5 since the database will be gone, all data is saved to the player file and read by Netstats' server which will talk to the PHP code when asked for data, this way the plugin has a much smaller chance of messing up any data since the PHP will be handling all database connections, if any.

    No need to apologize, I know how many non-native English speakers are here, at least you're trying :)
  10. Offline


    Only track players with a permission node set, if permissions is enabled.
    eg: netstats.track
    I'd prefer only to track/display users who are "Members".
  11. Offline


    That's a good request, I'll make sure to add that in. Thanks!
  12. Offline


    so for users that dont use your js script? but use database and his own scripts (only selection ), playedtime would not be compatible?
  13. Offline


    All the web code can be customized however you want, but there are of course things that'll have to be there which is the point of writing all this php and jQuery myself. If the user is able to use dynmap (which most should) then you won't have any problems with using v5. The point is to take the load off the server and instead put it on the PHP because currently the plugin leaks a lot and lags the server too much which I can blame on the MySQL implementation that I've had to work out.

    For users who don't have their own web space or want a free/cheap one with easy scaling, git support, and more then I would suggest looking at a new service called phpfog which supports custom php apps, etc. I will be testing how well the Netstats web code works on their service and if it works perfectly fine then I will officially suggest it since their free plan lasts for 6 months (per app) so once the 6 months is over you can just delete it (after backing up the data) and make another free app that'll last another 6 months or you can upgrade and pay. Plus it has easy scaling if you need it to have a boost. I'll post back after I do a bit of testing.

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


    I'm interested in how far v5 is coming along :)
  15. Offline


    Well the web code now has an admin page with login and the ability to check for updates instead of it being forced when looking at the page. The check and commands will be issued with jQuery so they can be watched as they work as well as being done in the background (no more staring at blank page until it's done loading). A user is contributing his own Minecraft theme which I will create a script to keep updated. I've started phasing out some of the database code and figuring out how to transfer the data between the plugin and PHP as fast as possible. Since the data doesn't need to be protected I won't have to encrypt it which means faster data transfer, less load, etc. I will be adding a button for the admin to initiate a database and/or data file backup. I'll be adding a way for admins to issue commands to the server as well and will see if I can get it to return a response from the server. At the least, the admin will be able to broadcast messages from the admin page. Users will have a customizable experience on the site by being able to choose their own localization and if their flag is wrong or unkown they will be able to click it and "suggest" what it should be to the admin who'll have notifications when they log in to the admin page (kinda like a personal inbox). More work on the player's custom stat page which has an interesting little "surprise" that I'll be adding in later (maybe more customization). Permissions support to choose what users will be tracked based on a "netstats.track" permission node. Also, the PHP code will "ping" the plugin to see if it's up and if not then it'll ask the database for info, this way even when the server is down, the info will still be available.

    So, all that with probably some more stuff that I'm forgetting. In the end, this will make the config file smaller and make the plugin a lot faster since it won't have to do any MySQL queries.
    AreLam likes this.
  16. Offline


    That's a lot of new features... Good luck !

    I actually use my own "php script" to display stats thanks to MySQL. Maybe I'm wrong / doesn't understand well, is MySQL will not be used anymore ?
  17. Offline


    Is it possible for someone to help me with basicly the WHOLE setup. Cause in phpmyadmin i can't understand what alot of it means (i.e. on the "enter" colomn it says 1306335728164 or something similar on each person). Also i can't seem to get the Web thing to work. Not even on locally on my server pc.
  18. Offline


  19. Offline


  20. Offline


    Actually, the code to do that is already in the data.php file. It's near the top.

    The database will be left alone for the most part. The main thing I'm going to change is how time is saved and calculated.

    Yeah it is, thanks! MySQL will still be used, but only when the server is down. That way, there are fewer calls to it and less time is wasted. Luckily, all the variable names will be kept the same except for the change to how time is stored. To elaborate, each fraction of time will be saved separately instead of a single "playtime" variable that has to be calculated out each time. This also makes the data transfer size much smaller so you'll be able to see your stats with 99% accuracy almost instantly. I say 99% accuracy because if anyone does anything between the time the PHP page asks for everyone's stats and you see them they'll be off by a few seconds or a few blocks have been placed/broken, etc. Though nothing is actually wrong about it, it's just "old".
  21. Offline

    Phantom Index

    It'as asking for much, but after seen that custom interface, that tab idea for skills is great.mcmmo web stats is inactive so probably this could work if put together.
  22. Offline


    I Test this Plugin and the plugin write into the Database but on the website i see nothing pls help
  23. Offline


    What code can can i use in the display page to format the date/times? how do i convert this number 1306422376342?
  24. Offline


    I totally overlooked that myself :eek: What I am using for the avatars is this.
  25. Offline


    Yeah, tabs look cool and could probably be done pretty easy with some nice jQuery. Actually, it can be done easily with jQuery now that I think about it.

    Already stated that Netstats is currently under heavy development and doesn't work 100% correctly at the moment. I'm also a bit busy to help with setting up the web code.

    I'll be changing how time is calculated in v5 as well as changing how time can be shown.

    Ah, not bad. Yeah, the code is already there ^^
  26. Offline


    Warning: file_get_contents( [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /var/www/clients/client1/web1/web/minecraft/plugins/Web/2.1/data.php on line 211

    Warning: copy(img/flags/.png) [function.copy]: failed to open stream: No such file or directory in /var/www/clients/client1/web1/web/minecraft/plugins/Web/2.1/data.php on line 216

    Dont know since the Error exist.
    Dont change the PHP files the last days.
    befor 2 or 3 days there was no error
  27. Offline


    Looks like the website died? It's having 500 internal server error on the frontpage (

    Edit: Looks like the site is up again.
  28. Offline


    I would be happy if you could fix that playtime bug. Alot of my players have like 147 years playtime?!
  29. Offline


    That'll be resolved when updated to v5, otherwise since I can't figure out what it is that's causing the problem, my only solution is to continue working on v5 and make it reset playtime. Then all data from the database will be pulled down to flatfiles, the database will be dropped, then built again and updated to the new format.
  30. Offline


    Yes, error is away.
  31. Offline


    How often your plugin writes data into DB?
    I mean it should collect some data and flush it every 5s or more.

Share This Page