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

    Lord Chaos

    Ah ok, thanks. I ran that SQL on the database and it ran without errors, but now I am getting this in the console instead:

    Code:
    2011-03-20 14:10:34 [SEVERE] [Netstats]: Could not set data for com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.36.152, total=1312515, logged=1 WHERE player='krestenhh'' at line 1
    This is MySQL 5.5 running on Windows Server 2008
     
  3. Offline

    Valrix

    Yeah, this has something to do with how Windows is handling the SQL which I'm still trying to figure out. It works perfect on *nix machines, but Windows keeps throwing a fit and I have an idea of what's doing it but I still have some testing to do. I'll patch that when I wake up tomorrow, but for now I need to get some sleep or nothing will get done. I'll also work on making the database name optional while I fix this since they both have to do with the database configuration.
     
  4. Offline

    Lord Chaos

    Ok, look forward to the fix. :) I am quite excited about this plugin.
     
  5. Offline

    Rilly

    I tried to install version 3 (removed my version 1.6 completely, deleted the jar, and the netstat folder that was created).
    I put the 3.0 jar file in the plugin folder, and updated the config.php file but.. when i restart the server, i get this
    -----------------
    Netstats: v3.0 has been enabled.
    Netstats: v3.0 has been disabled.
    -----------------
    (Thats in my console).
    No Netstat folder is created either

    I don't see other installation instructions - did I miss something? I thought this is what i did to install the 1.6 version prior..

    edit: using Bukkit 556
     
  6. Offline

    Chikken

    Ahhh great MySQL :D THX alot ;)
    Works great, just copy & paste.
    More stats would still be great ;)
    CraftBukkit Build 531
     
  7. Offline

    Valrix

    Looks like if you didn't get anything else then it couldn't create the config file. Maybe because that directory doesn't have write permissions? That's why it would disable itself so that it doesn't try to load nothing and give you a ton of errors about not finding anything, so instead I just tell it to disable itself. I would check your folder permissions first. If those are fine then I don't know what would cause it but I can give a blank config if needed.

    Glad it's working for you! More stats will be added as they get suggested or I think of some interesting things to keep track of.

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

    Chikken

    - nr. of monsters killed
    - nr. of players killed
    - distance the players travelled
    - first time a player logged in
    - maybe group from GroupManager or Permissions
    this would be some things id like to see ;)
     
  9. Offline

    Valrix

    Since so many people have asked for distance traveled I'll see if I can do that, along with number of monsters killed. You're the first to suggest the date they joined which I know will be the easiest, so I can add that in no time. I'll add these to the new "Planned" section. Thanks for the ideas!

    On Permissions: amd3th recently learned how to implement Permissions and I'm going to learn how to do so from him, but I don't see how it would be useful in this plugin. Maybe you could explain that idea a bit more? To keep Netstats lean I'm trying not to hook it into anything since I love how fast it loads and how little memory it needs to run, so the less code and hooking, the better.
     
  10. Offline

    garglebutt

  11. Offline

    Valrix

  12. Offline

    Chikken

    Group was just an idea nothing that would be important, thought it would be nice for some reason to show in which group the players are, admin, mods, builders, residents.
    But it seems better not to hook into other plugins for things like this.
     
  13. Offline

    FiZi

    Bad news. It's not just Windows.

    Code:
    16:18:36 [SEVERE] [Netstats]: Could not set data for com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.106, logged=1 WHERE player='FiZi'' at line 1
    It worked the first time I logged in and then after a server restart I'm getting that now. That's MySQL 5.0.77 on CentOS 5.5 64-bit. Latest JVM for my MC server and the latest recommended Bukkit release.

    Broken blocks are being tracked correctly.
     
  14. I get the following error:
    Code:
    [SEVERE] [Netstats]: Could not set data for com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.0.16, total=42474, logged=1 WHERE player='christopher2007'' at line 1
    Ehat should I do to salve this problem?

    greetings
    Chriss
     
  15. Offline

    Valrix

    Bah, it shouldn't be doing this... I'm working on it guys. I'll try to get it done ASAP. I think it's because it doesn't like IP addresses even though it worked fine before. I'll see what I can do.
     
  16. Offline

    FiZi

    Much appreciated :)
     
  17. Offline

    Valrix

    Ok everyone, for some reason when first testing it didn't show up but I restarted my server and tried again and sure enough I got the same error and found the source and patched it up. Grab the latest JAR to get the fix. Sorry about that guys! Also, thanks for the bug reports, you helped my find the source a lot faster than I would have without the numerous posts. :D

    Thought I'd make a quick post about what I'm currently working on. First I'm adding the ability to let server admins choose the name of the table AND when the plugin starts up if it sees that you changed the name it will change the table name for you. This process works by adding these two options to the config:
    Code:
    oldTable=
    newTable=
    The first time you want to change the table name it'll change it from "netstats" to whatever you put after "newTable". Once it changes the table name it changes "oldTable" to the same thing as "newTable" and as long as those are the same it won't do anything more. Now the next time you want to change the table name, once again just change the "newTable" option to whatever name you want it to use and it'll rename the table and change "oldTable" to the same value of "newTable". This makes it so you can forever keep renaming the table without it causing any problems, but you must make sure not to change "oldTable" otherwise you'll probably get errors or you'll accidentally mess up things in your database.

    For the web script, just set the "$mysql_table = " option in the config.php that you would change to match your "newTable" config each time you change the name. Now you don't have to use the table name of "netstats" in your database! There's more to come as I get more work done. Feel free to follow my twitter (link in my signature) for the latest updates.

    EDIT: You can get ready for the update early by adding the config options above right after the "password=" option. They don't HAVE to be there, but that's how I have it auto-generated when run for the first time. I also added "joindate" to the table that'll be set when the user logs in for the first time. This will be set ONLY when they log in the first time. This means that they can't have any data in the database or it won't be set. I know you don't like having to wipe player data, but it's either wipe it or you simply can't have that option. Besides, it wouldn't make sense to see a player with a join date of some time 2 hours ago but they've been on for 6+ hours right?

    If you want to keep your table as it is then just don't add the oldTable and newTable options to it and it'll run the exact same as before.

    A lot more work was done like tracking how many Monsters and Players a player has killed and the way data will be saved to the .stats file is being improved too so it'll be faster, take a bit less code, and hopefully I'll come up with a way to alter previous config files to add new config options to it without forcing the admin to do it by hand or delete it and generate a new one. The next few days are going to be hell for me because I have 3 big projects due and a final exam for Applied Physics of which I missed the previous week of. Wish me luck guys!

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

    Lord Chaos

    Good luck. :) Hope you get good grades regardless.

    Btw, I am no web expert, but how exactly do you add the php files on a webpage so they work, could use some sort of sample index file or something.
     
  19. Offline

    stoneLeaf

    I'm glad you decided to use MySQL again !
    Version 3.2 is working on my server (Bukkit 527).

    But something is missing. When I stop the server (nicely, using the stop command), the 'logged' column of the table is not zeroed ! I guess you should add something in the onDisable() ?
     
  20. Offline

    Valrix

    I was thinking of adding a simple index.php page too so if a user doesn't have one then they can use it out of the box. Easiest way is to make an index.php that looks just like an HTML page and between the <body> tags put in this:
    Code:
    <?php
    include 'get.php';
    ?>
    Yeah, I'll have to add that in. I forgot to do that since v2.

    I updated the planned section above to reflect the new things I've added as well as things I'm working on. When I release the update I'll fully explain the changes and why they're important, etc. If you have questions, feel free to ask!

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

    PhotonLance

    hi i idiot ))))
    i set netstats plugin and connect with mysql server
    but i dont know how make this in my site ((((
    help plz ^_^
     
  22. Offline

    Valrix

    Sorry, I don't really have the time to guide someone through how to do it. If you ask around I'm sure someone can help you though. If I wasn't so busy I would gladly help you out.
     
  23. Offline

    Postbote

    Hi, great Plugin, it work wonderful on my Server!
    I played some with PHP... did you know manu-admin-mod for Call of Duty servers? The mod had a extension for MySQL Stats & Medals. I build the medals from the Manuadminmod in Netstats:
    [​IMG]
    Do you like the Idea & Design? This is a first try to work with Photoshop, the Timemedal i dont like... x(
    And sorry for german speech in the hall of fame. Im German, but I can translate the Medals into english. Only on my HP there are german. Here the Translations:
    1st medal is the "broken Block" medal. Like a miner etc.
    2nd Medal: the "placed block" medal, for a builder (which build big Buildings ^.^)
    3nd medal: The Deaths. Creeper or fall down etc.
    4nd medal: the play time. Too much is not good ôO

    Would you build it in your script? Would be great! ;)

    And sorry for bad english grammar.



    see ya
     
  24. Offline

    Valrix

    This is actually a really cool idea and gives me another idea. If I can find a way to get the player's skin from the server I could have the PHP page show users as their picture and show the stats under their avatar. Then next to the stats, if they reach certain "achievements" set by the server admin, then they'll have a special medal put next to that stat. This even has the possibility of different "levels" of each achievement so reach level one and it's a wood block, level two is gold, etc. It can also be possible to make each name clickable so when you click on a player's name it'll show you a page with all their stats and medals laid out in a nice looking way. Thanks for the suggestion!
     
  25. Offline

    Kalastor

    And what about a podium to each medal?

    So you need only three medals type for every stat and they are pretty "endless" and someone can always get over the existing first.
     
  26. Offline

    Valrix

    Well, I was thinking if I can get the picture of the player from minecraft.net then I can have a dog tag-like background. This would be in a grid-like style on the main page and when you click on a user it'll give each trackable stat a pedestal with their current ranking. Maybe there'll even be some kind of achievements for those who've been on the server for a really long time. There's tons of cool things that can be done with this, but first I just need to get the actual plugin done and from there nearly everything can be done with PHP.
     
  27. Offline

    THEK

    Just one request. Can you set the plugin to set everyone's status to 0 at startup? When my server crashes I have to keep resetting it manually.
     
  28. Offline

    Valrix

    That's a little more difficult since I'll have to iterate through the players folder. But I'll figure it out and hopefully get that to work.
     
  29. Offline

    firewalled

    Valrix: Why not just do it in the database? Assuming you only use the database for ONE server, then you can just do "UPDATE netstats SET logged = '0'". Just make sure it happens on start only, not reload on the server?

    Anyways, great plugin, however, I do have a little problems with it. I get the following errors once in a while:

    Code:
    2011-03-22 20:38:41 [SEVERE] Could not pass event BLOCK_PLACED to Netstats
    java.lang.NullPointerException
    
        at com.sparkedia.valrix.Netstats.NetBlockListener.onBlockPlace(NetBlockListener.java:73)
    
        at org.bukkit.plugin.java.JavaPluginLoader$21.execute(JavaPluginLoader.java:264)
    
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:59)
    
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:255)
    
        at net.minecraft.server.ItemBlock.a(ItemBlock.java:107)
    
        at net.minecraft.server.ItemStack.a(ItemStack.java:56)
    
        at net.minecraft.server.ItemInWorldManager.a(ItemInWorldManager.java:160)
    
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:495)
    
        at net.minecraft.server.Packet15Place.a(SourceFile:57)
    
        at net.minecraft.server.NetworkManager.a(SourceFile:230)
    
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:76)
    
        at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
    
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:357)
    
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
    
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    
    2011-03-22 20:38:44 [SEVERE] Could not pass event BLOCK_BREAK to Netstats
    java.lang.NullPointerException
    
        at com.sparkedia.valrix.Netstats.NetBlockListener.onBlockBreak(NetBlockListener.java:40)
    
        at org.bukkit.plugin.java.JavaPluginLoader$30.execute(JavaPluginLoader.java:309)
    
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:59)
    
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:255)
    
        at net.minecraft.server.ItemInWorldManager.d(ItemInWorldManager.java:112)
    
        at net.minecraft.server.ItemInWorldManager.b(ItemInWorldManager.java:77)
    
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:370)
    
        at net.minecraft.server.Packet14BlockDig.a(SourceFile:42)
    
        at net.minecraft.server.NetworkManager.a(SourceFile:230)
    
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:76)
    
        at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
    
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:357)
    
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
    
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    
    
    I assume that means those blocks aren't accounted for. I am not sure when it happens, as it doesn't happen always, and it count some blocks, since my database contains block values.

    Last thing, when we started out using the plugins, the playtime was around 7 days for each user. I just corrected it in the database, and now it seems to calculate just fine.

    Sorry for the sucky "bug report" with no information about how to reproduce etc.

    I am using bukkit b556 on Windows 2003.
     
  30. Offline

    Valrix

    I looked at the source and it's failing to get your username from the actions HashMap. This means it didn't have a chance to add you which shouldn't have happened. After looking at why this could be it donned on me that when a reload occurs I forgot to have it add the users back into the actions table. Thank you for pointing this out to me because now I can actually fix this. I'll also take a look at the weird playtime when first starting out. I think I might know the reason for it saying 7 days.

    To explain the error, the plugin keeps a map of each user and the number of actions they perform, such as breaking and placing blocks (soon to include killing things) to know if it should update the player's info in the database. This is done to keep the database from having data put in after each action, drastically slowing it down when more than one person is on. The bug was that when a reload happens it has to forget everything, so I created a "catch" at the beginning of each action to store the user info again if it's not there, but I forgot to also put in that the user needs to have their actions watched instead of just keeping their .stats folder in memory. I can quickly fix this, but to make sure it doesn't happen, just don't use the /reload otherwise everyone will have to log out and back in for it to properly watch the number of actions they've done.

    EDIT: I will have it set the player's number of actions to half of whatever you set as updateRate to make it a happy-medium for all users. As another "catch" I will have the script that does the timed updates check if the user is in the actions map so if they're idle and a /reload occurs, they'll be added back without having to perform an action. This just speeds things up a bit.

    And to touch on the first thing you said about the "UPDATE...", that's perfect and I don't know why I didn't think of that myself. I'll add that to when the plugin is first enabled to make sure the database is fixed as fast as possible after a crash. Thanks for the report! You actually helped me a lot.
     
  31. Offline

    firewalled

    Hey Valrix,

    Thanks for a quick and very well explained response. The /reload thing you say sounds very much likely because I have been using /reload several times during the evening due to various modifications.
    The server has been running for some hours now, and I haven't seen any of those errors since, because as you say, they can't happen on a start, only on a reload.

    Looking forward to an update; I'm watching this topic, so I will know when something is written here, and I will test it right away and let you know how it went.
    Sounds awesome with even more stats, the more the marrier. People, including me loves stats, especially for a... how to put it, "basic game" like this.
     

Share This Page