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
Weeeell, fun or not, I suppose it needs to be done.
Well, Thanks for the Info. I will need to find a solution to that problem.
@LanToaster
The UUID column is used as the primary key for the table now, and is how existing rows are matched and updated. It needs to actually contain the user's UUID and wouldn't work otherwise.
If you can do a lookup of all of the users' UUIDs and actually insert that for each row, and then switch the primary key for the table to be the UUID column, that should work. It wouldn't be a fun task, though, that's for sure.
Is there a way around the DataWipe?
I added several colums to the table, to store additional UserData (Like Money, Used Title, Punishments, UserRank and stuff).
It would be veeery inconvenient to lose that data.
Anyway. Thanks for the Quick update.
Edit: I just read the description on the Changelog.
How would it react if I inserted the Userlist with an Empty UUID Column?
Version 1.8.0 is now released and will be available once it's approved by the BukkitDev team.
This version adds a new database column for UUID, which is now used as the unique identifier for player data. Note that as a result all old data will be wiped. Read the changelog notes on the file listing for more details on why.
This update doesn't affect flatfile data whatsoever, only database data.
I Can't Read Now O_O HELPZ!
@Bogblob
Flatfile doesn't. MySQL does. Of course you didn't specify.
Hey, i might be doing something wrong but this isnt counting the total time online
Mike
@Brettflan my "online_users.settings"
2013-05-16 23:06:04 [INFO] [OnlineUsers] Disabling OnlineUsers v1.7.0
2013-05-16 23:06:04 [SEVERE] OnlineUsers: Access denied for user 'art'@'localhost' (using password: YES)
2013-05-16 23:06:04 [SEVERE] Could not connect to the database. Check your credentials in online-users.settings
2013-05-16 23:06:04 [SEVERE] OnlineUsers: null
2013-05-16 23:06:04 [SEVERE] OnlineUsers: could not execute the sql "UPDATE `users_online` SET `time_total` = IF(`online`=1, `time_total` + TIMESTAMPDIFF(SECOND, `time`, NOW()), `time_total`), `online`=0"
i think....i will give up....
@Arthurdes
If you already have a MySQL lib in Java's classpath you might not need that connector, but normally you do if you want to use MySQL with this plugin.
This line:
db=jdbc\:mysql\:localhost\:3306/minecraft
...means it will try to connect to MySQL on localhost at port 3306 (the default MySQL port), and will use the database named "minecraft" (thus the "/minecraft" at the end). From your screenshot it looks like you already have that database set up.
None of that should have any bearing whatsoever on using PHP to read data from MySQL. PHP and Java don't interact in any way in this instance, they both would be communicating with MySQL.
I still don't really understand what you're asking.
@Brettflan
I mean if not use you supply Mysql soft "http://www.mysql.com/downloads/connector/j/"
and the setting
"jdbc\:mysql\:localhost\:3306/minecraft" have to change?
because i use warp soft to create the mysql in the picture you can see it
but when i run the server,i not know how create a php.
finaly,i'am so sorry because my broke english....(come from Taiwan
@Arthurdes
I don't understand what specifically you're asking about. Do you have the plugin configured and working through MySQL and just need a PHP script to read from it? If you've done anything else where you connect to and read from MySQL using PHP, that should be straightforward.
if use warp to create a mysql,
how can i create the php and let plugin run...
@TanveerGT5
An example PHP script to read from file output from this plugin can be found here.
I want a working php script to display on site can you do it?
@pcatack
Just tested, working fine in the latest CB Beta 1.5.1-R0.2 (build 2754). I expect you have something misconfigured.
Not working with 1.5.1. Table is empty ever O_O
Nevermind guys got it to work thanks for all the effort amazing plugin!
I'm getting this I have this And this is my properties file, I copied exactly form above since it didn't say destination by it self destination=mysql flatfile=online_users.txt flatfile-template=online_users.template flatfile-data=online_users.data remove-offline-users=false db=jdbc\:mysql\:
----\:-/users user=---- table=users_online pass=-----Please help Thanks in advance!
My properties file doesn't have the option destination...
@konesmeijer
If you don't know what that means, you're better just doing it the way it says to.