From 1c289cfcdfa52715979e371dba1078a1b7f2d533 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 13 Mar 2019 07:10:57 -0700 Subject: [PATCH] Refactoring SQL config class names again --- .../hocon/{ => antiexploit}/AntiExploit.java | 0 .../config/hocon/database/ConfigDatabase.java | 9 ++++--- ...tabase.java => ConfigSectionDatabase.java} | 2 +- ....java => ConfigSectionMaxConnections.java} | 8 +++--- ...ize.java => ConfigSectionMaxPoolSize.java} | 8 +++--- ...tionMySQL.java => ConfigSectionMySQL.java} | 26 +++++++++---------- ...ectionUser.java => ConfigSectionUser.java} | 2 +- .../database/UserConfigSectionServer.java | 12 ++++----- .../hocon/{ => scoreboard}/Scoreboard.java | 0 .../nossr50/database/SQLDatabaseManager.java | 18 ++++++------- src/main/java/com/gmail/nossr50/mcMMO.java | 6 ++--- src/main/resources/config/anti_exploit.conf | 0 src/main/resources/config/backups.conf | 0 src/main/resources/config/commands.conf | 0 src/main/resources/config/database.conf | 0 src/main/resources/config/general.conf | 0 src/main/resources/config/hardcore.conf | 0 src/main/resources/config/items.conf | 0 src/main/resources/config/language.conf | 0 src/main/resources/config/leveling.conf | 0 src/main/resources/config/metrics.conf | 0 src/main/resources/config/notifications.conf | 0 src/main/resources/config/particles.conf | 0 src/main/resources/config/party.conf | 0 src/main/resources/config/scoreboard.conf | 0 .../resources/config/skills/acrobatics.conf | 0 src/main/resources/config/skills/alchemy.conf | 0 .../resources/config/super_abilities.conf | 0 28 files changed, 47 insertions(+), 44 deletions(-) rename src/main/java/com/gmail/nossr50/config/hocon/{ => antiexploit}/AntiExploit.java (100%) rename src/main/java/com/gmail/nossr50/config/hocon/database/{UserConfigSectionDatabase.java => ConfigSectionDatabase.java} (94%) rename src/main/java/com/gmail/nossr50/config/hocon/database/{UserConfigSectionMaxConnections.java => ConfigSectionMaxConnections.java} (73%) rename src/main/java/com/gmail/nossr50/config/hocon/database/{UserConfigSectionMaxPoolSize.java => ConfigSectionMaxPoolSize.java} (77%) rename src/main/java/com/gmail/nossr50/config/hocon/database/{UserConfigSectionMySQL.java => ConfigSectionMySQL.java} (60%) rename src/main/java/com/gmail/nossr50/config/hocon/database/{UserConfigSectionUser.java => ConfigSectionUser.java} (94%) rename src/main/java/com/gmail/nossr50/config/hocon/{ => scoreboard}/Scoreboard.java (100%) delete mode 100644 src/main/resources/config/anti_exploit.conf delete mode 100644 src/main/resources/config/backups.conf delete mode 100644 src/main/resources/config/commands.conf delete mode 100644 src/main/resources/config/database.conf delete mode 100644 src/main/resources/config/general.conf delete mode 100644 src/main/resources/config/hardcore.conf delete mode 100644 src/main/resources/config/items.conf delete mode 100644 src/main/resources/config/language.conf delete mode 100644 src/main/resources/config/leveling.conf delete mode 100644 src/main/resources/config/metrics.conf delete mode 100644 src/main/resources/config/notifications.conf delete mode 100644 src/main/resources/config/particles.conf delete mode 100644 src/main/resources/config/party.conf delete mode 100644 src/main/resources/config/scoreboard.conf delete mode 100644 src/main/resources/config/skills/acrobatics.conf delete mode 100644 src/main/resources/config/skills/alchemy.conf delete mode 100644 src/main/resources/config/super_abilities.conf diff --git a/src/main/java/com/gmail/nossr50/config/hocon/AntiExploit.java b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/AntiExploit.java similarity index 100% rename from src/main/java/com/gmail/nossr50/config/hocon/AntiExploit.java rename to src/main/java/com/gmail/nossr50/config/hocon/antiexploit/AntiExploit.java diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java index 24b1c7f4a..9bcc07e4c 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java @@ -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; } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionDatabase.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java similarity index 94% rename from src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionDatabase.java rename to src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java index 7cd5b05d7..d9ea0cfb7 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionDatabase.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java @@ -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"; diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMaxConnections.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java similarity index 73% rename from src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMaxConnections.java rename to src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java index 1f17ba008..db3228032 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMaxConnections.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java @@ -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; /* diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMaxPoolSize.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java similarity index 77% rename from src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMaxPoolSize.java rename to src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java index 3af87ba09..8d92982f7 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMaxPoolSize.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java @@ -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; /* diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMySQL.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java similarity index 60% rename from src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMySQL.java rename to src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java index 54ff7ba5b..ad4c5bfb9 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionMySQL.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java @@ -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; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionUser.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java similarity index 94% rename from src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionUser.java rename to src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java index 1c86f57cd..ab9088221 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionUser.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java @@ -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"; diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java b/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java index 823f8d5ca..5140003e6 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java @@ -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; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/Scoreboard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/Scoreboard.java similarity index 100% rename from src/main/java/com/gmail/nossr50/config/hocon/Scoreboard.java rename to src/main/java/com/gmail/nossr50/config/hocon/scoreboard/Scoreboard.java diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index b8b27b2ee..781a89b06 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -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 cachedUserIDs = new HashMap(); @@ -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()) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index cb16b2e23..eff88a791 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -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() { diff --git a/src/main/resources/config/anti_exploit.conf b/src/main/resources/config/anti_exploit.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/backups.conf b/src/main/resources/config/backups.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/commands.conf b/src/main/resources/config/commands.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/database.conf b/src/main/resources/config/database.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/general.conf b/src/main/resources/config/general.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/hardcore.conf b/src/main/resources/config/hardcore.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/items.conf b/src/main/resources/config/items.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/language.conf b/src/main/resources/config/language.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/leveling.conf b/src/main/resources/config/leveling.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/metrics.conf b/src/main/resources/config/metrics.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/notifications.conf b/src/main/resources/config/notifications.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/particles.conf b/src/main/resources/config/particles.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/party.conf b/src/main/resources/config/party.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/scoreboard.conf b/src/main/resources/config/scoreboard.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/skills/acrobatics.conf b/src/main/resources/config/skills/acrobatics.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/skills/alchemy.conf b/src/main/resources/config/skills/alchemy.conf deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/resources/config/super_abilities.conf b/src/main/resources/config/super_abilities.conf deleted file mode 100644 index e69de29bb..000000000