mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Refactoring SQL config class names again
This commit is contained in:
parent
a8bf6357aa
commit
1c289cfcdf
@ -11,13 +11,16 @@ public class ConfigDatabase {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
|
@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
|
* GETTER BOILERPLATE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public UserConfigSectionMySQL getUserConfigSectionMySQL() {
|
public ConfigSectionMySQL getConfigSectionMySQL() {
|
||||||
return userConfigSectionMySQL;
|
return configSectionMySQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 UserConfigSectionDatabase {
|
public class ConfigSectionDatabase {
|
||||||
|
|
||||||
@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";
|
@ -4,15 +4,15 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
|||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class UserConfigSectionMaxConnections {
|
public class ConfigSectionMaxConnections {
|
||||||
|
|
||||||
@Setting(value = "Misc")
|
@Setting(value = "Misc_Connection_Limit")
|
||||||
private int misc = 30;
|
private int misc = 30;
|
||||||
|
|
||||||
@Setting(value = "Load")
|
@Setting(value = "Load_Connection_Limit")
|
||||||
private int load = 30;
|
private int load = 30;
|
||||||
|
|
||||||
@Setting(value = "Save")
|
@Setting(value = "Save_Connection_Limit")
|
||||||
private int save = 30;
|
private int save = 30;
|
||||||
|
|
||||||
/*
|
/*
|
@ -4,14 +4,14 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
|||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class UserConfigSectionMaxPoolSize {
|
public class ConfigSectionMaxPoolSize {
|
||||||
@Setting(value = "Misc")
|
@Setting(value = "Misc_Pool")
|
||||||
private int misc = 10;
|
private int misc = 10;
|
||||||
|
|
||||||
@Setting(value = "Load")
|
@Setting(value = "Load_Pool")
|
||||||
private int load = 20;
|
private int load = 20;
|
||||||
|
|
||||||
@Setting(value = "Save")
|
@Setting(value = "Save_Pool")
|
||||||
private int save = 20;
|
private int save = 20;
|
||||||
|
|
||||||
/*
|
/*
|
@ -5,16 +5,16 @@ import ninja.leaping.configurate.objectmapping.Setting;
|
|||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
@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")
|
@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 UserConfigSectionUser userConfigSectionUser = new UserConfigSectionUser();
|
private ConfigSectionUser configSectionUser = new ConfigSectionUser();
|
||||||
|
|
||||||
@Setting(value = "Database", comment = "Database settings for MySQL/MariaDB")
|
@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.")
|
@Setting(value = "Server", comment = "Your MySQL/MariaDB server settings.")
|
||||||
private UserConfigSectionServer userConfigSectionServer = new UserConfigSectionServer();
|
private UserConfigSectionServer userConfigSectionServer = new UserConfigSectionServer();
|
||||||
@ -27,12 +27,12 @@ public class UserConfigSectionMySQL {
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserConfigSectionUser getUserConfigSectionUser() {
|
public ConfigSectionUser getConfigSectionUser() {
|
||||||
return userConfigSectionUser;
|
return configSectionUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserConfigSectionDatabase getUserConfigSectionDatabase() {
|
public ConfigSectionDatabase getConfigSectionDatabase() {
|
||||||
return userConfigSectionDatabase;
|
return configSectionDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserConfigSectionServer getUserConfigSectionServer() {
|
public UserConfigSectionServer getUserConfigSectionServer() {
|
||||||
@ -44,11 +44,11 @@ public class UserConfigSectionMySQL {
|
|||||||
switch (poolIdentifier)
|
switch (poolIdentifier)
|
||||||
{
|
{
|
||||||
case LOAD:
|
case LOAD:
|
||||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getLoad();
|
return userConfigSectionServer.getConfigSectionMaxPoolSize().getLoad();
|
||||||
case SAVE:
|
case SAVE:
|
||||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getSave();
|
return userConfigSectionServer.getConfigSectionMaxPoolSize().getSave();
|
||||||
case MISC:
|
case MISC:
|
||||||
return userConfigSectionServer.getUserConfigSectionMaxPoolSize().getMisc();
|
return userConfigSectionServer.getConfigSectionMaxPoolSize().getMisc();
|
||||||
default:
|
default:
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
@ -59,11 +59,11 @@ public class UserConfigSectionMySQL {
|
|||||||
switch (poolIdentifier)
|
switch (poolIdentifier)
|
||||||
{
|
{
|
||||||
case LOAD:
|
case LOAD:
|
||||||
return userConfigSectionServer.getUserConfigSectionMaxConnections().getLoad();
|
return userConfigSectionServer.getConfigSectionMaxConnections().getLoad();
|
||||||
case SAVE:
|
case SAVE:
|
||||||
return userConfigSectionServer.getUserConfigSectionMaxConnections().getSave();
|
return userConfigSectionServer.getConfigSectionMaxConnections().getSave();
|
||||||
case MISC:
|
case MISC:
|
||||||
return userConfigSectionServer.getUserConfigSectionMaxConnections().getMisc();
|
return userConfigSectionServer.getConfigSectionMaxConnections().getMisc();
|
||||||
default:
|
default:
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
@ -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 UserConfigSectionUser {
|
public class ConfigSectionUser {
|
||||||
|
|
||||||
@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";
|
@ -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." +
|
@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")
|
"\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.")
|
@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
|
* GETTER BOILERPLATE
|
||||||
@ -42,12 +42,12 @@ public class UserConfigSectionServer {
|
|||||||
return serverAddress;
|
return serverAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserConfigSectionMaxConnections getUserConfigSectionMaxConnections() {
|
public ConfigSectionMaxConnections getConfigSectionMaxConnections() {
|
||||||
return userConfigSectionMaxConnections;
|
return configSectionMaxConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserConfigSectionMaxPoolSize getUserConfigSectionMaxPoolSize() {
|
public ConfigSectionMaxPoolSize getConfigSectionMaxPoolSize() {
|
||||||
return userConfigSectionMaxPoolSize;
|
return configSectionMaxPoolSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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().getUserConfigSectionDatabase().getTablePrefix();
|
private String tablePrefix = mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix();
|
||||||
|
|
||||||
private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>();
|
private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>();
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
protected SQLDatabaseManager() {
|
protected SQLDatabaseManager() {
|
||||||
String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerAddress()
|
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())
|
if(mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().isUseSSL())
|
||||||
connectionString +=
|
connectionString +=
|
||||||
@ -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().getUserConfigSectionUser().getUsername());
|
poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getConfigSectionUser().getUsername());
|
||||||
//MySQL User Password
|
//MySQL User Password
|
||||||
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getUserConfigSectionUser().getPassword());
|
poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getConfigSectionUser().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().getUserConfigSectionDatabase().getDatabaseName());
|
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().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().getUserConfigSectionDatabase().getDatabaseName());
|
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().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().getUserConfigSectionDatabase().getDatabaseName());
|
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().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().getUserConfigSectionDatabase().getDatabaseName());
|
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().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().getUserConfigSectionDatabase().getDatabaseName());
|
statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName());
|
||||||
statement.setString(2, tablePrefix + "experience");
|
statement.setString(2, tablePrefix + "experience");
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
if (!resultSet.next()) {
|
if (!resultSet.next()) {
|
||||||
|
@ -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.UserConfigSectionMySQL;
|
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;
|
||||||
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 UserConfigSectionMySQL getMySQLConfigSettings()
|
public static ConfigSectionMySQL getMySQLConfigSettings()
|
||||||
{
|
{
|
||||||
return configManager.getConfigDatabase().getUserConfigSectionMySQL();
|
return configManager.getConfigDatabase().getConfigSectionMySQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static ModManager getModManager() {
|
/*public static ModManager getModManager() {
|
||||||
|
Loading…
Reference in New Issue
Block a user