Renaming config classes

This commit is contained in:
nossr50 2019-03-12 00:37:26 -07:00
parent 45e785bd1f
commit d3b437f6d3
10 changed files with 62 additions and 46 deletions

View File

@ -0,0 +1,7 @@
package com.gmail.nossr50.config.hocon;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSection {
}

View File

@ -8,9 +8,6 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigDatabase extends Config { public class ConfigDatabase extends Config {
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
private ConfigCategoryMySQL configCategoryMySQL;
public ConfigDatabase() { public ConfigDatabase() {
super("mysql", ConfigConstants.getDataFolder(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, super("mysql", ConfigConstants.getDataFolder(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR,
true,true, false, true); true,true, false, true);
@ -18,6 +15,17 @@ public class ConfigDatabase extends Config {
initFullConfig(); //Load Config initFullConfig(); //Load Config
} }
/*
* CONFIG NODES
*/
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
private UserConfigSectionMySQL userConfigSectionMySQL;
/*
* CLASS OVERRIDES
*/
@Override @Override
public void unload() { public void unload() {
@ -37,7 +45,7 @@ public class ConfigDatabase extends Config {
* GETTER BOILERPLATE * GETTER BOILERPLATE
*/ */
public ConfigCategoryMySQL getConfigCategoryMySQL() { public UserConfigSectionMySQL getUserConfigSectionMySQL() {
return configCategoryMySQL; return userConfigSectionMySQL;
} }
} }

View File

@ -1,10 +1,11 @@
package com.gmail.nossr50.config.hocon.database; package com.gmail.nossr50.config.hocon.database;
import com.gmail.nossr50.config.hocon.ConfigSection;
import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigCategoryDatabase { public class UserConfigSectionDatabase extends ConfigSection {
@Setting(value = "Database_Name", comment = "The database name for your DB, this DB must already exist on the SQL server.") @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"; private String databaseName = "example_database_name";

View File

@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigCategoryMaxConnections { public class UserConfigSectionMaxConnections {
@Setting(value = "Misc") @Setting(value = "Misc")
private int misc = 30; private int misc = 30;

View File

@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigCategoryMaxPoolSize { public class UserConfigSectionMaxPoolSize {
@Setting(value = "Misc") @Setting(value = "Misc")
private int misc = 10; private int misc = 10;

View File

@ -5,19 +5,19 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigCategoryMySQL { public class UserConfigSectionMySQL {
@Setting(value = "Enabled", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage") @Setting(value = "Enabled", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage")
private boolean enabled = true; private boolean enabled = true;
@Setting(value = "User", comment = "Your MySQL User Settings") @Setting(value = "User", comment = "Your MySQL User Settings")
private ConfigCategoryUser configCategoryUser; private UserConfigSectionUser userConfigSectionUser;
@Setting(value = "Database", comment = "Database settings for MySQL/MariaDB") @Setting(value = "Database", comment = "Database settings for MySQL/MariaDB")
private ConfigCategoryDatabase configCategoryDatabase; private UserConfigSectionDatabase userConfigSectionDatabase;
@Setting(value = "Server", comment = "Your MySQL/MariaDB server settings.") @Setting(value = "Server", comment = "Your MySQL/MariaDB server settings.")
private ConfigCategoryServer configCategoryServer; private UserConfigSectionServer userConfigSectionServer;
/* /*
* GETTER BOILERPLATE * GETTER BOILERPLATE
@ -27,16 +27,16 @@ public class ConfigCategoryMySQL {
return enabled; return enabled;
} }
public ConfigCategoryUser getConfigCategoryUser() { public UserConfigSectionUser getUserConfigSectionUser() {
return configCategoryUser; return userConfigSectionUser;
} }
public ConfigCategoryDatabase getConfigCategoryDatabase() { public UserConfigSectionDatabase getUserConfigSectionDatabase() {
return configCategoryDatabase; return userConfigSectionDatabase;
} }
public ConfigCategoryServer getConfigCategoryServer() { public UserConfigSectionServer getUserConfigSectionServer() {
return configCategoryServer; return userConfigSectionServer;
} }
public int getMaxPoolSize(SQLDatabaseManager.PoolIdentifier poolIdentifier) public int getMaxPoolSize(SQLDatabaseManager.PoolIdentifier poolIdentifier)
@ -44,11 +44,11 @@ public class ConfigCategoryMySQL {
switch (poolIdentifier) switch (poolIdentifier)
{ {
case LOAD: case LOAD:
return configCategoryServer.getConfigCategoryMaxPoolSize().getLoad(); return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getLoad();
case SAVE: case SAVE:
return configCategoryServer.getConfigCategoryMaxPoolSize().getSave(); return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getSave();
case MISC: case MISC:
return configCategoryServer.getConfigCategoryMaxPoolSize().getMisc(); return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getMisc();
default: default:
return 20; return 20;
} }
@ -59,11 +59,11 @@ public class ConfigCategoryMySQL {
switch (poolIdentifier) switch (poolIdentifier)
{ {
case LOAD: case LOAD:
return configCategoryServer.getConfigCategoryMaxPoolSize().getLoad(); return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getLoad();
case SAVE: case SAVE:
return configCategoryServer.getConfigCategoryMaxPoolSize().getSave(); return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getSave();
case MISC: case MISC:
return configCategoryServer.getConfigCategoryMaxPoolSize().getMisc(); return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getMisc();
default: default:
return 20; return 20;
} }

View File

@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable @ConfigSerializable
public class ConfigCategoryServer { public class UserConfigSectionServer {
@Setting(value = "Use_SSL", comment = "Enables SSL for MySQL/MariaDB connections, newer versions of MySQL will spam your console if you aren't using SSL." + @Setting(value = "Use_SSL", comment = "Enables SSL for MySQL/MariaDB connections, newer versions of MySQL will spam your console if you aren't using SSL." +
" It is recommended that you turn this on if you are using a newer version of MySQL," + " It is recommended that you turn this on if you are using a newer version of MySQL," +
@ -18,10 +18,10 @@ public class ConfigCategoryServer {
private String serverAddress = "localhost"; 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") @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; private UserConfigSectionMaxConnections userConfigSectionMaxConnections;
@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.") @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; private UserConfigSectionMaxPoolSize userConfigSectionMaxPoolSize;
/* /*
* GETTER BOILERPLATE * GETTER BOILERPLATE
@ -39,12 +39,12 @@ public class ConfigCategoryServer {
return serverAddress; return serverAddress;
} }
public ConfigCategoryMaxConnections getConfigCategoryMaxConnections() { public UserConfigSectionMaxConnections getUserConfigSectionMaxConnections() {
return configCategoryMaxConnections; return userConfigSectionMaxConnections;
} }
public ConfigCategoryMaxPoolSize getConfigCategoryMaxPoolSize() { public UserConfigSectionMaxPoolSize getUserConfigSectionMaxPoolSize() {
return configCategoryMaxPoolSize; return userConfigSectionMaxPoolSize;
} }

View File

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

View File

@ -22,7 +22,7 @@ import java.util.concurrent.locks.ReentrantLock;
public final class SQLDatabaseManager implements DatabaseManager { public final class SQLDatabaseManager implements DatabaseManager {
private static final String ALL_QUERY_VERSION = "total"; private static final String ALL_QUERY_VERSION = "total";
public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver"; public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver";
private String tablePrefix = mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getTablePrefix(); private String tablePrefix = mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getTablePrefix();
private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>(); private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>();
@ -33,10 +33,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
private ReentrantLock massUpdateLock = new ReentrantLock(); private ReentrantLock massUpdateLock = new ReentrantLock();
protected SQLDatabaseManager() { protected SQLDatabaseManager() {
String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getConfigCategoryServer().getServerAddress() String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerAddress()
+ ":" + mcMMO.getMySQLConfigSettings().getConfigCategoryServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName(); + ":" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName();
if(mcMMO.getMySQLConfigSettings().getConfigCategoryServer().isUseSSL()) if(mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().isUseSSL())
connectionString += connectionString +=
"?verifyServerCertificate=false"+ "?verifyServerCertificate=false"+
"&useSSL=true"+ "&useSSL=true"+
@ -85,9 +85,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties.setUrl(connectionString); poolProperties.setUrl(connectionString);
//MySQL User Name //MySQL User Name
poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getConfigCategoryUser().getUsername()); poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().getUsername());
//MySQL User Password //MySQL User Password
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getConfigCategoryUser().getPassword()); poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().getPassword());
//Initial Size //Initial Size
poolProperties.setInitialSize(0); poolProperties.setInitialSize(0);
@ -783,7 +783,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " WHERE table_schema = ?" + " WHERE table_schema = ?"
+ " AND table_name = ?"); + " AND table_name = ?");
//Database name //Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName()); statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "users"); statement.setString(2, tablePrefix + "users");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (!resultSet.next()) { if (!resultSet.next()) {
@ -800,7 +800,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
tryClose(resultSet); tryClose(resultSet);
//Database name //Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName()); statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "huds"); statement.setString(2, tablePrefix + "huds");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (!resultSet.next()) { if (!resultSet.next()) {
@ -815,7 +815,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
tryClose(resultSet); tryClose(resultSet);
//Database name //Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName()); statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "cooldowns"); statement.setString(2, tablePrefix + "cooldowns");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (!resultSet.next()) { if (!resultSet.next()) {
@ -841,7 +841,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
tryClose(resultSet); tryClose(resultSet);
//Database name //Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName()); statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "skills"); statement.setString(2, tablePrefix + "skills");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (!resultSet.next()) { if (!resultSet.next()) {
@ -870,7 +870,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
tryClose(resultSet); tryClose(resultSet);
//Database name //Database name
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName()); statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
statement.setString(2, tablePrefix + "experience"); statement.setString(2, tablePrefix + "experience");
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (!resultSet.next()) { 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.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.database.ConfigCategoryMySQL; import com.gmail.nossr50.config.hocon.database.UserConfigSectionMySQL;
import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory; import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -327,9 +327,9 @@ public class mcMMO extends JavaPlugin {
* Returns settings for MySQL from the users config * Returns settings for MySQL from the users config
* @return returns settings for MySQL from the users config * @return returns settings for MySQL from the users config
*/ */
public static ConfigCategoryMySQL getMySQLConfigSettings() public static UserConfigSectionMySQL getMySQLConfigSettings()
{ {
return configManager.getConfigDatabase().getConfigCategoryMySQL(); return configManager.getConfigDatabase().getUserConfigSectionMySQL();
} }
/*public static ModManager getModManager() { /*public static ModManager getModManager() {