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


    I noticed the same people who have years added are the same people who tried to use flying and speed hacks according to my logs. They were probably messing around with their system clocks.

    The ajax version is calculating time correctly but the include I'm using in my webpage shows zero seconds for most people.
  3. Offline


    Is there a way to make it track each mobkill separately? Like a separate column for Creepers, Spiders, Chickens, etc.
  4. Offline


    Mechanicalocaean, if you look at the mysql database the recorded table is mobs killed. There is no separation at the moment, so I guess that would be a feature request.
  5. Offline


    My netstats won't crate a table on my mysql is there some command i have to do or am i doing it wrong?

    heres the error code
    # Netstats Error Log
    CraftBukkit Version: git-Bukkit-0.0.0-706-gf53e007-b740jnks (MC: 1.5_02)
    Netstats Version: 4.6
    MySQL Error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'mc1934db.netstats' doesn't exist
    Offending Statement: UPDATE netstats SET logged=0
  6. Offline


    Correct, I haven't had time to implement separate tracking of each mob. Though it is a planned feature.

    The next update should fix all the current problems going on, please wait.
  7. Offline


    Oh *FACEPALM* i didn't see your post about the update.....I usually check back before i post questions like that I apologize for my stupidity lol.
  8. Offline


    It's fine.

    I've just pushed out v4.7 which will allow for database auto-creation and has lots of code improvements and fixes as well as improving a few calls to the database so when I was doing about 3 calls one after the other, now they're mixed into a single statement that runs through each call so the database connection is only opened once for all those calls instead of: open -> SQL -> close, open -> SQL -> close, open -> SQL -> close. Now it's: open -> SQL, SQL, SQL -> close.

    For those who like looking at the source, I've also updated the repo to the most recent code (meaning you can see what I have on my own computer, no changes yet). Now people can help find errors (which I hope there are none, for once I'd like a break and be able to fix my other plugins and work on the web code a bit).

    Also, keep in mind that v5 will require a lot of code rewriting and you will HAVE to restart your server after updating to it since it'll need everyone to be offline otherwise any data loss will be your fault. From what I can tell there should be no bugs floating around and I even tested this out many times, remaking the database over and over and playing to test if it count blocks breaking and so on, so I know it works. As always, I appreciate feedback from everyone so I can get to doing any fixes as soon as I can. Once my school load decreases a bit (if it doesn't then this will be quite difficult) then I will continue working on v5.

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


    nice, checking it out right now
  10. Offline


    Hmm, this i weird.. The playtime dont work perfectly? It seems like it is set so 10 minuts is 1 sec or something like that on the get.php tabel.

    How can i fix this?
  11. Offline


    Is this your first install, or are you updating from a previous version?
  12. Offline


    This is the first install
  13. Offline


    It should work fine then. I did a lot of testing by removing the data folder and rebuilding everything.
  14. Offline


    Try look at this get.php
    As you can see, it is not working correct.
    # Netstats Properties File
    # Both oldTable and newTable are optional
    # Optional things to track. True = track, False = don't track
    And if you need it, the php config file:

    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.
    ------------------------------------------------- */
    $mysql_host '';
    $mysql_user 'web1345';
    $mysql_pass '********';
    $mysql_db 'web1345';
    $mysql_table 'netstats';

    # What you want to be shown, change to false if you want it hidden
    $trackIP       false# IP address
    $trackBroken   true# Number of blocks broken by player
    $trackPlaced   true# Number of blocks placed by player
    $trackDeaths   true# Number of times player died
    $trackMobs     true# Number of Monsters killed by player
    $trackPlayer   false# Number of Players killed by player
    $trackJoined   true# Date of when player first joined the server (with Netstats running)
    $trackDistance true# Total distance player has traveled
    Why cant it show the play time as it is?
  15. Offline


    Hmm, the config looks I'm not sure what could be doing it. I'm not sure what you mean by "Why can't it show the play time as it is?". It's supposed to just record how long someone has been playing, then calculate it out. When v5 comes out, it should solve many of these recurring problems that, oddly enough, never seem to happen to me which makes it difficult to test and find the source of the problem.
  16. Offline


    Did you saw that link i posted to the get.php file? Look in the playtime. It is looking like 1 second is 10 minutes because MasterDnk has been online for a lot of hours now and have only got 38 sec in playtime?
    Try look at this get.php
  17. Offline


    What do I have to use to create a table? Because there is no sql file in the 2.1 zipfile
  18. Offline


    I'm just wondering.. Is the Web 2.x actually (dramatically) slower than the 1.x or is it just me?
  19. Offline


    No, I'm sure it's slower due to how it checks for updates at the moment. The next version goes a lot faster since it handles the update process in a completely different way than 2.1 does. Future versions will also have more advanced things that the admin will be able to control such as backing everything up via PHP and being able to watch as it happens instead of it firing somewhat randomly whenever someone checks the stats.

    On that same note, the next update will need to be done manually because of the new setup, but luckily after this most everything should be automated. The only thing left before the next update is adding an admin login to the update page so only admins can start the update. Once that's done then I'll be pushing it out for everyone. I'll also check on the weird playtime bug to see what can be causing that, which I have a slight idea, but I'll need to check to be sure.

    That's the beauty of Netstats, it doesn't need .sql files because it makes everything on it's own. I've taken some time to post instructions on the first post, please do look them over before posting.

    Alright everyone, I've checked the code over and over and can't see why the time would be freaking out like it seems to be doing and without extensive testing, I don't think I could find it any time soon. My remedy for this is that you'll just need to wait until the v5 update which will calculate and save time in a different way than it is now, which is my only thought of why it could be getting messed up. For now you'll just need to wait until I can convert the code over to the v5 format which I'll start doing after the next Web update.

    From there I will work on porting the Java to v5 and simultaneously be changing the Web code to v3. Here's a small breakdown of the new features:
    • Plugin will have auto-update capability
    • Faster management of player data
    • Improved database to specifically save certain data (less calculations)
    • Fewer database calls
    • Smaller footprint (less resource usage)
    • Smaller plugin size
    • Improved web code
    • Direct access to plugin data (PHP -> Plugin for instant, accurate data)
    • Selective data retrieval (If player is logged in, data is grabbed from plugin; otherwise it's grabbed from the database via a PHP database call)
    • Web code will be able to back up the database (possibility of Java running PHP code after a set amount of time to create a database backup)
    • Admin page w/ controls over certain workings of the site (possible web control over the plugin)
    In essence this all means that the new way the plugin and PHP will communicate would mean the admin could control the server and maybe even edit the config via the admin page. Not to mention better updating methods for Web code and plugin code which will use the new /update/ folder recently implemented by CraftBukkit.

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


    Yeah well, that's the problem because it doesn't create the table while I changed the config file to my database settings.
  21. Offline


    The latest patch should have solved that problem, oh well. Here's the .sql file to make the table then if it's not doing it on its own. netstats.sql
  22. Offline


    Thanks, but when I login on my server Netstats doesn't update the databse/table.
    I have my host set as and set my username and password to the user settings

    Is there something I'm missing?
  23. Offline


    If something isn't working then it'll say so in the server.log file. I have every error shown there.
  24. Hello, nice plugin !

    I have a little problem... some players connection time pass to "41a 23m 2s 10j 15h 52min 14sec" Oo

    I also have some errors :
    Any idea ?
  25. Offline


    The weird time bug can't really be fixed since I'm not sure of the cause, but may I see your config.txt to verify my suspicion of why you're getting that error?
  26. (I'm sure of "*****" informations, there only is a probleme with connection time....)
  27. Offline


  28. I'm sure that you're a great programer, but do you looked into others stats plugins sources ? (lot of them are innactive)

    I make some program (in Python, or php) and looking into others opensources program's sources help a lot :)

    I really want to help you to find the answer, but I don't know java language...
  29. Offline


    No, all the plugins I make use my own code that I slave over to get working. The main idea is to just upgrade it to v5 so these problems will just "go away" since the data will be sent differently than it is now.
  30. Ok, good new. Thanks for the good support. Good work !

    PS: I'm looking for a java programmer 'cause I've got many idea... If you want to know more about it, PM me, we could create some really good plugins ;) Some, revolutionnary plugins ;)
  31. Offline


    I always like the idea of making more plugins, but I'm already behind and have a few more that I need to make as well. I'm always up for people asking if I could make a plugin and if I like it and think I could do it then I'll add it to my To-Do list.

Share This Page