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

View File

@ -68,7 +68,7 @@ public final class Settings extends YamlConfiguration {
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin, broadcastWelcomeMessage, forceRegKick, forceRegLogin,
checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect, checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
customAttributes, generateImage, isRemoveSpeedEnabled; customAttributes, generateImage, isRemoveSpeedEnabled, isMySQLWebsite;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
@ -275,6 +275,7 @@ public final class Settings extends YamlConfiguration {
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole"); forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
customAttributes = configFile.getBoolean("Hooks.customAttributes"); customAttributes = configFile.getBoolean("Hooks.customAttributes");
generateImage = configFile.getBoolean("Email.generateImage", true); generateImage = configFile.getBoolean("Email.generateImage", true);
isMySQLWebsite = configFile.getBoolean("DataSource.mySQLWebsite", false);
// Load the welcome message // Load the welcome message
getWelcomeMessage(); getWelcomeMessage();
@ -476,6 +477,10 @@ public final class Settings extends YamlConfiguration {
set("DataSource.mySQLRealName", "realname"); set("DataSource.mySQLRealName", "realname");
changes = true; changes = true;
} }
if (!contains("DataSource.mySQLQueryCache")) {
set("DataSource.mySQLWebsite", false);
changes = true;
}
if (changes) { if (changes) {
plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me"); 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 mySQLlastlocWorld: world
# Column for RealName # Column for RealName
mySQLRealName: realname mySQLRealName: realname
# Enable this when you allow registration through a website
mySQLWebsite: false
settings: settings:
sessions: sessions:
# Do you want to enable the session feature? # Do you want to enable the session feature?
# If enabled, when a player authenticates successfully, # If enabled, when a player authenticates successfully,
# his IP and his nickname is saved. # 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 # is the same of the last time, and the timeout time
# hasn't expired, he will not need to authenticate. # hasn't expired, he will not need to authenticate.
enabled: false enabled: false
@ -62,7 +64,7 @@ settings:
# another IP Address? # another IP Address?
sessionExpireOnIpChange: true sessionExpireOnIpChange: true
restrictions: 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 # Care that this feature blocks also all the commands not
# listed in the list below. # listed in the list below.
allowChat: false allowChat: false
@ -109,7 +111,7 @@ settings:
# After the authentication they will be teleported back to # After the authentication they will be teleported back to
# their normal position. # their normal position.
teleportUnAuthedToSpawn: false teleportUnAuthedToSpawn: false
# Minimum allowed nick length # Minimum allowed nick length
minNicknameLength: 4 minNicknameLength: 4
# Can unregistered players walk around? # Can unregistered players walk around?
allowMovement: false allowMovement: false
@ -161,25 +163,25 @@ settings:
security: security:
# minimum Length of password # minimum Length of password
minPasswordLength: 5 minPasswordLength: 5
# this is very important options, # this is very important options,
# every time player join the server, # 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 # to unLoggedInGroup, this
# should prevent all major exploit. # should prevent all major exploit.
# So you can set up on your Permission Plugin # 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 # 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 # the better way is to set up
# this group with few permissions, # this group with few permissions,
# so if player try to exploit some account, # so if player try to exploit some account,
# they can # they can
# do anything except what you set in perm Group. # 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! # moved to his correct permissions group!
# Pay attention group name is case sensitive, # Pay attention group name is case sensitive,
# so Admin is different from admin, # so Admin is different from admin,
# otherwise your group will be wiped, # otherwise your group will be wiped,
# and player join in default group []! # and player join in default group []!
# Example unLoggedinGroup: NotLogged # Example unLoggedinGroup: NotLogged
unLoggedinGroup: unLoggedinGroup 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 # Force these commands after /register as a server console, without any '/', use %p for replace with player name
forceRegisterCommandsAsConsole: [] forceRegisterCommandsAsConsole: []
# Do we need to display the welcome message (welcome.txt) after a register or a login? # 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, # {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 # {IP} : player ip, {LOGINS} : number of players logged, {WORLD} : player current world, {SERVER} : server name
# {VERSION} : get current bukkit version, {COUNTRY} : player country # {VERSION} : get current bukkit version, {COUNTRY} : player country