MOC Playtime Tracker
Description:
The Minds of Chimera (MOC) Playtime Tracker tracks time players have been online (total time as well as last time on), as well as useful stats of their activity, in a MySQL or SQLite db. Gives top X reports as well (like top 5 players in time spent playing).
NOTE: Other plugins do this but they either are discontinued, buggy or use flat files. They've done a great job but didn't fit our needs so Playtime Tracker was created to fill our, and hopefully some other people's needs.
Part of the Minds of Chimera Project (dev)
MOCPlaytimeTracker | MOCDBLib | RegenBlock | MOCGoodEats | MOC3DImporter | MOCKiosk | MOCChemistry
See development versions in action on our server: isue-server.eecs.ucf.edu
Features:
- Log time players have been online.
- Report time online as a sum or as the last time they were on.
- Log player activities such as killing mobs and players, placing/destroying blocks, movement, etc.
- Report different player activities.
- Report top X charts of player activities and time online.
- Store data in a database: SQLite or MySQL.
- Uses a caching system to minimize database read/writes and avoid server blocking (darn single threads).
Media:
Demonstration video.
As of version 0.3, it logs player events per world. Here is what the output of: "/playtimetracker user cwingrav world" displays, where the user is "cwingrav" and the world name is "world".
It also lists the top performers in a category.
Commands:
/playtime - Prints amount of time you have played.
/playtime sum - Prints amount of time you have played.
/playtime sum [player] - Prints stats about time spent playing.
/playtime sumall - Prints stats about time spent playing for all players ever logged in.
/playtime laston - Lists last login times of self.
/playtime laston [player] - Lists last login times of the given player.
/playtime lastonall - Lists last login times of all players.
/playtime full - for the player, list their sum and laston
/playtime full [player] - for the given player, list their sum and laston
/playtime stats (player) (world) - prints user states about their activities in the world
/playtime debugon - spews debugging information
/playtime debugoff - stops spewing debugging information
/playtime recountall - forces the database to recount all player entries. Use if something is screwed up for 'sum'.
/playtime help|? - lists help
/playtime top [criteria] [# to print] [world] - Prints the top 5 in the categories this is tracking. Default is top 5 online time.
[criteria] currently include: online, place, destroy, die, moved, pk, hk, fk
pk=player kills, hk=hostile kills, fk=friendly kills (like cows, pigs, etc).
Permissions:
- PlaytimeTracker.admin:
- description: Access to debug and clear the log.
- default: op
- PlaytimeTracker.self:
- description: Gives access to discover the amount of time the player is online.
- default: true
- PlaytimeTracker.player:
- description: Gives access to discover the amount of time a player is online or last on.
- default: false
- PlaytimeTracker.all:
- description: Gives access to discover the amount of time all players are online or last on.
- PlaytimeTracker.top:
- description: Lets people list the top X for a given value.
Installation (and Configuration):
- add the PlaytimeTracker.jar file to your plugins directory.
- add the MOCDBLib.jar file to your plugins directory.
- follow the configuration instructions below if you connect to a MySQL database.
- create the plugins/PlaytimeTracker/DBLib.properties file (running the server once will create this)
- configure these options for your setup. This uses MOCDBLib for this so see its page for further details.
MySQL=false host=localhost database=playtimetracker username=root password=pass port=3306
Troubleshooting
- A common error is to skip the installation of the MOCDBLib.jar plugin.
- Check the server.log file for a list of errors. I try to be descriptive if it fails.
- When reporting a bug, please list a lot message error and information about your database configuration (i.e. MySQL or SQLite).
- /playtime recountall - This is useful if something gets mixed up with the online time counting.
- I'll do my best to help. Cheers.
Feature Requests
- Properties file for setting the names of the databases this is using. This will allow multiple servers to run off the same MySQL server.
- /afk support (interesting, might do but I will have to make a lot of changes to support this and to make sure it doesn't impact the server)
- Log sumall to the server file.
- Track per-world time online. so, /playtime <player> [world]
When you are on two servers at the same time, you don't get doubled time. It works perfectly and you cannot abuse it, it seems :)
Awesome!
The materials come from MOD-packs. Not client. Tekkit modpack consists of 35 mods and each mod brings tens of new items.
Maybe block-break event listening could be disabled and it could follow other methods only? Or are there any other :P I don't know.
I am running Playtime on 2 servers, PvP and Survival servers. They work just fine, but I haven't tried joining to both at the same time on same account. I will test.
@weja93
Hard to say about the three servers. Probably, not good. I was toying with a server entry. That would resolve what you're taking about. However, most people won't be signed in with the same account on different servers. It handles different worlds just fine. You can try it and let me know? Otherwise, when I get back I can take a look. I'm currently on a family vacation. Let me know if that helps. Also, the BlockBreakEvent... I'll look. Probably a Spout Material that was hit? I've seen that before. I'll check into it.
Thanks for the feedback.
I am going to use this on 3 servers, with same database.
What might happen if I join all 3 servers at the same time?
Btw it does not seem to work with Tekkit. Is this fixable?
2012-08-01 00:32:11 [SEVERE] Could not pass event BlockBreakEvent to MOCPlaytimeTracker org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:303) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:464) at eloraam.machine.TileBreaker.onBlockNeighborChange(TileBreaker.java:147) at eloraam.core.BlockExtended.doPhysics(BlockExtended.java:63) at eloraam.core.RedPowerLib.notifyBlock(RedPowerLib.java:25) at eloraam.core.RedPowerLib.updateCurrent(RedPowerLib.java:1220) at eloraam.machine.TileRedstoneTube.onBlockNeighborChange(TileRedstoneTube.java:124) at eloraam.core.BlockMultipart.doPhysics(BlockMultipart.java:29) at net.minecraft.server.World.k(World.java:532) at net.minecraft.server.World.applyPhysics(World.java:507) at net.minecraft.server.BlockRedstoneWire.g(BlockRedstoneWire.java:55) at net.minecraft.server.BlockRedstoneWire.doPhysics(BlockRedstoneWire.java:297) at eloraam.core.RedPowerLib.notifyBlock(RedPowerLib.java:25) at eloraam.core.RedPowerLib.updateIndirectNeighbors(RedPowerLib.java:48) at eloraam.core.TileExtended.updateBlockChange(TileExtended.java:98) at eloraam.logic.TileLogicPointer.timerUpdate(TileLogicPointer.java:219) at eloraam.logic.TileLogicPointer.q_(TileLogicPointer.java:413) at net.minecraft.server.World.tickEntities(World.java:1191) at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:547) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:453) at net.minecraft.server.ThreadServerApplication.run(SourceFile:492) Caused by: java.lang.NullPointerException at moc.PlaytimeTracker.PlaytimeTrackerBlockListener.onBlockBreak(PlaytimeTrackerBlockListener.java:21) at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ... 21 more
Lots of new blocks.
Can you add color support to names? Playtime top looks pretty dull, and all the other ones as well.
Thanks!
Login time and logout time. In the recent update, I also sum it all up, each login-logout time, to optimize online time calculations. There are weird cases where logouts are not caught and the new version "heals" these in the database by closing them out at zero time, but these are rare.
So does this log the start and end times of every players session? So that I could look at the db and graph when people were online?
Update FINALLY incoming. Changes a few command lines to be more like weja93's comments. More importantly, this is much faster now. I.e. I don't recount each login each time. As well, all players are loaded so commands like 'top' and 'sumall' actually cover everyone that ever visited the server.
In testing on my server now.
@weja93
Ha ha... that's a pretty emphatic response. When I revisit the code, I'll take a look at it's interface as well. Thanks for the feedback.
Request:
"/playtime" shows your playtime, instead of "/playtime sum"
"/playtime help" shows help instead of "/playtime"
Please!! It's so much easier that way :)
@Hans6666
Follow the directions above. You probably don't have the MOCDBLib.jar.
on newest craftbukkit: 22:14:16 [SEVERE] Could not load 'plugins/MOCPlaytimeTracker.jar' in folder 'plugins'[0m org.bukkit.plugin.UnknownDependencyException: MOCDBLib[0m at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:195)[0m at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:213)[0m at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:189)[0m at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)[0m at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:166)[0m at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:432)[0m at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)[0m
Bug: On someone is offline, still the plugins says he's online and every second he got more playetime.
Please fix.
Request:
/playtime shows your own playtime, no need to type "/playtime sum"
"/playtime help" would show all existing commands
Please! :)
Can we have it tally a ongoing total of each players play time... so we know how much they have played in total...?
I would like to make site to my website, where you can list the players playtimes :P
That's why. I think it's possible too with SQLite, but I don't think it's as simple.
And my server will grow.. Newcomers daily. The flatfile will be gigabytes some day..
Of course it works for now, but soon I have to think something else.
Anyways, thanks for answering to my post :)
@weja93
Thanks for the earlier bug. I know how to fix it and will in next release so we can keep the server log file clean. It was a simple distance calculation that failed due to different worlds. Odd I don't get it when I teleport. I don't think it brought down your server.
Regarding switching from SQLite to MySQL... you're going to have to do that manually as that isn't that easy to do. They have different SQL syntax and such and there are several projects that specialize in supporting this work and I can't reproduce all of that.
FYI, why switch to MySQL? MySQL is nice for massive transactional systems, but SQlite should be fine for 99.9% of servers out there. I use MySQL on my server only because it makes it easier for the webguy who accesses lots of plugin data for our website.
I also should convert this SQLite to mySQL. Is there a script to do it? Or ingame command?
If not, please make it. Otherwise my players will lose their hours of "work" :P
Thanks for awesome plugin, I love it. Still think that the mySQL bridge thing should be "inside" the plugin without having to use bridge plugin.
2012-05-27 20:45:21 [SEVERE] Could not pass event PlayerMoveEvent to MOCPlaytimeTracker
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304)
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:459)
at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:209)
at net.minecraft.server.Packet10Flying.handle(SourceFile:126)
at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java:169)
at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78)
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:567)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:459)
at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
Caused by: java.lang.IllegalArgumentException: Cannot measure distance between Peace and Resource
at org.bukkit.Location.distanceSquared(Location.java:381)
at org.bukkit.Location.distance(Location.java:364)
at moc.PlaytimeTracker.PlaytimeTrackerPlayerListener.onPlayerMove(PlaytimeTrackerPlayerListener.java:54)
at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302)
... 11 more
Peace and Resource are my world names.
Weird issue, hope you find the problem.
Server also went unresponsive shortly after that, I do not know if this caused it, this just happened a bit before it.
@harryjamesuk
We're looking at Achievements and such, but probably won't implement anything based upon topX. Top X shifts (i.e. the next person breaks a block and they get a diamond, then the previous person breaks a block and gets a diamond, etc.) and my method of tracking this is not fit as it only loads online people so I would have to redo a few things to make it fit.
Check out the Achievement plugin for basic achievement tracking, but it won't do it based upon logs.