OnlineUsers
Note: the original plugin and almost all of the work done on it is by croemmich. He doesn't have the time to work it any more, so he's allowed me to maintain it.
OnlineUsers is a simple plugin that maintains a flatfile or MySQL table with logged in users. Make sure to install the MySQL JDBC driver if you choose to use MySQL. You can obtain it from here: http://www.mysql.com/downloads/connector/j/
You can simply drop it in your server root folder, alongside the CraftBukkit jar. It will need to be named mysql-connector-java-bin.jar. Alternately, if you know how, you should be able to include it in your Java path.
online-users.properties
- destination=mysql #[mysql|flatfile]
- flatfile=online_users.txt #location of the flatfile to write
- flatfile-template=online_users.template #template used for creating the flatfile
- flatfile-data=online_users.data #data used to fill the flatfile
- remove-offline-users=true #Set to false to keep users in table when logged off.
- db=jdbc\:mysql\:localhost\:3306/minecraft
- user=root
- table=users_online#Will be created for you when the plugin is enabled
- pass=root
Note that the new `time_total` column is only updated when players disconnect. So, if a player is currently connected, that column won't account for the additional time they've been online in their current session. If you want to get a fully up-to-date value for how long they've been online, you can account for it in your query.
For example, this query would give you the up-to-date value as `current_time_total`:
SELECT *, IF(`online`=1, `time_total` + TIMESTAMPDIFF(SECOND, `time`, NOW()), `time_total`) AS `current_time_total` FROM `users_online`
If you're using an older release that 1.6.2, the query would instead look like this due to the different data type for `time_total`:
SELECT *, IF(`online`=1, ADDTIME(`time_total`, TIMEDIFF(NOW(), `time`)), `time_total`) AS `current_time_total` FROM `users_online`
An example PHP script to read from file output from this plugin can be found here.
Changelog
- 1.8.0 - Player UUID is now tracked in database and used as unique key, with the player's name updated at each login in case it has changed, so that time online is properly attached to unique player account rather than (soon to be) non-unique player name. dl
- 1.7.0 - Major efficiency boost by running a separate async task thread to handle adding/removing players from the database or flatfile. Previously this was handled entirely in the player join and quit listeners, thus holding up the main server thread for however long it took. dl
- 1.6.3 - Fix for newly created MySQL database tables missing the 'online' column; thanks to AxxiD for pointing it out. MySQL tables which are missing that column will retroactively have it added. dl
- 1.6.2 - IMPORTANT: BREAKING CHANGE for MySQL users: For MySQL data storage, time_total column type is changed from TIME to INT (read notes here) dl
- 1.6.1 - Primarily a compatibility release to support the upcoming CB 1.1-R5 and above. Update to use the new Bukkit event system. Fix for timestamps showing 12-based hour instead of 24-based as it was supposed to be. Removed the plugin's "loading" and "shutting down" log messages since Bukkit now handles those itself. dl
- 1.6 - added new database column `time_total` to track how long a player has spent on your server (MySQL only). dl
- 1.5.5 - fix for {longtime} and {shorttime} (in flatfile template) both outputting the same thing. dl
- 1.5.4 - Brettflan is now the owner. Updated for 612+ dl
- 1.5 - Fix MySQL issues. Move OnlineUsers directory to plugins. dl
- 1.4 - Initial Release dl
What do they mean with "Alternately, if you know how, you should be able to include it in your Java path."
@Brettflan
Thanks I'm trying now, fingers crossed :P
@konesmeijer
The link to download it it, the location to put it, and what to name it is covered above. Then in online-users.properties you would make sure destination=mysql, and for db change "localhost" to the remote IP, change the port "3306" if needed (probably correct though), and change "minecraft" at the end of that to the name of the database to access. Then of course you'll need to make sure user, pass, and table are set correctly.
Please help me how do I install jbdc driver etc, I have a remote database please help
@pirmax
Yeah, it should continue to work perfectly for the foreseeable future. It has minimal hooks into Bukkit so there's not much which is likely to require changes.
@PigPlushy
I missed this way back when you posted it, but it looks like you missed the "remove-offline-users" setting.
An update would not be denied, but if the plugin still works for version 1.4 ;)
Could you make an option to keep the users information in the table and then just change a row if the users online.. for instance...
can you add last login ? for mysql with php5 code ?
@xIGoDz
The plugin description pretty much says it all. It tracks a list of all users currently logged in, either to a flatfile (text file on disk) or to a MySQL database. The primary use would be for a website (through PHP or whatever) which lists the users currently online.
I'm confused. What benefit would having this plugin give you? Does it log all users when they first join and it keeps them in the file? Or do the users just stay in the file when they are online
Release 1.6.3
Single change for 1.6.3:
From 1.6.2:
IMPORTANT: BREAKING CHANGE for MySQL users: the time_total column type is changed from TIME to INT. The new INT values refer to the number of seconds the user has been online. This was necessary due to TIME columns being limited to roughly 839 hours before being truncated.
Any SQL queries you've written which reference the time_total column will likely need to be updated as a result. For a quick way to get a TIME value like before, you can use something like the SQL "SEC_TO_TIME(`time_total`)" or similar, but again you should note that SQL TIME values are limited to 839 hours before they stop working correctly.
Release 1.6.2
IMPORTANT: BREAKING CHANGE for MySQL users: the time_total column type is changed from TIME to INT. The new INT values refer to the number of seconds the user has been online. This was necessary due to TIME columns being limited to roughly 839 hours before being truncated and no longer working correctly.
Any SQL queries you've written which reference the time_total column will likely need to be updated as a result. For a quick way to get a TIME value like before, you can use something like the SQL "SEC_TO_TIME(`time_total`)" or similar, but again you should note that SQL TIME values are limited to 839 hours before they stop working correctly.
I have an unfortunate announcement: since I've just closed down my own Minecraft server for various reasons (mostly boiling down to me not having enough time to devote to it), most of my motivation for working on Bukkit plugins is now gone. I most likely will not be actively developing any plugins I'm involved in from this point on. However, I still plan to maintain all plugins as needed for new Bukkit releases and minor bugfixes and such, I just probably won't be adding any major new features or answering much in the way of support questions.
The source will remain available for all plugins, and I'd welcome anyone to take up active development. For Factions, Cayorion / Olof (the original author and still constant contributor for the plugin) will of course remain to develop the plugin and will continue to run the Massivecraft server.
If anyone really wants a particular feature added to one of the plugins I've worked on, I will still consider doing sponsored feature requests; no promises, of course.
Also, for Factions, I plan to try to make sure the 1.7 branch is ready before halting active development on it. There will also be at least one more 1.6.x release before then, probably quite soon. So, this announcement is a bit in advance of me ceasing active development on Factions.
Sorry, guys. Again, I will at least try to bugfix and maintain my plugins for Bukkit updates, but that's about it.
Oh, and OnlineUsers will get an update soon as well.
@srmysqldba
I can't entirely decipher what you're trying to say. Are you indicating a player isn't being updated in a MySQL database when they join the server? You'll need to provide more information on the problem you're having.
When a user is active in craft it is not showing user in the table?
Plugin works great. Really nice way for people who know PHP to get a nice list of who's online. May I recommend posting up the PHP example from the forums to make the process easier for some.
@Kekler
Drop it in your server root folder, alongside the CraftBukkit jar. It should be named mysql-connector-java-bin.jar.
Alternately, you should be able to include it in your Java path if you know how to do that.
Where do I place the JDBC connector?
@XeonG8
It doesn't log IPs and doesn't have any commands at all, sorry.
does it log the very first IP they joined the server with?
and any other IP, including last/current connected ip?
that and a replacement of the other plugin that does ..../playtime and /totalplaytime ...from ingame?
would switch to this in no time.