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've fixed the bug that messes up everyone's play time, I just need to release it which will be done in a few minutes. To help with the other problem I'd have to see how things are set up, but from what I saw on the website...everything looks fine.

    Updated to 4.6 which should fix a bunch of the problems.

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


    Can you just make this plugin create its own database like others do? I've been reading posts on this thread for half an hour and still have no idea how to use this plugin.
  4. Offline


    Yes, much lack of documentation on how to use. You need to setup your MYSQL info in the config.txt of the plugin.
    The SQL file isn't provided in obvious location for users to find. I found it on the forum here.
    @author: Please make a simple 1, 2, 3 step setup guide.

    I configured my plugin, but when running on the serevr it generates constant errors:

    CB 754

  5. Offline


    Because not everyone can just make their own database. If running through a host then in most cases you have to make a new database via some sort of manager which is why I have you put in the name of the database.

    When there's only two config files you'd think it would be obvious when setting it up, but it looks like I'll need to have an instructions section on the first post.

    First thing to note is that I don't support builds that aren't Recommended Builds because those can have bugs and such that can mess with plugins, but I will check that out just in case.

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


    Maybe I missed it, but are there install instructions somewhere? I have sqlite for big brother. But I have no idea how to set up the config...



    I see now there arent any. Maybe just a link to somewhere that shows how to set up a db? Then let us know how to tell this plugin to use that db?

  7. Offline


    A lot of people also don't know how the database works, where to find it, or what exactly they need to type into the config to make the plugin work. Have you ever had to teach a relative who's new to computers how to check their new e-mail account or something similar? If you have the patience and the compassion, write a guide for this plugin the same way.
  8. Offline


    If you don't know how the database works, then this plugin is probably not for you. It assumes you know at least SOMETHING about a MySQL database and PHP so you can set it up, otherwise there's vast amounts of data about both on the internet that you can go absorb. I'm also not going to take the time to explain every possible way for each different person to get it to work with their host.

    You're young like me, it won't kill you to learn something new, especially when it's just phpMyAdmin.
  9. Offline


    although i agree with your statement that
    there is alot you ARE obligated to provide like.. i don't know stating *If you don't know how the database works, then this plugin is probably not for you.* in your op so that people who know nothing about sql/php dont get too invested in downloading ect and although i agree google is a great resource for learning not everyone learns through visual means. Some are tactile and its not up to you to decide that one method is universal to do so just shows your ignorance :D
    after a few days (not knowing anything about phpmyadmin/sql or php i have learned enough to create a database,load the tables and edit php to my liking to style my page) this is not because i am *smart* this was research and trial and error prob because im a more hands on type nor is anyone dumb for not knowing these things :D not everyone is into everything no matter what someone might proclaim there is always something new to learn
  10. Offline


    Can you please include an importable MySQL table in the OP? The newest version I just downloaded of Netstats doesn't seem to generate it for me, thank you!
  11. Offline


    As long as you have correct database permissions and the config is done correctly the table will create itself. If not, then it's user error. I suppose I can have an .sql file available for people if it doesn't seem to work.

    I'll make sure to include such a statement when I'm more coherent. It's 3 AM at the moment...but editing a PHP config file is as easy as a altering any plain-text config and much easier than trying to change a YAML config file by far. As far as phpMyAdmin goes, if you can't navigate your way around it, then even supplying the .sql file wouldn't matter. I've already tried spoon-feeding damn near everything for the user already so this wouldn't be an issue. I'll try adding a method to create a database if it doesn't exist for convenience, though I see it being more of a pain than being helpful.

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


    Any chance you could throw the .sql up on here now? Or just copy/paste it here and I'll save it as a .sql? I've been trying to get this plugin to work for ages now, but trying to pick through you source files to find the most recent table generation is not working out. I keep getting errors while running it because the table fields I can get from github obviously aren't accurate =P

    Disregard, I managed to find a post somewhere with each category name and whatnot. So correct me if I'm wrong (no errors yet, and so far it is counting correctly) but this should be what the .sql file looks like (just copy all, paste in notepad, save as *.sql and import to MySQL)

    # Dump of table netstats
    # ------------------------------------------------------------

    CREATE TABLE `netstats` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `player` varchar(50) NOT NULL,
    `enter` bigint(20) NOT NULL DEFAULT '0',
    `seen` bigint(20) NOT NULL DEFAULT '0',
    `total` bigint(20) NOT NULL DEFAULT '0',
    `logged` tinyint(1) NOT NULL DEFAULT '0',
    `ip` varchar(40) NOT NULL,
    `broken` int(11) NOT NULL DEFAULT '0',
    `placed` int(11) NOT NULL DEFAULT '0',
    `deaths` int(11) NOT NULL DEFAULT '0',
    `mobskilled` int(11) NOT NULL DEFAULT '0',
    `playerskilled` int(11) NOT NULL DEFAULT '0',
    `joindate` bigint(20) NOT NULL DEFAULT '0',
    `distance` double NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
  13. Offline


    Instead of latin1 for the charset it needs to be utf8, which I changed in your post and made bold, otherwise yes that'll work.
  14. Offline


    This is a poorly documented Plugin. That is not in question no matter what defense is given. The rational people are not asking you to write an API for it, or write how-to for MySQL or anything like that. What people are requesting is a nice little how-to guide. All other plugins manage to provide at least basic instructions on getting it setup.
    1- Putthe plugin in plugins folder.
    2- Start server, allows default files to be created, restart server.
    3- Configure MySQL settigns in the config.txt of the plugin's folder.
    4- etc, etc, etc.

    Providing the create table statements would be nice as well. Or maybe tell us where we can find the queries int he existing files, if they are there. As there is no documentation indicating anything.

    I would not think this is a difficult thing to do at least to show people how to use it. Again, the rational people are not askign you "to take the time to explain every possible way for each different person to get it to work with their host."

    The fact that you do not even have the basic general setup procedure is one reason why you are getting requests on how to configure many things, because no where is it mentioned how to configure any part of it. Which is sad. I think this has potential, but people cannot use it if they do not know how to set it up. You created it, not them. At least have the forsight to help others use it as well by giving some brief explanantion as to how to set it up in the first place.

    Thank you for your work, btw.


    P.S. The CB 754 may be different, but I am using 50 plugins on the server, and they do not gerenate errors, even though made officialy for 740. They all work. I will wait to post again until another version comes out for another future recommended build. Thanks.
  15. Offline


    honestly if you can't figure out how to get the plugin working you really don't have any business running a bukkit minecraft server..go back to the official server heh
  16. Offline


    Burn! Nice of you to join in.
  17. Offline


    Your comment is pretty worthless and stupid. 99% of bukkit plugins require little more than throwing them in the plugin folder and configuring the text files to ones liking. You are not special, anyone can run a bukkit server.
  18. Offline


    Ok, after hours and hours and hours of attempting to get this to work as a viewable webpage - I found out GoDaddy web hosting does not allow access to external MySQL databases. Alternatively, I simply moved my Netstats database (leaving all my other db plugins on my server PC) to the GoDaddy web host and it works just fine. I only get 1 error and that is when I goto the webpage. The table opens up, looks great by the way, but at the very top there is like a header bar with:

    Warning: copy(img/flags/.png) [function.copy]: failed to open stream: No such file or directory in /home/content/86/7649886/html/mcstats/data.php on line 216
    Warning: copy(img/flags/.png) [function.copy]: failed to open stream: No such file or directory in /home/content/86/7649886/html/mcstats/data.php on line 216
    Warning: copy(img/flags/.png) [function.copy]: failed to open stream: No such file or directory in /home/content/86/7649886/html/mcstats/data.php on line 216

    If you could help me get rid of this, you would be my hero - thanks! (on a sidenote, apparently a few of my members don't see this error message when they goto the website)
  19. Offline


    GoDaddy is terrible, and I mean absolutely terrible. I've never, not even once, heard good things about them.

    Anyway, it looks like it wasn't able to find the correct country code for the IP or something of the sort. To be honest I'm not positive what the problem is and would need some IPs that tend to fail so I can see if I can work around that problem in some way. It's nothing really bad, just saying it couldn't copy over the flag which can be caused by one of I think 2-4 possible things going wrong. It's not much to worry about and I'll find a way around it sometime soon I hope, until then I'll have the next update hide those errors.

    That's all this plugin really takes. It's been stated that it requires MySQL, so if you don't know anything about MySQL database AT ALL, then obviously you shouldn't be using this plugin. Besides simply having a database ready for it and a web host for the PHP files to actually show the stats, all you do is drop in the jar, run it once so it can generate everything (which is noted in the changelog and features list I believe), then it clearly tells you in the log that it kills itself because the config isn't set up which anyone would understand "Oh, I need to go fill it in.", do so, then restart the server so it can load in the changes. Plus I made sure everything is clearly labeled so damn near anyone should be able to do this, and I agree that if you can't edit a small text file and make one database then you shouldn't be using a CB server at all.

    I would have to agree with you. I've made it harder on myself to make it nearly as easy as possible for the end user to get this whole thing running without having to ship out a fuck ton of files and folders, .sql files, etc. just to set it up. I've automated nearly everything and even made it possible to change the table name FFS, which please show me another plugin that does that for you while preserving all your info and all you have to do is change one value in a text file to do it. Hell, I even made a secure way for an admin to wipe the database and player files from not only in-game, but command-line as well for the transition to v4 and as a fast way to clean up everything if something goes wrong. AND in the future when it does timed updates it'll create a backup of the server which the config will have an option of how many backups to keep so you can choose how far to roll back or whatever.

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


    So the argument of not providing installation instructions boils down to " if you can't edit a small text file and make one database then you shouldn't be using a CB server at all."

    I am defending those people who are posting about how to get this working, because they cannot find clear documentation. I have the DB setup, and config files, the problem is the plugin does not run due to the newer CB version or the conflict with other plugins. I am not arguing for those who are posting about how to get their MySQL database configured, nor configuration between different hosts. This is not about editing a "small text file". Nice fallacy.

    To reduce the argument for proper documentation to the above, is telling on the part of those who espouse such a low view of the people posting here. They are asking for your help, and this is what it comes down to? That they are simply not able to add data values to a text file? Please read their issues again, and my arguments. Please go look at the majority of plugins released: they do assist the plugin users with minor documentation on the plugin page.

    I hope you come to see how you can further help people in such an easy way. It does not require you to continually post to all the requests for help. Those will be reduced in number. A little blue section for "Configuration" is all they need :) Thanks. Peace.
  21. Offline


    Thanks for the quick response. And after looking into it some more, I get the error because I'm connecting via another PC through the same router (so my IP is a router assigned IP so I'm assuming it can't match that to a region). And the other guy who receives the same error messages isn't entirely sure about his internet, but he's from New York and says he has Verizon, so I guess he has one of those wireless cell-phone networking cards. Hope this helps :)

    Also, using your pre-made table layout on the website, clicking the column title to sort in ascending/descending order dont work right in the following categories:

    Distance Traveled
    Play Time
    Player Locale
  22. Offline


    I'm too busy to do any personal responses at the moment since I've found a few bugs which is probably why the tables aren't auto-generating like they should. When I was doing the last fix some of the code seems to have just disappeared (yet somehow compiled without any errors...) and that's why it's not making the table. I'm also going to try and add in code to have Netstats attempt to make a database for you, but if so I will force a few things. For one if you don't specify a database in the config it'll try to make one called NetStats with a table name of stats inside it. I imagine this will fail on some systems, so if it does fail it'll report back to the admin it couldn't make the database and will promptly kill itself so nothing else can go on. From there the admin will be on their own making the database and supplying it's name to the config. You also will NOT be able to rename the database like you can with the table because that's far too much work when just making it possible to change table names took many lines of extra code and a whole rewrite of how the database is handled.

    TL;DR I'm going to release a patch soon that should fix the table-creation bug. After that I'll work in database creation. In case you didn't notice yet, I've also started on writing install instructions. They'll be relatively vague in some areas since some things are drastically different depending on the OS, permissions, etc. The best I can do is try to write something that'll be broad enough to at least help push you along.

    Ordering is being worked on. I've got a lot going on and can only get so much done at once while still attending classes and not going insane.

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


    Could you perhaps add mobs...So a stats page for creepers XD
    Creeper: Player kills- 9001
    Maybe this would be useless for the other sections such as blocks broken etc
  24. Offline


    I dont get it, so how do I check how long someone has been playing. Is there a command?
  25. Offline

    Brendon Morgan

    I was helping tomgsx out and came up with a quick hacky solution to the unknown locale issue (this is within data.php): -- Line 126 is where my minor changes begin.

    For this to work I had to create a new image called "unknown_cc.png" for the unknown locale and place it within the img/flags folder. It can be found here:
  26. Offline


    No commands, you have to either check the database manually - or goto the address you have setup for the 2.1 Web index.php
    (my netstats 2.1 web example: HERE)

    I don't think there are any in-game commands to my knowledge.
    kahlilnc likes this.
  27. Offline


    Nice, thanks for an image too since I didn't have one yet.
  28. Offline


    trying to use:
    include_once 'netstat_config.php';
    $playersOnline = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM ".$mysql['table']." WHERE logged=1"));

    but getting this:

    Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/sunwind/ on line 27
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/sunwind/ on line 27
    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/sunwind/ on line 27
    it seems to be trying to use the local server rather than what is in netstat_config?
    $mysql_host = '';
    $mysql_user = 'xxxx';
    $mysql_pass = 'xxxx';
    $mysql_db = 'paradox';
    $mysql_table = 'netstats';

    as you can see it works fine for the player list
    so i'm at a loss, I don't know php/mysql that well.
  29. Offline


    I updated to 4.6 but my playtime is still really wonky.

    Are there any logs I can show you from my server that might help? My bukkit isn't saying much.
  30. Offline


    Thanks, It worked like a charm for me.
  31. Offline


    Are you getting years added to your total play time?

    That's whats happening to my play times.

Share This Page