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

    Valrix

    Netstats v5:
    COMPLETE!
    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 [Web.zip] (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

    _andy

    Netstats does not appear to be working with build 493 :(

    I seem to be getting that error everytime someone disconnects from the server.
     
  3. Offline

    Valrix

    I just tested it with 493 and it all worked just fine for me. I'm not sure why it didn't work for you.
     
  4. Offline

    Zorkin3

    Seems to be working now. Really thanks for debian support :)
     
  5. Offline

    _andy

    Oops! Appears I forgot to update the .jar (derp). Working perfectly on 493 :p
     
  6. Offline

    Valrix

    Awesome, looks like I got it all fixed then. I'll be working on it more to make it a bit more customizable too without sacrificing performance.
    --- merged: Mar 6, 2011 12:04 AM ---
    Haha, yeah you need to make sure to update the .jar :p
     
  7. Offline

    vsTerminus

    Well you certainly seem to have fixed the files issue. However it seems to me that my stats are wildly inaccurate now.

    I reset them when I installed 1.8 so there's nothing left over from previous versions. Apparently, the guy who joined our server for the first time and rode in a minecart for 10 minutes also placed 1100 blocks and destroyed almost 300. Really, he probably should have zero for both.

    The time logged also seems broken, but in the other direction. It's several hours under my actual play time.

    Or maybe I'm just crazy and I actually have placed 81,000 blocks in 3 hours of play time. lol.

    See for yourself.
     
  8. Offline

    Valrix

    Well it says you've placed around 60,000 which would be difficult, but not impossible to reach. That does seem odd, but I'm not sure why the values would be so off since when I test it's always completely accurate. I have an idea of what may be going on, but I'll need to do a bit more testing to be sure.
     
  9. Offline

    vsTerminus

    My guess is it has something to do with the minecart tracks. We have 6 minecart stations, track between them all, and a tour around the server.

    vsTerminus | Broken: 60115 | Placed: 84297 | Deaths: 6 | Last Login: Sun 06 Mar 3:51 | Last Seen: 0d 0h 3m 3s0d | Total Time: 4h 12m

    I was definitely online and building things for the last 6 hours straight. Yet apparently I'm still only at four hours total time.

    Strange, right?
     
  10. Offline

    GmK

    We observer the same thing - people that have been playing for around 10 hours only have 20min logged as total playing time, and similar things.

    One example of one online player: Last seen: 0d 1h 12m 10s ago Total time: 0d 0h 1m
    Even after I let him dc and reconnect, the time was stuck at the 1m.
     
  11. Offline

    darkwarriors

    good thing to add server status like "online/offline"
    Admin loggedin

    also could be cool an automtic web start, if still there wasnt
     
  12. Offline

    Valrix

    @vsTerminus @GmK
    Then this seems to be some strange error with how player data is being managed by the server itself. I'm not sure why this is but if anyone is able to figure out what's going on or send the Bukkit dev team some data then maybe they can sort out the reason.

    My guess is that if you are getting way too many blocks being shown as broken or placed it's because the plugin is being told that the even has gone off when it really hasn't which would also drastically mess with the amount of time people have been on the server. This worries me since this basically breaks it when there's nothing truly wrong with it, it's only doing as it's told. I'm afraid that this can't be helped until CraftBukkit is more stable. Sorry guys (and possible gals), looks like your stats will be messed up for a while until things get sorted out, however I will still keep Netstats up to date and working as usual.
     
  13. Offline

    FiZi

    I didn't read through the thread to see if someone has already posted this but here is a simple PHP page that will print out a comma delimited list of players who are currently online.

    Installation instructions:
    1. Copy/paste the PHP below into your Netstats web-directory (where get.php is) as 'getOnlinePlayers.php'
    2. Include 'getOnlinePlayers.php' where ever you'd like to display currently online players on your Minecraft website. (there is an example below)

    PHP:
    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.


    File modified by FiZi to display only online
    plays are displayed in a comma seperated format.

    Modified: March 6th, 2011
    -------------------------------------------------*/

    include("config.php");

    date_default_timezone_set(date_default_timezone_get());

    mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die (mysql_error());
    mysql_select_db($mysql_db) or die (mysql_error());

    //Select all players from the database with a current status of 1
    $sqlPlayersOnline mysql_query("SELECT name from $mysql_table WHERE status=1 ORDER BY `name` ASC");

    //Loop through the returned results storing each player name into a string (comma deleimited)
    while($row mysql_fetch_array($sqlPlayersOnline)) {
        
    $listOfPlayers .= "" $row['name'] . ", ";
    }

    //Drop the last comma and print out the list of players online
    print substr($listOfPlayers0, -2);
    Then on my index.php page (http://minecraft.fizi.ca/) I have the following:
    HTML:
    <p><strong>Players currently online:</strong> <span class="onlinePlayer"> <?php include "stats/getOnlinePlayers.php"; ?> </span> - <a href="stats.php">See player stats </a></p>
    The class "onlinePlayer" is the following CSS:
    Code:
    .onlinePlayer {
        color: #060;
    }
    All that does is makes things green.

    @Valrix: Are you planning to add additional stats? Like monsters killed, items crafted, distance traveled, etc?
     
  14. Offline

    Phanku

    So...!? This plugin still broken?

    I am using it on build 493 and it seems to be reporting wrong number of hours played.
     
  15. Offline

    FiZi

    Quick update to my script. It will not print text if no users are online instead of a blank string.

    PHP:
    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.

    File modified by FiZi to display only online
    plays are displayed in a comma seperated format.

    Modified: March 6th, 2011
    -------------------------------------------------*/

    include("config.php");

    date_default_timezone_set(date_default_timezone_get());

    mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die (mysql_error());
    mysql_select_db($mysql_db) or die (mysql_error());

    //Select all players from the database with a current status of 1
    $sqlPlayersOnline mysql_query("SELECT name from $mysql_table WHERE status=1 ORDER BY `name` ASC");

    //Loop through the returned results storing each player name into a string (comma deleimited)
    while($row mysql_fetch_array($sqlPlayersOnline)) {
        
    $listOfPlayers .= "" $row['name'] . ", ";
    }

    //Drop the last comma and print out the list of players online assuming there are any
    if (strlen($listOfPlayers) == 0) {
        print 
    "No players currently online";
    }
    else {
        print 
    substr($listOfPlayers0, -2);
    }
     
  16. Offline

    TerraPlay

    Looks like a great plugin - but it's not writing data into my MySQL database. No error messages or smth., it just does nothing D: Using CB#493
     
  17. Offline

    Valrix

    As the API makes it more possible to track all these kinds of things then I will be adding the ability to keep track of them. However it seems like the ones that are already in place aren't working correctly so I'm hoping newer releases will stop breaking my plugins.
     
  18. Offline

    FiZi

    Thanks for the info. Your mod appeared to be working properly on build #499 but I've rolled my server back to the recommended build anyway.

    Feel free to include any of my PHP in your mod if you want to use it. Just name drop me in the comments :)
     
  19. Offline

    Valrix

    Yeah, it seems like some recent server updates messed up how events are being watched and firing when it shouldn't. I don't know why, but hopefully newer builds will have this sorted out.
    [MERGETIME="1299618537"][/MERGETIME]
    After thinking over how the plugins are handled, I believe I may know why statistics are being messed up. I will get to work on this when I have time. Until then please be patient until I can work out the kinks. Furthermore, I will see if a purely flatfile-based method of tracking user data would be better than using a database. If it doesn't take too much work, then this method will be used instead so we can prevent people from having to use a database and cause more problems when try to set everything up. This will also reduce the amount of resources needed to run the plugin, which is always good! I also plan on making each trackable statistic optional at startup, meaning if you have things you don't want to track, then the plugin won't even watch that event which will greatly reduce resource use and improve speed as well as allow personal customization. This may take a while, but you can keep track of my updates by checking out my twitter.
     
  20. Offline

    FiZi

    Awww. I really like the use of MySQL. It allows me to run my own queries on the data and doesn't require me to put the flat-file in a directory accessible by both my webserver and minecraft server.

    Any chance you could make the flatfile default and optionally a server admin could switch to MySQL? I'd be happy to assisting you with maintaining the database and creating a php based API for querying the data.
     
  21. Offline

    AreLam

    So.. How would stats pages work then?
     
  22. Offline

    FiZi

    I suspect the file would be comma delimited. You could read the contents of that file with your favorite web programming language into an array and then fiddle with the data there.... or dump the data into a database first and then fiddle with it from the database.
     
  23. Offline

    Valrix

    Nope, the files would remain the same and instead PHP would just change the way it fetches the data. PHP can get file data one line at a time, from there just have it look for lines with "=" and split the data using the "=" and show it that way. Would take about the same amount of work in the end.

    Don't need any help with the MySQL. MySQL is nice since you don't need to have PHP look inside a specific folder for the player data, but it also leaves many points open for the end user to mess something up as well as taking up a good amount of resources. The new problem is flatfile will take less code and ease up stress on the server while using a DB takes more code, stress, and will have to handle player data in a special way with the new "hybrid" system I made which is what's currently broken. It's getting harder to support the use of a DB, but I will try to see how well I can get it to work with the updates I have planned.

    I would love to explain how it all works in great detail, but I'm sure not many people here want to read that long post, nor would they understand half of what I would be talking about. For kicks I might write up a Google Doc on the whole process and post a link if enough people truly care about how Netstats works. Maybe this would help people understand the problem and see that it's really not so easy to give everyone what they want; however, I will still try my best to work in as many of the suggestions as I can.

    PLANNED ADDITIONS:
    Flatfile-based storage
    Timed updates
    Customized tracking

    If you have questions about the update, please ask and I'll do my best to explain.
     
    AreLam likes this.
  24. Offline

    FiZi

    @Valrix Sounds great either way. Appreciate you listening to feedback and commenting in a rational way :)
     
  25. Offline

    barristerwa

    Netstats for Dummies?
    I would love to have this functionality, but it looks hopelessly confusing. I was hoping it would be something as simple to use as the dynmap plugin. If it is, I can't figure it out. Also, I don't have a clue what MySQL is let alone have it. Is there a youtube or wiki for mac users on how to set this up?
    Thx.
     
  26. Offline

    Valrix

    This is why it's going to be changed to a flatfile format where MySQL won't be needed.
     
  27. Offline

    jascotty2

    it's much simpler once you get into it.. for the purposes of this plugin: MySQL is a database server, which can be accessed by a php script for a website. you can get the server at http://dev.mysql.com/downloads/mysql/
    (you should install it on the machine the minecraft server is on, or on another networked machine)
    these are the steps that i used in setting up for netstats: install mysql (will ask for a password to give to root)
    login to the server: mysql --user=root --password=pass
    create database minecraft;
    create a user for the netstats: create user minecraft identified by pass;
    give the user access to the database: grant all privileges on minecraft.* to minecraft;
    to create the table:
    use minecraft; (select the database)
    copy-paste the create table command from the .sql file (or run the file)
    to see what's there: describe players;
    to look at the table data: select * from players;
    then provide netstats the login info, and you should be good to go [​IMG]
     
  28. Offline

    kankan

    Hello,

    I am running git-Bukkit-0.0.0-497-gea319d1-b503jnks (MC: 1.3)
    And trying to make Netstats 1.8 working with it

    While launching my server, here is the error message :

    Any idea of what is doing wrong?

    Regards

    Nicolas
     
  29. Offline

    jascotty2

    bugs:
    the time recording seems to go off at midnight.. i started about 11-ish, and to 1, but showed 11 minutes
    deaths sometimes incremented without a death (can't track down a cause.. just that i've died twice & it said 11)
    request:
    adding distance traveled :)
    items picked up?
    - separate table(s) for which blocks have been broken/placed (optional, since would be more overhead)
    [MERGETIME="1299785797"][/MERGETIME]
    i've seen java.lang.UnsupportedClassVersionError before.. was caused by trying to run a program i built on a machine with an older version of java
    try making sure that your version is up to date.

    my computer:
    $ java -version
    java version "1.6.0_20"
     
  30. Offline

    Valrix

    Getting rid of databases should help a bit with the issues that've been happening. Also, always make sure your Java is up to date and that you're running a Recommended Build that is higher than the version in the title so you'll know that it will work.

    I don't think I'll do distance traveled since that's a bit too complex, but items picked up would be easy. And since I plan on going to flatfiles it'll be possible to track "more advanced" things like specifically picked up/placed/broken things. This is because writing to a file is much faster than using a socket connection, so the data will update faster, etc. There won't really be a need to watch for a certain number of events to go by anymore, so everything will go faster. The only possible downside is if a bunch of players are breaking/placing a large number of blocks at the same time things may slow down just a bit, but nowhere near as much as timed database connections. Now, like I said before this is a lot to change, so I'm having to rewrite good sections of the code and need to figure the best way to do this. Until then I will say that 1.8 is broken and I don't really suggest using it. Sorry to have to say it, but that's how it is.

    I'm a bit busy with finals going on, but I do try and work on my plugins when I have free time.
     
  31. Offline

    jascotty2

    another thing i just thought of you could add: how many monsters (and players?) a player has killed
     

Share This Page