mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 21:15:28 +02:00
Code cleanup and new settings for Database config
This commit is contained in:
@@ -14,6 +14,10 @@ public class ConfigDatabase {
|
||||
comment = "Settings to automatically purge old users to keep database sizes small.")
|
||||
private ConfigSectionCleaning configSectionCleaning = new ConfigSectionCleaning();
|
||||
|
||||
@Setting(value = "FlatFile", comment = "FlatFile is a plain text database used by mcMMO." +
|
||||
"\nIt is recommended that you use MySQL/MariaDB instead because FlatFile is notoriously slow.")
|
||||
private ConfigDatabaseFlatFile configDatabaseFlatFile = new ConfigDatabaseFlatFile();
|
||||
|
||||
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database" +
|
||||
"\nI recommend using MariaDB, its completely compatible with MySQL and runs a lot better" +
|
||||
"\nI also recommend having the MySQL/MariaDB server in the same datacenter or LAN as your Minecraft server" +
|
||||
@@ -21,10 +25,21 @@ public class ConfigDatabase {
|
||||
" but ideally you want low latency to your SQL server anyways!")
|
||||
private ConfigSectionMySQL configSectionMySQL = new ConfigSectionMySQL();
|
||||
|
||||
@Setting(value = "General", comment = "Settings that apply to both databases, both MySQL/MariaDB and FlatFile.")
|
||||
private ConfigSectionDatabaseGeneral configSectionDatabaseGeneral = new ConfigSectionDatabaseGeneral();
|
||||
|
||||
/*
|
||||
* GETTER BOILERPLATE
|
||||
*/
|
||||
|
||||
public ConfigDatabaseFlatFile getConfigDatabaseFlatFile() {
|
||||
return configDatabaseFlatFile;
|
||||
}
|
||||
|
||||
public ConfigSectionDatabaseGeneral getConfigSectionDatabaseGeneral() {
|
||||
return configSectionDatabaseGeneral;
|
||||
}
|
||||
|
||||
public ConfigSectionMySQL getConfigSectionMySQL() {
|
||||
return configSectionMySQL;
|
||||
}
|
||||
|
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.config.hocon.database;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigDatabaseFlatFile {
|
||||
|
||||
public static final int LEADERBOARD_SCOREBOARD_UPDATE_INTERVAL_MINUTES_DEFAULT = 10;
|
||||
|
||||
@Setting(value = "Scoreboard-Leaderboard-Update-Interval", comment = "How often the scoreboard leaderboards will update." +
|
||||
"\nThis is an expensive operation, it is highly recommended to avoid doing this often." +
|
||||
"\nDefault value: "+LEADERBOARD_SCOREBOARD_UPDATE_INTERVAL_MINUTES_DEFAULT)
|
||||
private int leaderboardUpdateIntervalMinutes = LEADERBOARD_SCOREBOARD_UPDATE_INTERVAL_MINUTES_DEFAULT;
|
||||
|
||||
public int getLeaderboardUpdateIntervalMinutes() {
|
||||
return leaderboardUpdateIntervalMinutes;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.gmail.nossr50.config.hocon.database;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigSectionDatabaseGeneral {
|
||||
|
||||
public static final int SAVE_INTERVAL_MINUTES_DEFAULT = 10;
|
||||
|
||||
@Setting(value = "Save-Interval-Minutes", comment = "How often the database will save." +
|
||||
"\nSaving the database is an expensive operation although it is done in an ASYNC thread." +
|
||||
"\nI wouldn't recommend setting this value lower than 10 minutes" +
|
||||
"\nKeep in mind if you properly shut down your server with a stop command mcMMO saves before your server shuts down." +
|
||||
"\nDefault value: "+SAVE_INTERVAL_MINUTES_DEFAULT)
|
||||
private int saveIntervalMinutes = SAVE_INTERVAL_MINUTES_DEFAULT;
|
||||
|
||||
public int getSaveIntervalMinutes() {
|
||||
return saveIntervalMinutes;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.config.hocon.database;
|
||||
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.database.PoolIdentifier;
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ConfigSectionMySQL {
|
||||
* HELPER METHODS
|
||||
*/
|
||||
|
||||
public int getMaxPoolSize(SQLDatabaseManager.PoolIdentifier poolIdentifier)
|
||||
public int getMaxPoolSize(PoolIdentifier poolIdentifier)
|
||||
{
|
||||
switch (poolIdentifier)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public class ConfigSectionMySQL {
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxConnections(SQLDatabaseManager.PoolIdentifier poolIdentifier)
|
||||
public int getMaxConnections(PoolIdentifier poolIdentifier)
|
||||
{
|
||||
switch (poolIdentifier)
|
||||
{
|
||||
|
Reference in New Issue
Block a user