mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Renaming config classes
This commit is contained in:
parent
45e785bd1f
commit
d3b437f6d3
@ -0,0 +1,7 @@
|
||||
package com.gmail.nossr50.config.hocon;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigSection {
|
||||
}
|
@ -8,9 +8,6 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
@ConfigSerializable
|
||||
public class ConfigDatabase extends Config {
|
||||
|
||||
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
|
||||
private ConfigCategoryMySQL configCategoryMySQL;
|
||||
|
||||
public ConfigDatabase() {
|
||||
super("mysql", ConfigConstants.getDataFolder(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR,
|
||||
true,true, false, true);
|
||||
@ -18,6 +15,17 @@ public class ConfigDatabase extends Config {
|
||||
initFullConfig(); //Load Config
|
||||
}
|
||||
|
||||
/*
|
||||
* CONFIG NODES
|
||||
*/
|
||||
|
||||
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
|
||||
private UserConfigSectionMySQL userConfigSectionMySQL;
|
||||
|
||||
/*
|
||||
* CLASS OVERRIDES
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
|
||||
@ -37,7 +45,7 @@ public class ConfigDatabase extends Config {
|
||||
* GETTER BOILERPLATE
|
||||
*/
|
||||
|
||||
public ConfigCategoryMySQL getConfigCategoryMySQL() {
|
||||
return configCategoryMySQL;
|
||||
public UserConfigSectionMySQL getUserConfigSectionMySQL() {
|
||||
return userConfigSectionMySQL;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
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.serialize.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.")
|
||||
private String databaseName = "example_database_name";
|
@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigCategoryMaxConnections {
|
||||
public class UserConfigSectionMaxConnections {
|
||||
|
||||
@Setting(value = "Misc")
|
||||
private int misc = 30;
|
@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigCategoryMaxPoolSize {
|
||||
public class UserConfigSectionMaxPoolSize {
|
||||
@Setting(value = "Misc")
|
||||
private int misc = 10;
|
||||
|
@ -5,19 +5,19 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.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")
|
||||
private boolean enabled = true;
|
||||
|
||||
@Setting(value = "User", comment = "Your MySQL User Settings")
|
||||
private ConfigCategoryUser configCategoryUser;
|
||||
private UserConfigSectionUser userConfigSectionUser;
|
||||
|
||||
@Setting(value = "Database", comment = "Database settings for MySQL/MariaDB")
|
||||
private ConfigCategoryDatabase configCategoryDatabase;
|
||||
private UserConfigSectionDatabase userConfigSectionDatabase;
|
||||
|
||||
@Setting(value = "Server", comment = "Your MySQL/MariaDB server settings.")
|
||||
private ConfigCategoryServer configCategoryServer;
|
||||
private UserConfigSectionServer userConfigSectionServer;
|
||||
|
||||
/*
|
||||
* GETTER BOILERPLATE
|
||||
@ -27,16 +27,16 @@ public class ConfigCategoryMySQL {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public ConfigCategoryUser getConfigCategoryUser() {
|
||||
return configCategoryUser;
|
||||
public UserConfigSectionUser getUserConfigSectionUser() {
|
||||
return userConfigSectionUser;
|
||||
}
|
||||
|
||||
public ConfigCategoryDatabase getConfigCategoryDatabase() {
|
||||
return configCategoryDatabase;
|
||||
public UserConfigSectionDatabase getUserConfigSectionDatabase() {
|
||||
return userConfigSectionDatabase;
|
||||
}
|
||||
|
||||
public ConfigCategoryServer getConfigCategoryServer() {
|
||||
return configCategoryServer;
|
||||
public UserConfigSectionServer getUserConfigSectionServer() {
|
||||
return userConfigSectionServer;
|
||||
}
|
||||
|
||||
public int getMaxPoolSize(SQLDatabaseManager.PoolIdentifier poolIdentifier)
|
||||
@ -44,11 +44,11 @@ public class ConfigCategoryMySQL {
|
||||
switch (poolIdentifier)
|
||||
{
|
||||
case LOAD:
|
||||
return configCategoryServer.getConfigCategoryMaxPoolSize().getLoad();
|
||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getLoad();
|
||||
case SAVE:
|
||||
return configCategoryServer.getConfigCategoryMaxPoolSize().getSave();
|
||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getSave();
|
||||
case MISC:
|
||||
return configCategoryServer.getConfigCategoryMaxPoolSize().getMisc();
|
||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getMisc();
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
@ -59,11 +59,11 @@ public class ConfigCategoryMySQL {
|
||||
switch (poolIdentifier)
|
||||
{
|
||||
case LOAD:
|
||||
return configCategoryServer.getConfigCategoryMaxPoolSize().getLoad();
|
||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getLoad();
|
||||
case SAVE:
|
||||
return configCategoryServer.getConfigCategoryMaxPoolSize().getSave();
|
||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getSave();
|
||||
case MISC:
|
||||
return configCategoryServer.getConfigCategoryMaxPoolSize().getMisc();
|
||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getMisc();
|
||||
default:
|
||||
return 20;
|
||||
}
|
@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.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." +
|
||||
" 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";
|
||||
|
||||
@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.")
|
||||
private ConfigCategoryMaxPoolSize configCategoryMaxPoolSize;
|
||||
private UserConfigSectionMaxPoolSize userConfigSectionMaxPoolSize;
|
||||
|
||||
/*
|
||||
* GETTER BOILERPLATE
|
||||
@ -39,12 +39,12 @@ public class ConfigCategoryServer {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
public ConfigCategoryMaxConnections getConfigCategoryMaxConnections() {
|
||||
return configCategoryMaxConnections;
|
||||
public UserConfigSectionMaxConnections getUserConfigSectionMaxConnections() {
|
||||
return userConfigSectionMaxConnections;
|
||||
}
|
||||
|
||||
public ConfigCategoryMaxPoolSize getConfigCategoryMaxPoolSize() {
|
||||
return configCategoryMaxPoolSize;
|
||||
public UserConfigSectionMaxPoolSize getUserConfigSectionMaxPoolSize() {
|
||||
return userConfigSectionMaxPoolSize;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigCategoryUser {
|
||||
public class UserConfigSectionUser {
|
||||
|
||||
@Setting(value = "User_Name", comment = "The authorized user for your MySQL/MariaDB DB")
|
||||
private String username = "example_user_name";
|
@ -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().getConfigCategoryDatabase().getTablePrefix();
|
||||
private String tablePrefix = mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getTablePrefix();
|
||||
|
||||
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();
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getConfigCategoryServer().getServerAddress()
|
||||
+ ":" + mcMMO.getMySQLConfigSettings().getConfigCategoryServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getConfigCategoryDatabase().getDatabaseName();
|
||||
String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerAddress()
|
||||
+ ":" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName();
|
||||
|
||||
if(mcMMO.getMySQLConfigSettings().getConfigCategoryServer().isUseSSL())
|
||||
if(mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().isUseSSL())
|
||||
connectionString +=
|
||||
"?verifyServerCertificate=false"+
|
||||
"&useSSL=true"+
|
||||
@ -85,9 +85,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
poolProperties.setUrl(connectionString);
|
||||
|
||||
//MySQL User Name
|
||||
poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getConfigCategoryUser().getUsername());
|
||||
poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().getUsername());
|
||||
//MySQL User Password
|
||||
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getConfigCategoryUser().getPassword());
|
||||
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().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().getConfigCategoryDatabase().getDatabaseName());
|
||||
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().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().getConfigCategoryDatabase().getDatabaseName());
|
||||
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().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().getConfigCategoryDatabase().getDatabaseName());
|
||||
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().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().getConfigCategoryDatabase().getDatabaseName());
|
||||
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().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().getConfigCategoryDatabase().getDatabaseName());
|
||||
statement.setString(1, mcMMO.getMySQLConfigSettings().getUserConfigSectionDatabase().getDatabaseName());
|
||||
statement.setString(2, tablePrefix + "experience");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
|
@ -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.ConfigCategoryMySQL;
|
||||
import com.gmail.nossr50.config.hocon.database.UserConfigSectionMySQL;
|
||||
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 ConfigCategoryMySQL getMySQLConfigSettings()
|
||||
public static UserConfigSectionMySQL getMySQLConfigSettings()
|
||||
{
|
||||
return configManager.getConfigDatabase().getConfigCategoryMySQL();
|
||||
return configManager.getConfigDatabase().getUserConfigSectionMySQL();
|
||||
}
|
||||
|
||||
/*public static ModManager getModManager() {
|
||||
|
Loading…
Reference in New Issue
Block a user