Add an option to disable all caching (useful if you use website

registration system)
This commit is contained in:
vanhec_a 2015-10-12 15:49:19 +02:00
parent 5e991f7f42
commit 39ab41f542
3 changed files with 33 additions and 18 deletions

View File

@ -102,9 +102,15 @@ public class MySQL implements DataSource {
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
config.setUsername(this.username);
config.setPassword(this.password);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
if (Settings.isMySQLWebsite)
{
config.addDataSourceProperty("cachePrepStmts", "false");
}
else {
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
}
config.addDataSourceProperty("autoReconnect", false);
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
config.setMaxLifetime(180000); // 3 Min
@ -197,6 +203,8 @@ public class MySQL implements DataSource {
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnRealName + " VARCHAR(255) NOT NULL DEFAULT 'Player' AFTER " + columnLogged + ";");
}
if (Settings.isMySQLWebsite)
st.execute("SET GLOBAL query_cache_size = 0; SET GLOBAL query_cache_type = 0;");
} finally {
close(rs);
close(st);

View File

@ -68,7 +68,7 @@ public final class Settings extends YamlConfiguration {
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
customAttributes, generateImage, isRemoveSpeedEnabled;
customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
@ -275,6 +275,7 @@ public final class Settings extends YamlConfiguration {
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
customAttributes = configFile.getBoolean("Hooks.customAttributes");
generateImage = configFile.getBoolean("Email.generateImage", true);
isMySQLWebsite = configFile.getBoolean("DataSource.mySQLWebsite", false);
// Load the welcome message
getWelcomeMessage();
@ -476,6 +477,10 @@ public final class Settings extends YamlConfiguration {
set("DataSource.mySQLRealName", "realname");
changes = true;
}
if (!contains("DataSource.mySQLQueryCache")) {
set("DataSource.mySQLWebsite", false);
changes = true;
}
if (changes) {
plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me");

View File

@ -43,12 +43,14 @@ DataSource:
mySQLlastlocWorld: world
# Column for RealName
mySQLRealName: realname
# Enable this when you allow registration through a website
mySQLWebsite: false
settings:
sessions:
# Do you want to enable the session feature?
# Do you want to enable the session feature?
# If enabled, when a player authenticates successfully,
# his IP and his nickname is saved.
# The next time the player joins the server, if his IP
# The next time the player joins the server, if his IP
# is the same of the last time, and the timeout time
# hasn't expired, he will not need to authenticate.
enabled: false
@ -62,7 +64,7 @@ settings:
# another IP Address?
sessionExpireOnIpChange: true
restrictions:
# Can not authenticated players chat and see the chat log?
# Can not authenticated players chat and see the chat log?
# Care that this feature blocks also all the commands not
# listed in the list below.
allowChat: false
@ -109,7 +111,7 @@ settings:
# After the authentication they will be teleported back to
# their normal position.
teleportUnAuthedToSpawn: false
# Minimum allowed nick length
# Minimum allowed nick length
minNicknameLength: 4
# Can unregistered players walk around?
allowMovement: false
@ -161,25 +163,25 @@ settings:
security:
# minimum Length of password
minPasswordLength: 5
# this is very important options,
# this is very important options,
# every time player join the server,
# if they are registered, AuthMe will switch him
# if they are registered, AuthMe will switch him
# to unLoggedInGroup, this
# should prevent all major exploit.
# should prevent all major exploit.
# So you can set up on your Permission Plugin
# this special group with 0 permissions, or permissions to chat,
# this special group with 0 permissions, or permissions to chat,
# or permission to
# send private message or all other perms that you want,
# send private message or all other perms that you want,
# the better way is to set up
# this group with few permissions,
# so if player try to exploit some account,
# they can
# do anything except what you set in perm Group.
# After a correct logged-in player will be
# After a correct logged-in player will be
# moved to his correct permissions group!
# Pay attention group name is case sensitive,
# so Admin is different from admin,
# otherwise your group will be wiped,
# Pay attention group name is case sensitive,
# so Admin is different from admin,
# otherwise your group will be wiped,
# and player join in default group []!
# Example unLoggedinGroup: NotLogged
unLoggedinGroup: unLoggedinGroup
@ -244,7 +246,7 @@ settings:
# Force these commands after /register as a server console, without any '/', use %p for replace with player name
forceRegisterCommandsAsConsole: []
# Do we need to display the welcome message (welcome.txt) after a register or a login?
# You can use colors in this welcome.txt + some replaced strings :
# You can use colors in this welcome.txt + some replaced strings :
# {PLAYER} : player name, {ONLINE} : display number of online players, {MAXPLAYERS} : display server slots,
# {IP} : player ip, {LOGINS} : number of players logged, {WORLD} : player current world, {SERVER} : server name
# {VERSION} : get current bukkit version, {COUNTRY} : player country