Rewiring the SQL code to the new configs

This commit is contained in:
nossr50
2019-03-12 00:09:51 -07:00
parent e94005df34
commit be69f0d6a7
5 changed files with 126 additions and 66 deletions

View File

@ -12,11 +12,7 @@ public class ConfigCategoryDatabase {
@Setting(value = "Table_Prefix", comment = "The Prefix that will be used for tables in your DB")
private String tablePrefix = "mcmmo_";
@Setting(value = "Max_Connections", comment = "This setting is the max simultaneous MySQL/MariaDB connections allowed at a time, this needs to be high enough to support multiple player logins in quick succession")
private ConfigCategoryMaxConnections configCategoryMaxConnections;
@Setting(value = "Max_Pool_Size", comment = "This setting is the max size of the pool of cached connections that we hold at any given time.")
private ConfigCategoryMaxPoolSize configCategoryMaxPoolSize;
/*
* GETTER BOILERPLATE
@ -30,11 +26,5 @@ public class ConfigCategoryDatabase {
return tablePrefix;
}
public ConfigCategoryMaxConnections getConfigCategoryMaxConnections() {
return configCategoryMaxConnections;
}
public ConfigCategoryMaxPoolSize getConfigCategoryMaxPoolSize() {
return configCategoryMaxPoolSize;
}
}

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.config.hocon.database;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.mcMMO;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -26,6 +28,10 @@ public class ConfigCategoryMySQL {
return enabled;
}
public ConfigCategoryUser getConfigCategoryUser() {
return configCategoryUser;
}
public ConfigCategoryDatabase getConfigCategoryDatabase() {
return configCategoryDatabase;
}
@ -33,4 +39,34 @@ public class ConfigCategoryMySQL {
public ConfigCategoryServer getConfigCategoryServer() {
return configCategoryServer;
}
public int getMaxPoolSize(SQLDatabaseManager.PoolIdentifier poolIdentifier)
{
switch (poolIdentifier)
{
case LOAD:
return configCategoryServer.getConfigCategoryMaxPoolSize().getLoad();
case SAVE:
return configCategoryServer.getConfigCategoryMaxPoolSize().getSave();
case MISC:
return configCategoryServer.getConfigCategoryMaxPoolSize().getMisc();
default:
return 20;
}
}
public int getMaxConnections(SQLDatabaseManager.PoolIdentifier poolIdentifier)
{
switch (poolIdentifier)
{
case LOAD:
return configCategoryServer.getConfigCategoryMaxPoolSize().getLoad();
case SAVE:
return configCategoryServer.getConfigCategoryMaxPoolSize().getSave();
case MISC:
return configCategoryServer.getConfigCategoryMaxPoolSize().getMisc();
default:
return 20;
}
}
}

View File

@ -17,6 +17,12 @@ public class ConfigCategoryServer {
@Setting(value = "Server_Address", comment = "The address for your MySQL/MariaDB server")
private String serverAddress = "localhost";
@Setting(value = "Max_Connections", comment = "This setting is the max simultaneous MySQL/MariaDB connections allowed at a time, this needs to be high enough to support multiple player logins in quick succession")
private ConfigCategoryMaxConnections configCategoryMaxConnections;
@Setting(value = "Max_Pool_Size", comment = "This setting is the max size of the pool of cached connections that we hold at any given time.")
private ConfigCategoryMaxPoolSize configCategoryMaxPoolSize;
/*
* GETTER BOILERPLATE
*/
@ -32,4 +38,14 @@ public class ConfigCategoryServer {
public String getServerAddress() {
return serverAddress;
}
public ConfigCategoryMaxConnections getConfigCategoryMaxConnections() {
return configCategoryMaxConnections;
}
public ConfigCategoryMaxPoolSize getConfigCategoryMaxPoolSize() {
return configCategoryMaxPoolSize;
}
}