mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
add missing defaults and constructor for database config
This commit is contained in:
parent
e757dd10c8
commit
7d152794ba
@ -50,11 +50,11 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
/* CONFIG MANAGER */
|
/* CONFIG MANAGER */
|
||||||
//private ConfigurationLoader<CommentedCommentedConfigurationNode> configManager;
|
//private ConfigurationLoader<CommentedCommentedConfigurationNode> configManager;
|
||||||
|
|
||||||
public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
|
/*public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
|
||||||
//TODO: Check if this works...
|
//TODO: Check if this works...
|
||||||
this(new File(pathToParentFolder), relativePath, mergeNewKeys, copyDefaults, removeOldKeys);
|
this(new File(pathToParentFolder), relativePath, mergeNewKeys, copyDefaults, removeOldKeys);
|
||||||
System.out.println("mcMMO Debug: Don't forget to check if loading config file by string instead of File works...");
|
System.out.println("mcMMO Debug: Don't forget to check if loading config file by string instead of File works...");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public Config(File pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
|
public Config(File pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
|
||||||
/*
|
/*
|
||||||
|
27
src/main/java/com/gmail/nossr50/config/ConfigConstants.java
Normal file
27
src/main/java/com/gmail/nossr50/config/ConfigConstants.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants relating to config folders and paths
|
||||||
|
*/
|
||||||
|
public class ConfigConstants {
|
||||||
|
/* FOLDER NAMES */
|
||||||
|
public static final String FOLDER_NAME_CONFIG = "config";
|
||||||
|
public static final String FOLDER_NAME_SKILLS = "skills";
|
||||||
|
|
||||||
|
/* RELATIVE PATHS */
|
||||||
|
public final static String RELATIVE_PATH_CONFIG_DIR = File.separator + FOLDER_NAME_CONFIG;
|
||||||
|
public final static String RELATIVE_PATH_SKILLS_DIR = RELATIVE_PATH_CONFIG_DIR + File.separator + FOLDER_NAME_SKILLS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the data folder for mcMMO
|
||||||
|
* @return the File for the data folder used by mcMMO
|
||||||
|
*/
|
||||||
|
public static File getDataFolder()
|
||||||
|
{
|
||||||
|
return mcMMO.p.getDataFolder();
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
|
|||||||
import com.gmail.nossr50.config.collectionconfigs.CollectionClassType;
|
import com.gmail.nossr50.config.collectionconfigs.CollectionClassType;
|
||||||
import com.gmail.nossr50.config.collectionconfigs.MultiConfigContainer;
|
import com.gmail.nossr50.config.collectionconfigs.MultiConfigContainer;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.config.hocon.database.ConfigDatabase;
|
||||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||||
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
|
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
|
||||||
@ -64,6 +65,7 @@ public final class ConfigManager {
|
|||||||
|
|
||||||
/* CONFIG INSTANCES */
|
/* CONFIG INSTANCES */
|
||||||
|
|
||||||
|
private ConfigDatabase configDatabase;
|
||||||
private MainConfig mainConfig;
|
private MainConfig mainConfig;
|
||||||
private FishingTreasureConfig fishingTreasureConfig;
|
private FishingTreasureConfig fishingTreasureConfig;
|
||||||
private ExcavationTreasureConfig excavationTreasureConfig;
|
private ExcavationTreasureConfig excavationTreasureConfig;
|
||||||
@ -92,6 +94,7 @@ public final class ConfigManager {
|
|||||||
// I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly
|
// I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly
|
||||||
|
|
||||||
//TODO: Not sure about the order of MainConfig
|
//TODO: Not sure about the order of MainConfig
|
||||||
|
configDatabase = new ConfigDatabase();
|
||||||
mainConfig = new MainConfig();
|
mainConfig = new MainConfig();
|
||||||
|
|
||||||
fishingTreasureConfig = new FishingTreasureConfig();
|
fishingTreasureConfig = new FishingTreasureConfig();
|
||||||
@ -299,4 +302,6 @@ public final class ConfigManager {
|
|||||||
public ExperienceMapManager getExperienceMapManager() {
|
public ExperienceMapManager getExperienceMapManager() {
|
||||||
return experienceMapManager;
|
return experienceMapManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigDatabase getConfigDatabase() { return configDatabase; }
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,16 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|||||||
public class ConfigCategoryDatabase {
|
public class ConfigCategoryDatabase {
|
||||||
|
|
||||||
@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;
|
private String username = "example_user_name";
|
||||||
|
|
||||||
@Setting(value = "User_Password", comment = "The password for your authorized user")
|
@Setting(value = "User_Password", comment = "The password for your authorized user")
|
||||||
private String password;
|
private String password = "example_user_password";
|
||||||
|
|
||||||
@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;
|
private String databaseName = "example_database_name";
|
||||||
|
|
||||||
@Setting(value = "Table_Prefix", comment = "The Prefix that will be used for tables in your DB")
|
@Setting(value = "Table_Prefix", comment = "The Prefix that will be used for tables in your DB")
|
||||||
private String tablePrefix;
|
private String tablePrefix = "mcmmo_";
|
||||||
|
|
||||||
@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 ConfigCategoryMaxConnections configCategoryMaxConnections;
|
||||||
|
@ -7,12 +7,12 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|||||||
public class ConfigCategoryMaxConnections {
|
public class ConfigCategoryMaxConnections {
|
||||||
|
|
||||||
@Setting(value = "Misc")
|
@Setting(value = "Misc")
|
||||||
private int misc;
|
private int misc = 30;
|
||||||
|
|
||||||
@Setting(value = "Load")
|
@Setting(value = "Load")
|
||||||
private int load;
|
private int load = 30;
|
||||||
|
|
||||||
@Setting(value = "Save")
|
@Setting(value = "Save")
|
||||||
private int save;
|
private int save = 30;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public class ConfigCategoryMaxPoolSize {
|
public class ConfigCategoryMaxPoolSize {
|
||||||
@Setting(value = "Misc")
|
@Setting(value = "Misc")
|
||||||
private int misc;
|
private int misc = 10;
|
||||||
|
|
||||||
@Setting(value = "Load")
|
@Setting(value = "Load")
|
||||||
private int load;
|
private int load = 20;
|
||||||
|
|
||||||
@Setting(value = "Save")
|
@Setting(value = "Save")
|
||||||
private int save;
|
private int save = 20;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
|||||||
public class ConfigCategoryMySQL {
|
public class ConfigCategoryMySQL {
|
||||||
|
|
||||||
@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;
|
private boolean enabled = true;
|
||||||
|
|
||||||
@Setting(value = "Database", comment = "Database settings for MySQL/MariaDB")
|
@Setting(value = "Database", comment = "Database settings for MySQL/MariaDB")
|
||||||
private ConfigCategoryDatabase configCategoryDatabase;
|
private ConfigCategoryDatabase configCategoryDatabase;
|
||||||
|
@ -1,12 +1,32 @@
|
|||||||
package com.gmail.nossr50.config.hocon.database;
|
package com.gmail.nossr50.config.hocon.database;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.ConfigConstants;
|
||||||
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 ConfigDatabase {
|
public class ConfigDatabase extends Config {
|
||||||
|
|
||||||
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
|
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
|
||||||
private ConfigCategoryMySQL configCategoryMySQL;
|
private ConfigCategoryMySQL configCategoryMySQL;
|
||||||
|
|
||||||
|
public ConfigDatabase() {
|
||||||
|
super(ConfigConstants.getDataFolder(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unload() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version of this config
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double getConfigVersion() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user