Refactoring SQL config class names again

This commit is contained in:
nossr50 2019-03-13 07:10:57 -07:00
parent a8bf6357aa
commit 1c289cfcdf
28 changed files with 47 additions and 44 deletions

View File

@ -11,13 +11,16 @@ public class ConfigDatabase {
*/
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
private UserConfigSectionMySQL userConfigSectionMySQL = new UserConfigSectionMySQL();
private ConfigSectionMySQL configSectionMySQL = new ConfigSectionMySQL();
@Setting(value = "Enabled", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage")
private boolean enabled = true;
/*
* GETTER BOILERPLATE
*/
public UserConfigSectionMySQL getUserConfigSectionMySQL() {
return userConfigSectionMySQL;
public ConfigSectionMySQL getConfigSectionMySQL() {
return configSectionMySQL;
}
}

View File

@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class UserConfigSectionDatabase {
public class ConfigSectionDatabase {
@Setting(value = "Database_Name", comment = "The database name for your DB, this DB must already exist on the SQL server.")
private String databaseName = "example_database_name";

View File

@ -4,15 +4,15 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class UserConfigSectionMaxConnections {
public class ConfigSectionMaxConnections {
@Setting(value = "Misc")
@Setting(value = "Misc_Connection_Limit")
private int misc = 30;
@Setting(value = "Load")
@Setting(value = "Load_Connection_Limit")
private int load = 30;
@Setting(value = "Save")
@Setting(value = "Save_Connection_Limit")
private int save = 30;
/*

View File

@ -4,14 +4,14 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class UserConfigSectionMaxPoolSize {
@Setting(value = "Misc")
public class ConfigSectionMaxPoolSize {
@Setting(value = "Misc_Pool")
private int misc = 10;
@Setting(value = "Load")
@Setting(value = "Load_Pool")
private int load = 20;
@Setting(value = "Save")
@Setting(value = "Save_Pool")
private int save = 20;
/*

View File

@ -5,16 +5,16 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class UserConfigSectionMySQL {
public class ConfigSectionMySQL {
@Setting(value = "Enabled", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage")
private boolean enabled = true;
@Setting(value = "User", comment = "Your MySQL User Settings")
private UserConfigSectionUser userConfigSectionUser = new UserConfigSectionUser();
private ConfigSectionUser configSectionUser = new ConfigSectionUser();
@Setting(value = "Database", comment = "Database settings for MySQL/MariaDB")
private UserConfigSectionDatabase userConfigSectionDatabase = new UserConfigSectionDatabase();
private ConfigSectionDatabase configSectionDatabase = new ConfigSectionDatabase();
@Setting(value = "Server", comment = "Your MySQL/MariaDB server settings.")
private UserConfigSectionServer userConfigSectionServer = new UserConfigSectionServer();
@ -27,12 +27,12 @@ public class UserConfigSectionMySQL {
return enabled;
}
public UserConfigSectionUser getUserConfigSectionUser() {
return userConfigSectionUser;
public ConfigSectionUser getConfigSectionUser() {
return configSectionUser;
}
public UserConfigSectionDatabase getUserConfigSectionDatabase() {
return userConfigSectionDatabase;
public ConfigSectionDatabase getConfigSectionDatabase() {
return configSectionDatabase;
}
public UserConfigSectionServer getUserConfigSectionServer() {
@ -44,11 +44,11 @@ public class UserConfigSectionMySQL {
switch (poolIdentifier)
{
case LOAD:
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getLoad();
return userConfigSectionServer.getConfigSectionMaxPoolSize().getLoad();
case SAVE:
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getSave();
return userConfigSectionServer.getConfigSectionMaxPoolSize().getSave();
case MISC:
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getMisc();
return userConfigSectionServer.getConfigSectionMaxPoolSize().getMisc();
default:
return 20;
}
@ -59,11 +59,11 @@ public class UserConfigSectionMySQL {
switch (poolIdentifier)
{
case LOAD:
return userConfigSectionServer.getUserConfigSectionMaxConnections().getLoad();
return userConfigSectionServer.getConfigSectionMaxConnections().getLoad();
case SAVE:
return userConfigSectionServer.getUserConfigSectionMaxConnections().getSave();
return userConfigSectionServer.getConfigSectionMaxConnections().getSave();
case MISC:
return userConfigSectionServer.getUserConfigSectionMaxConnections().getMisc();
return userConfigSectionServer.getConfigSectionMaxConnections().getMisc();
default:
return 20;
}

View File

@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class UserConfigSectionUser {
public class ConfigSectionUser {
@Setting(value = "User_Name", comment = "The authorized user for your MySQL/MariaDB DB")
private String username = "example_user_name";

View File

@ -21,10 +21,10 @@ public class UserConfigSectionServer {
@Setting(value = "Max_Connections", comment = "This setting is the max simultaneous MySQL/MariaDB connections allowed at a time." +
"\nThis needs to be high enough to support multiple player logins in quick succession, it is recommended that you do not lower these values")
private UserConfigSectionMaxConnections userConfigSectionMaxConnections = new UserConfigSectionMaxConnections();
private ConfigSectionMaxConnections configSectionMaxConnections = new ConfigSectionMaxConnections();
@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 UserConfigSectionMaxPoolSize userConfigSectionMaxPoolSize = new UserConfigSectionMaxPoolSize();
private ConfigSectionMaxPoolSize configSectionMaxPoolSize = new ConfigSectionMaxPoolSize();
/*
* GETTER BOILERPLATE
@ -42,12 +42,12 @@ public class UserConfigSectionServer {
return serverAddress;
}
public UserConfigSectionMaxConnections getUserConfigSectionMaxConnections() {
return userConfigSectionMaxConnections;
public ConfigSectionMaxConnections getConfigSectionMaxConnections() {
return configSectionMaxConnections;
}
public UserConfigSectionMaxPoolSize getUserConfigSectionMaxPoolSize() {
return userConfigSectionMaxPoolSize;
public ConfigSectionMaxPoolSize getConfigSectionMaxPoolSize() {
return configSectionMaxPoolSize;
}

View File

@ -22,7 +22,7 @@ import java.util.concurrent.locks.ReentrantLock;
public final class SQLDatabaseManager implements DatabaseManager {
private static final String ALL_QUERY_VERSION = "total";
public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver";
private String tablePrefix = mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getTablePrefix();
private String tablePrefix = mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix();
private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>();
@ -34,7 +34,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
protected SQLDatabaseManager() {
String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerAddress()
+ ":" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName();
+ ":" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName();
if(mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().isUseSSL())
connectionString +=
@ -85,9 +85,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties.setUrl(connectionString);
//MySQL User Name
poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().getUsername());
poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getConfigSectionUser().getUsername());
//MySQL User Password
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().getPassword());
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getConfigSectionUser().getPassword());
//Initial Size
poolProperties.setInitialSize(0);
@ -783,7 +783,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " WHERE table_schema = ?"
+ " AND table_name = ?");
//Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "users");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -800,7 +800,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
tryClose(resultSet);
//Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "huds");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -815,7 +815,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
tryClose(resultSet);
//Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "cooldowns");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -841,7 +841,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
tryClose(resultSet);
//Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "skills");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
@ -870,7 +870,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
tryClose(resultSet);
//Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "experience");
resultSet = statement.executeQuery();
if (!resultSet.next()) {

View File

@ -5,7 +5,7 @@ import com.gmail.nossr50.config.CoreSkillsConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.database.UserConfigSectionMySQL;
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -327,9 +327,9 @@ public class mcMMO extends JavaPlugin {
* Returns settings for MySQL from the users config
* @return returns settings for MySQL from the users config
*/
public static UserConfigSectionMySQL getMySQLConfigSettings()
public static ConfigSectionMySQL getMySQLConfigSettings()
{
return configManager.getConfigDatabase().getUserConfigSectionMySQL();
return configManager.getConfigDatabase().getConfigSectionMySQL();
}
/*public static ModManager getModManager() {