AutoWhitelist
About AutoWhitelist
This is a continuation of the Whitelist plugin originally written by Silencium20. This plugin will automatically reload your whitelist when players are added to the whitelist file. This plugin will connect to Mojang servers for UUID lookups.
Features
- AutoWhitelist is automatically reloaded when changed outside of Minecraft (e.g. with a text editor)
- AutoWhitelist supports console commands
- SQL support
- Support for every SQL database that has a JDBC implementation available
- User-defined table and database layouts supported
- Ampersand color codes in the kick message. (&4 = red etc...)
- UUID support.
How to install
- In your server.properties file set whitelist to false.
- Drop the jar file in your plugins directory and restart your server.
Commands
Commands: These commands can be used by Ops ingame or in the server console. When used with the server console don't type '/' before the command.
- /whitelist help - Shows the help ;-)
- /whitelist reload - Reloads the whitelist and it's settings
- /whitelist add [playername(s)] - Adds a player to the whitelist)
- /whitelist info [playername] - Display information about a player
- /whitelist remove [playername(s)] - Removes a player from the whitelist)
- /whitelist on|off - Activates/deactivates the whitelist
- /whitelist list - Lists all whitelisted players (from txt file)
- /whitelist dblist - Lists all whitelisted players (from DB)
- /whitelist dbdump - Dumps users from database to whitelist.txt file
Permissions
- whitelist.admin - Gives players access to any of the /whitelist commands.
- whitelist.[command] - Gives players access to specific commands.
Basic Configuration
See config.yml
SQL Configuration
To support as many different database configurations as possible, Whitelist sets flexibility over simplicity. This way virtually every existing database can be used as a base for authentification.
Table Creation
The plugin will not automatically create tables for you. Below are a couple examples to get you started.
If you want to use UUIDs you can do something like this.
CREATE TABLE IF NOT EXISTS `tbl_users` ( `name` varchar(256) NOT NULL, `uuid` varchar(256) NOT NULL, `oper` varchar(256) NOT NULL, `time` varchar(256) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Or more basic without UUIDs.
CREATE TABLE IF NOT EXISTS `tbl_users` ( `name` varchar(256) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Dependencies
If you want to use MySQL, you might need the MySQL Connector/J. It can be found here.
Source
https://github.com/cnaude/Whitelist
Change Log
- v3.5-32
- Add DB reconnect logic.
- Update for MC 1.10.2.
- Info command should always respond.
- v3.5-26 - May 7, 2015
- Update for MC 1.8.3.
- v3.5-24 - February 20, 2015
- Don't allow null uuid when adding players.
- Automatically remove players with null uuid from json.
- NPE fixes.
- v3.5-22 - February 14, 2015
- Add support for offline mode.
- v3.5-20 - January 26, 2014
- Add support for UUID in SQL mode.
- v3.5-17 - September 1, 2014
- Fix player add message.
- Fix remove command.
- Make commands more verbose.
- v3.5-15 - August 27, 2014
- Add UUID support (whitelist.json)
- v3.4 - May 15, 2014
- Add %NAME% token for kick message.
- v3.3 - March 27, 2013
- Add dbdump command.
- v3.2 - October 11, 2012
- Changed from whitelist.properties to config.yml
- Fixed the list command
- Added dblist command
- v2.7b - June 15, 2012
- Added color code support. Use ampersand color codes in the kick message.
- v2.7a - June 12, 2012
- Initial version.
- Added support for CB 1.2.3-R0.1 and higher.
@cnaude
I did it before you made the post, but like this:
sql-query=SELECT user_nicename FROM wp_users WHERE user_nicename\='<%USERNAME%>' and user_activation_key\=' '
The way you had it didn't work. It just got chopped off in the console to:
sql-query=SELECT user_nicename FROM wp_users
But it is working, so this is fantastic! Any ideas about the "add" command?
@TE5LA
If the value is empty only after they have successfully verified then use this. Basically it searches for a row matching the user and only returns a success if the user_activation_key is empty.
@cnaude
I have noticed that user_activation_key has a value if they have not verified and is empty for people that have. I'd figure I could do this in your first example, but exactly how should it read to include them only if the value is empty?
@TE5LA
1) Currently there does not appear to be a way to get multiple lines in the kick message. I've tried different things but so far nothing has worked. If you notice another plugin that does this let me know.
2) This should be possible. You need to figure out which column contains their registration status. Maybe user_activation_key or user_status. Or some other field that gets updated or can be updated after successful registration.
Then create SELECT statement that looks like this:
or just make them set a URL
No need to donate to me. I really don't play many games. :)
@cnaude
Okay, I am officially a dummy because I apparently overwrote that line with the last one you gave me, the one for listing the database. I put it back and it is working! I've tested it on three accounts and they are all connecting if they are registered. Then I removed one from the website and they couldn't connect.
This is great! This is a great plugin. Thank you so much for making this work. I may finally be able to open my server soon.
If you have a Steam account, I would like to give you some games for helping me. Look me up under the same name and tell me who you are. I have these for you. They may be on sale now but usually costs about $23. Not BF3 but pretty fun gaming.
"Renegade Ops"
Steam
Gift
Includes 3 items: Renegade Ops, Renegade Ops - Coldstrike Campaign, Renegade Ops - Reinforcement Pack
Almost perfect. Two things:
1) Can I get more than one line in the kick message? I need about three. How can I format this?
2) Any way around the fact that WP is adding new users to the database before the user has confirmed registration via email? Right now, they only have to register and are instantly on the whitelist with never having to confirm. This means they could put a bogus email in :(
It still appears that I still can't add a player with the 'whitelist add' command. This is not as big a deal as long as the site registration is working, but would be nice.
@TE5LA
Can you paste your latest "sql-query=SELECT ... " option here again? That error makes it look like the query is empty.
@cnaude
Yes, I had it on because I was using it. I also saw a tutorial video on this plugin that stated it needed to be set to "true" to work.
I have turned it off and restarted the server. I got someone to try and join who is registered on my WP site. They still get "You are not on the whitelist". Here is the console:
--------------------
2012-07-19 15:17:32 [INFO] Whitelist: Player WinstonWolfe is trying to join...
2012-07-19 15:17:33 [INFO] Whitelist: SQLException: Can not issue empty query.
2012-07-19 15:17:33 [INFO] Whitelist: SQLState: S1009
2012-07-19 15:17:33 [INFO] Whitelist: VendorError: 0
2012-07-19 15:17:33 [INFO] kick!
2012-07-19 15:17:33 [INFO] Disconnecting WinstonWolfe [/96.31.222.55:52603]: Sorry, you are not on the whitelist!
----------------------
And here is the 'dblist' showing he is indeed in the database:
---------------------
2012-07-19 15:18:38 [INFO] bigdude
2012-07-19 15:18:38 [INFO] blindwolf
2012-07-19 15:18:38 [INFO] creeperman1010
2012-07-19 15:18:38 [INFO] da-fort
2012-07-19 15:18:38 [INFO] dillonbmx
2012-07-19 15:18:38 [INFO] dr-bonesaw
2012-07-19 15:18:38 [INFO] palerider365
2012-07-19 15:18:38 [INFO] te5la
2012-07-19 15:18:38 [INFO] winstonwolfe
-----------------------
I've searched this error. Does any of this seem like a possible solution? Could this have something to do with the java thing?
http://helpx.adobe.com/coldfusion/kb/mysql-error-java-sql-sqlexception.html
http://zephyrdev.com/2010/mysql-error-sql-state-s1009-java-sql-sqlexception-value-0000-00-00-cannot-be-represented-as-java-sql-date/
P.S. what is it with these "Markup Types" in this forum? They all look like the format from hell.
@TE5LA
Do you by chance have the server built in whitelist enabled? Make sure your server.propertires has "white-list=false". The server whitelist will take precedence over the whitelist plugin.
@cnaude
Yes, dblist works. Can we assume my connection is good? I'll have to test the other stuff, don't have time right now.
Still can't connect even if I'm on the physical whitelist.txt Can't add players:
----------------
2012-07-19 09:40:09 [INFO] Whitelist: SQLException: Can not issue empty query.
2012-07-19 09:40:09 [INFO] Whitelist: SQLState: S1009
2012-07-19 09:40:09 [INFO] Whitelist: VendorError: 0
2012-07-19 09:40:09 [INFO] Could not add player "BigDude"
@TE5LA
Add this to your whitelist.properties file and download the latest test version from here.
I added a command "/whitelist dblist" that will run the query from sql-query-list and return all of the results. This will effectively tell you if it can access the database and see all of the users.
Okay, here is a dumb idea. Is there a query we can put in the properties file that would perhaps display a list of the users in the user_nicename column? There are only a few. Wouldn't this determine if it's actually accessing the database?
@cnaude
Not sure how to do that but I've been speaking with my hosting tech support and they don't see where the plugin is connecting to the database.
One thing, if this makes a difference: The MySQL database is not on the same server as the Minecraft server. Does the plugin care where the MC server is? With this line:
sql-query=SELECT user_nicename FROM wp_users WHERE user_nicename\='<%USERNAME%>'
How does it know where to be looking for the database? Is it supposed to be actively connected already via the "driver-connection" line?
Also, when this is connecting, does it need to use the password for FTP/SSH or MySQL? Because those are different passwords.
@TE5LA
The <%USERNAME%> is a special token used by the plugin. It replaces that with the username to build the select statement to query the database. When you do your test just out the actual username instead of <%USERNAME%>.
@cnaude
What is the <%USERNAME> related to in the sql-query? Is that for your plugin? It doesn't seem to be used in WP.
@TE5LA
I recommend not using the /reload command. I haven't had time to verify that the plugin works correctly with a /reload. A clean stop and start is best.
The whitelist.txt is used in addition to the mysql database. Any time a user is added to the txt file the plugin adds the user to the in-memory whitelist. If a person tries to join the MC server the plug in will check the txt file and the mysql database.
I think what you need to do is use a commnnd line mysql tool to verify that your select statement is accurate.
@cnaude
Okay, now you've lost me. What is the whitelist.txt file for then? I removed myself (only one on it) and I can still login, but I have another account and registered it on my WP site and that user can't login.
To be sure, I asked another person to try. They registered and can't login either. Whatever is supposed to happen, it isn't working with MySQL.
{Edit}
Actually, I was able to login after removing myself only because I didn't restart the server. When I did, I can no longer login.
And since I rebooted, it no longer complete reloading (Whitelist) and I can't add a user from the console.
--------
Okay, this is interesting: If I do a reload, it doesn't complete. I can't add a user. If I add the user to the list maually, they still can't login. Everything that was working earlier isn't now. The only thing working now (that never worked before) is 'whitelist list'.
@TE5LA
That is exactly correct. The plugin will not add users to the txt file automatically as they are added to the database. Instead the plugin will just check the database each time a player logs on. To test this just create a user account on WP that matches your minecraft username. Then delete your name from the txt file and try to log on. It should work.
@cnaude
So, if after a player registers and I look at the whitelist.txt file, I should not see it in the list?
@TE5LA
That looks good.
By default the add command will just add users the to the whitelist.txt file. If you have SQL enabled the add command will attempt to add to the database. If someone is added to the database, like signs up on WP, the plugin will not automatically reload. There will be no message on the console. The only indication it works is when a player tries to log on. When the player logs on the plugin will run the select against the database to see if the player is valid.
The trick to making this work with WP is that the "nice name" should match the player's username.
I got this with the "verbose" version (edited my personal stuff):
----------------------
2012-07-18 22:19:49 [INFO] Whitelist: Trying to load whitelist and settings...
2012-07-18 22:19:49 [INFO] Reading whitelist.txt
2012-07-18 22:19:49 [INFO] Adding TE5LA to allow list.
2012-07-18 22:19:49 [INFO] Reading whitelist.properties file.
2012-07-18 22:19:49 [INFO] Kick Message: Sorry, you are not on the whitelist!
2012-07-18 22:19:49 [INFO] Admin: TE5LA
2012-07-18 22:19:49 [INFO] List Command: false
2012-07-18 22:19:49 [INFO] Use SQL: true
2012-07-18 22:19:49 [INFO] SQL Driver: com.mysql.jdbc.Driver
2012-07-18 22:19:49 [INFO] Connect String: jdbc:mysql://myuser.site.nfoservers.com/xtc_homefront?user=MyUserName&password=*********
2012-07-18 22:19:49 [INFO] Select Query: SELECT user_nicename FROM wp_users WHERE user_nicename='<%USERNAME%>'
2012-07-18 22:19:49 [INFO] Add Query:
2012-07-18 22:19:49 [INFO] Remove Query:
2012-07-18 22:19:49 [INFO] SQL Driver Jar: lib/mysql-connector-java-5.1.21-bin.jar
2012-07-18 22:19:49 [INFO] done.
2012-07-18 22:19:49 [INFO] Settings and whitelist reloaded
------------------------
I noticed it said list=false, but in properties it is "disable list=false".