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


    This is a great sortable page!
    I have no clue how to program or write php files. I would like to have the column of "First time logged in" added to this page. How would I do that?
  3. Offline


    We integrated it into our site.

    Next time can you make it more integration friendly?

    As I had to edit the getPT and copy out the header info to our separate header file and remove the body and html tags.
  4. Offline



    Well that's an odd way to say thank you.
  5. Offline


    I really do mean thanks to the author of that and I liked the post.

    It looks great integrated as we did the same to the other one also.
  6. Offline


    Since everyone's been talking about the web script, some or most will be glad to know that the next version of the code is almost ready and will include the ability to update itself while preserving your config options and will create everything in a /tmp/ folder so your old files aren't overwritten. v2.1 of the web script will have the ability to actually overwrite the files in case you don't do any custom changes to it. This way I can push out changes and you don't have to keep downloading the newest version unless you want to strictly control it. Once I'm done testing then I'll update it for you so I can work at a faster pace and any updates I do you can get right away. I'm also going to have it let you know if you have an update if the $update variable is "false". The code has also been cleaned up a lot so it's smaller and parts of it work better. It's not done, but seeing how everyone wants better code, then I will release it and just constantly push updates.

    Stay tuned, it should be ready within an hour as long as nothing distracts me from my work.
  7. Offline


    Hey Valrix, I've hit a snag and need some help. I've been running this plugin for a while now and used its ability to update tables when moving to the newer version. (netstats table became newstats table) Now the data was migrated to the newly created table as expected and all was well. The config rewrote itself to show newstats in the oldtable= position and the newtable= is blank..

    However after a server restart, I noted that data was being written to the "now blank" netstats table instead of the newstats table. Thinking it may be easiest to comply with this, I attempted to move the data back to the netstats table. This it did not want to know about. It does not create and migrate to a table called netstats. And if you have a table in the oldtable= but blank newtable=, on restart/reload Netstats will create a new table called netstats and start writing to it.

    as an experiment I attempted to migrate the data to a new table by a different name and that went well. It just won't work if trying to migrate back to a new table called netstats. And if given no arguement in the config at all it will create a new blank netstats table and ignore the other.

    The only way I have found to keep things running on the DB table where all my players data lives, is to put the name of the table I want to use in both config entries.. eg
    And because it rewrites the newtable entry every time it restarts, I have to remember to go and add a table name there, or I wind up with a netstats table again lol..

    I hope I have explained that with some clarity. I can provide any more details you might require.

    And on an unrelated note, my stats page draws data from several plugins. Each one is mentioned at the bottom of the page in a link image. I couldn't find a netstats logo as such so threw one together quickly. Pls advise if you have a logo you would like used, and where best to point a link.
  8. Offline


    Not work for me :
    2011-05-02 04:27:42 [SEVERE] [Netstats]: Couldn't find file plugins/Netstats/config.txt
    First install.

    Where i can found informations for Config.txt ?
  9. Offline


    I'll check on that. I thought I fixed that bug, but apparently there's still something wrong with out it renames the table. I think it's just something wrong with how it checks if you want something renamed or not.

    It should have made it. Make sure you have correct permissions set up for the folders and if those are fine just make the file yourself and it'll write all the config options to it.

    New version of the PHP code is out and has the ability to automatically download newer versions when they come up. It's really new, so all it does it "just work" and unzips the files into /tmp/ and rewrites the config in the /tmp/ folder for you. Past that, you'll have to move the files and for the PHP savvy, you'll have to mix your personal code into the new code yourself since I couldn't think up a nice way to only have it update my code in each of the files without a LOT of extra work.

    Furthermore, I've been tinkering with my computer so as I build new versions of the web code, and possibly new plugin versions, I can easily have the files moved around automatically by a series of folders watching for changes then moving the new/different files to other locations, renaming them, and even uploading them to a website for me so my updates will be faster and nearly fully-automated for me. Remember, less work for me that isn't coding means faster updates for you guys. Once my computer has a few more tweaks done then updates will definitely come faster and more often since I won't have to mess with the files much if at all once I'm done with them. In the near future this can mean once I've saved a file it can be moved, zipped up, and uploaded with no extra work on my part.

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


    Valrix, I might be interested in doing the PHP part of this code for you. Hit me up.
  11. Offline


    I have a partial solution to the code mixing and will make integration allot easier especially for us.

    Your Index.php page could be cleaned up a little more to allow better integration and just be a wrapper of sorts by using php includes for everything as the last thing left in that currently is the header which could be put in its own file.

    As we and probably allot of sites do not need the html or body tags but would need everything else.

    Also if you changed the name from style.css to netstats.css that would help allot as then it wouldn't conflict with our own stylesheet.

    And the include for config should be moved back to get.php

    We pretty much we just have a initial framework wrapper which is the theme and use includes for everything with our page header files and body content.

    Stats is a great thing and players are really liking it.

    We had the 20 day playtime on a user also this morning for some reason.

    Trying the latest code it was screwed up and wouldn't load as the config.php file was wrong here is the fixed version which you can see here as I haven't integrated it as its screwy with times.

    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.
    ------------------------------------------------- */
    # Netstats version (do not alter)
    $version "2.0";

    # Auto-update the web code for you
    $update '0';

    # Database connection info
    $mysql = array(
    'host'  => 'localhost',
    'user'  => '',
    'pass'  => '',
    'db'    => 'netstats',
    'table' => 'netstats');

    # What you want to be shown, change to false if you want it hidden
    $track = array(
    'ip'       => false# Shows country indicators
    'broken'   => true# Number of blocks broken by player
    'placed'   => true# Number of blocks placed by player
    'deaths'   => true# Number of times player died
    'mobs'     => true# Number of Monsters killed by player
    'player'   => true# Number of Players killed by player
    'joined'   => true# Date of when player first joined the server (with Netstats running)
    'distance' => true# Total distance player has traveled
    I don't know how its reading the current database as the old stats page kinda worked with time:

    Player Row: drguild

    If Ive been playing minecraft for 7 years with a April 27 2011 join date all I can say is wow the years flyby in a few days.
  12. Offline


    Hmmm... I am seeing an issue with the sorting.

    Here's our stats page:

    When I do a sort by "Last Login", I get groupings of days together, not cronologically. I'll have everyone who logged on Thu, Apr 28, and the next group below them is people who logged in Sun, May 1. However, the group after them is those who logged in on Sat, Apr 30. Shouldn't sorting this column list in order by date?

    The playtime column doesn't seem to have a sort order at all. At the top of the list is a person who has played for 1 day 16 hours, 31 minutes. However, scrolling down in the list, there are two people who are flagged as playing for 22 and 23 days.

    The playtime also doesn't add up, because I just made a new Netstats database last week, so there's no way I could have times for players at 22 and 23 days.

    Name, Last Seen, and IP all seem to sort correctly.
  13. Offline


    I have a remote website, and I don't have a direct access to the creation of databases, so could you please consider the possibility to add $mysql_prefix, so that it could be put in any database with a prefix, something like mcstats_ ?
  14. Offline


    The time is a little messed up at the moment because I haven't done the patch to the actual data yet. It's only counting the time in seconds instead of milliseconds. Once the next JAR comes out then it'll fix the total play time. So for just a little bit it'll look wrong, but will still be perfectly fine after the next update. I also suggest not trying to alter the database at all otherwise when the next update comes out then everything will get messed up. So PLEASE, just wait until I have a chance to put out the next JAR which will be soon.

    It would be great to have help since recently I've been getting really busy, but as fair warning I'm a very picky programmer and at the moment I haven't even had time to update the Git repo's code since the way I have it now is very hack-ish. There's still a lot that hasn't been added or just needs to be worked in, but for PHP, since it was my second language (ActionScript 2 was my first) then I know it really well. Luckily I've added the ability to auto update the code and v2.1 of the web code will have another config option to actually move the update pages for you so you don't have to do much of anything.

    I'm hoping that in the future I can have a method of updating around people's custom code, but I don't know how people have things changed exactly. ALSO, if anyone wants to localize any of the content for me, I will happily accept that code and do my best to make the whole thing localized so it'll work for everyone. I'm going to try and just create some specialized pages and create a link that uses jQuery to easily change between localizations for the many German players and such. More info on this in the future.

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


    i think the stats are way off... it appears you are storing 1/1000th of a sec increments and retrieving them as seconds. I had to change my php to be $total = (int)($total/1000);
  16. Offline


    which is what I said above. You can change the PHP yourself for now until I roll out the actual Java update, but I had to change it so player data wouldn't reach an overflow in the server. I'll try to toss out a quick update tonight that will change how the data is saved and will update the database. In the mean time, don't go over 23 days of play time for a single player otherwise the database will blow up. By that I mean it'll get an overflow error and many things will go all weird.

    Seriously...I need more people to help with this stuff.....
  17. Offline


    I think what I said earlier about code splitting would be the best way as we have all the actual head and body tags etc and have includes for everything.

    We have a system of:

    <!-- Start Page Head -->
    <?php include ("theme/template/page-head.php") ?>
    Thais is what I was saying about splitting the page head that way we can call the data from our template.

    <!-- Start Dynamic Content Import & Menu Import -->
    <?php include ("includes/dcimport.php") ?>
    <!-- End Dynamic Content Import & Menu Import -->
    Body is a dynamic input where we grab pages from a /pages directory and based on whatever the url value is eg:


    From there if its like these stats we have a small php file with our own text in /pages with a include to you actual content page being get.php where we unzip your folder to /modules/your-directory.

    <h1>Main Server Player Statistics</h1>
    <?php include("modules/playerstats/getPT.php"); ?>
    <br />
    For the header it would be the same process of calling your own file by a include in theme/template/page-head.php.

    <-- Netstats -->
    <?php include("modules/playerstats/netstats-header.php"); ?>
    I think this will work well for us and on other servers and it would allow netstats to auto update its own files.
  18. Offline


    I'll look that over more when I get home. Furthermore, I've nearly got the Netstats java update ready. When I get home I'll check and update.
  19. Offline


    don't see how going over 23 days would matter?
    shows your storing time as a bigint(20), which should store just over 3 billions years of time stored in 1/1000th of a second.
    Just curious
  20. Offline


    No, the max size of a bigint has a length of 19 and I mentioned it in a previous post. The max length in 1/1000th of a second would max out at just over 23 days, so after a player has been playing for that long then it'll overflow.

    Some people barely know how to even set up the PHP pages, so I've tried to make it as easy as possible to work everything in, though I know that it limits what any PHP devs can do, especially when the pages auto update. I can try and think of an easy way to make fetching the data so devs only need certain pages and such, but that means I need to some relatively easy ways of satisfying both the devs and non-devs.

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


    Your readme says theres a .sql file but there isnt.
    And the plugin doesnt write any tables in the database.
  22. Offline


    If the plugin isn't making any tables in the DB then you're doing something wrong. The readme is also outdated like the repo at the moment because I've been too busy to do any proper commits and pushes. This is also because I've been working on the web code which has to be cleaned before I can put it in the repo and I'm half done with v5 so committing and adding half-done code would only be more of a bother than waiting until there's useful code to be shown.

    For future reference, when you tell me something isn't working, show me proof so I can try and help you.
  23. Offline


    hi im haveing alot of trouble installing this im not sure what i did wrong thats the site im trying to host it under

    i get this error on my server
    2011-05-03 04:24:35 [WARNING] [OnlineLog v1.1] DB connection failed: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    2011-05-03 04:24:35 [INFO] [OnlineLog v1.1] I failed to init and will now suicide :O
    2011-05-03 04:24:35 [INFO] [OnlineLog v1.1] Disabled[B]

    since there is no way of completely showing you what i did you can have full access to my web server i would love to get this pluggin working it would greatly improve my community's willingness to participate[/CODE][/B]
  24. Offline


    That's not Netstats...

    I've started work on localization support for the web code, if you'd like to localize it for your language then edit the following code and send it to me as a PM so I can create the file for it and add it to the list of supported languages.
    = array(
    'name'     => 'Name',
    'broken'   => 'Blocks Broken',
    'placed'   => 'Blocks Placed',
    'deaths'   => 'Deaths',
    'mkilled'  => 'Monsters Killed',
    'pkilled'  => 'Players Killed',
    'distance' => 'Distance Traveled',
    'login'    => 'Last Login',
    'seen'     => 'Last Seen',
    'total'    => 'Play Time',
    'plocale'  => 'Player Locale',
    'join'     => 'Join Date',
    'online'   => 'Currently Online',
    'unseen'   => 'Not yet seen',
    'meters'   => 'meters'
    Only edit the text AFTER the "=>" sign.

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


    Does this plugin Let me Make those cool sig thingies or does that it make me have to learn PHP or something and then co-operate with this plugin?
  26. Offline


    I'll already localized for french (and modified for my use).
    You must able to change time/date format :
    Function date is only for english countries.

    Example for French :
    setlocale(LC_ALL,'fr_FR');       // place in the beginning
    // and replace
    date("D, M d g:i A",...)
    // by
    strftime("%A %d %B %G à %H:%M",...)
    And for more information :
    d (for Day) change in other contries
    y (for Year)...
  27. Offline


    2011-05-04 00:14:54 [SEVERE] java.lang.Boolean cannot be cast to java.lang.String loading Netstats v4.4 (Is it up to date?)
    java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
        at com.sparkedia.valrix.netstats.Property.getBoolean(
        at com.sparkedia.valrix.netstats.Netstats.onEnable(
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(
        at net.minecraft.server.MinecraftServer.e(
        at net.minecraft.server.MinecraftServer.a(
        at net.minecraft.server.MinecraftServer.init(
    0.7@740 zeus
    0.2@740 worldwarp
    5.0a10 worldguard
    4.5@740 worldedit
    1.1.2@740 worldborder
    0.4.4@740 stargate
    1.1.0@740 simplewarp
    1.3.7@740 serverevents
    2.7.2@740 permissions
    4.4@740 netstats
    1.5.1@740 locker
    2.2.3@740 ichat
    0.5.3@740 firelord
    0.84a@733 falsebookic
    0.84a@733 falsebookextra
    0.84a@733 falsebookcore
    0.84a@733 falsebookchat
    0.84a@733 falsebookcart
    0.84a@733 falsebookblock
    0.16@720 dynmap
    1.3@740 dispnamechanger
    3.0b1@709 commandhelper
    1.4.3@740 commandbook
    1.2@740 bedrespawn
    1.4a@740 backup
    0.72@740 authme
  28. Offline


    Cool sig thingies?

    I mean more than just time though. I mean having all the text that'll be shown translated for the different languages, but I'll add ability to change time format.

    Crap, I'll take a look at that when I can.

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


  30. Offline


    Ah, ok. I'll check into that. I think it's just a naming issue is all.
  31. Offline


    I have a request, could you have netstats put in the DB how many players are currently online? so I can have a simple PHP call on my site that does Players Online: 10/20 etc

Share This Page