Netstats
Netstats is a plugin that watches each player's activities and saves it to their own stats file while running an internal server which is used by web clients to ask for player stats.
Plugin Version: v5.0.4
Web Version: v3.0 (Work In Progress)
***
Alerts ***
Updated: Feb. 10, 2012
v5.0.4 is out! Web client coming next.
Features
- Monitors player online/offline status
- Keeps track of when they were last on the server
- Tracks total time they've been online
- Tracks player's last used IP address
- Tracks number of blocks broken
- Tracks number of blocks placed
- Tracks number of times the player has died
- Tracks total distance traveled by the player
- Tracks number of monsters killed
- Tracks number of players killed
- Tracks when the player first joined the server (after Netstats was installed).
- Auto-generating/Auto-updating config
- Tracking control (you choose what you want to be tracked)
- Multi-world support
- Reload-friendly
- Supports any language that can send JSON via HTTP POST
- 100% Java standard compliant
Commands
<> = required option, [] = optional, | = or, <command> = netstats or ns
/<command> stats - Shows list of stat names
/<command> get:config <option> - Gets config value
/<command> set:config <option> <value> - Sets config value
/<command> get:stat <stat>[,stat...] | all <player> - Get one or all stats of player
Examples
/netstats get:stat broken valrix
/ns get:stat placed,broken valrix
/ns get:stat all valrix
Config File Explained
Key | Default Value | Meaning |
---|---|---|
admin | <blank> | Username of admin's character |
delay | 30 | Time in seconds until all player data is saved to disk |
port | 9999 | Port to start the Netstats server on |
ip | true | Track the player's IP Address |
broken | true | Track when a block is broken |
placed | true | Track when a block is placed |
deaths | true | Track when a player dies |
mobs | true | Track when a player kills a mob |
players | true | Track when a player kills another player |
distance | true | Track distance a player travels |
Author's Notes/Warnings
- Don't use plugins that allow you to "roll back" any changes to the server. This will mess up all your stats!
Resources
Planned Plugin Updates
- Multi-language support
Planned Web Updates
- Re-write to work with new system
- Personal stat pages
Plugin Changelog
Version 5.0.4
- Improved memory usage by removing more repeated strings and numbers
- Fix a typo in the JSON builder
- Fixed/improved command handling
- Improved documentation
Web Changelog
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.
@Reubentrapdoor
I've been working on that. It just takes an HTTP POST like on the API page. My example is done using the jQuery post() method. jQuery is a framework of Javascript. For PHP you can do a cURL request.
Thanks for clarifying the database/configuration stuff.
If it's not too much to ask, it would be great if someone with some JSON knowledge could produce a very simple working example of how to pull the information from PHP(?) or something so that it can be displayed on a webpage. (I did see the notes on the API page). Thanks in advance!
@user_955758
Any plugin that lets you "roll back" anything that's changed on the server will cause problems with Netstats since it doesn't have a way of being informed of those changes and would mean incorrect stats.
Hey, I can't seem to get this working. I think the problem is HawkEye. Do others have the same problem?
@selfservice0
Nothing, just leave it blank. The installer just checks to see if that key exists, if so, skip the installation process. Otherwise it creates needed files, folders, etc.
@Valrix
Thank you. What do I put next to installed, if anything? "installed=No"?
@Pythros
That's what the "admin=" in the config.txt is for. Since I'm the admin of my server, mine would look like "admin=Valrix" so when the command is run, if it doesn't see a value or the usernames don't match, then it doesn't run the command.
@selfservice0
There, I removed the bit about a database from the intro and the config has been explained above.
@Valrix
Here is a sentence from your introduction "The information is stored in a database which is defined by the user."
"Netstats it will create the config file then disable itself until you change the config to match your database."
but now you're saying it doesn't use a database, "Netstats doesn't use a database, and nowhere in the description or otherwise does it say that it does use one."
okay, ummm.....
"How does it make no sense? I suppose I'll elaborate more." what is the "Admin=" for in the config? what is the "installed=:" for, in the config?
Your discription is all about configuring a database. And the configuration has nothing about a database.
@Valrix
OK.... So if the admin commands can be ran through the the client, what/how is it determined who the server admin is? That's what I am getting at as this would mean any person could run those admin commands, correct?
@Pythros
That's either run through the game's chat (client), or through the console.
@Reubentrapdoor
Netstats doesn't use a database, and nowhere in the description or otherwise does it say that it does use one. You don't configure it to use one, because there is no database involved at all.
@selfservice0
How does it make no sense? I suppose I'll elaborate more.
@PeterFour
Drop the .jar in the plugins folder, start the server or do a /reload (fresh start is safer, though it is /reload friendly), edit the config.txt to your liking, though everything works from the start. You don't go to localhost:9999 at all, JSON requests are sent to localhost:9999/data and player stats are returned.
@XiServe
Yes, /ns or /netstats would through an error since it's not an actual command, though I'll make sure it just returns false. Any invalid commands should just return the help text. Currently there is no WebGUI, which is what I'm working on. This GUI though is only to show player stats, etc, not control the plugin which can be done by editing the config and doing a /reload.
Note that the single command /ns or /netstat throws errors. Can you upload/create a general WebUI?
Edit: I'm also getting tons of errors.
Is anyone can explain how to setup this plugin?
I drop the .jar in the plugins folder but when I go on localhost:9999 I got 404.
Is there something wrong? (Server is a basic McMyadmin with no other plugin)
The config makes no sense.
How do I configure the plugin to use my MySQL database? The auto generated config file shows:
What do the installed and delay fields mean? I was expecting a format like hostname, username, password and port number or something.
Edit: I'd also like to point out that those four lines are the only ones in the config.txt file besides the configurations for which things to track. Shouldn't there be more? Such as table names, database name etc.
@Valrix
You are talking about running this via the client or through the console?
/<command> set:config <option> <value> - Sets config value
@Pythros
I meant admin to be the one who owns the server. So the only one who can alter the config file would be the one who can issue those commands. Luckily this doesn't use a DB, so if someone was spamming it, they'd have a lot to type out, and it's grabbed directly from cached data.
@Valrix
Then what defines a "server admin"? We don't use OP on our server.
On our server, we have had people spamming commands for utility plugins in the past. Plus, for those things like this that uses a db, for whatever reason that it may crash the server when doing a query, I want it reserved for only selected staff to run these as certain staff can restart the server if need to be. Plus, I don't think somone's IP address should personally be viewable by anyone.
@Pythros
The config-related commands are only usable by the server's admin. Past that, the other commands are safe since they just display the help text, the list of stats that can be seen, and the ability to see someone's stats. Since the admin commands are ONLY for the server admin, what would you need permissions for?
@TeamAss
Just drop the JAR into the plugins folder, start your server, then edit your newly created /plugins/Netstats/config.txt file to your liking. After that, it's safest to stop, then start again to ensure all settings take effect. Now everything should be running fine and Netstats knows how to do the rest!