add missing defaults and constructor for database config

This commit is contained in:
nossr50 2019-03-08 17:54:23 -08:00
parent e757dd10c8
commit 7d152794ba
8 changed files with 66 additions and 14 deletions

View File

@ -50,11 +50,11 @@ public abstract class Config implements VersionedConfig, Unload {
/* CONFIG MANAGER */
//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...
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...");
}
}*/
public Config(File pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
/*

View 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();
}
}

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.config.collectionconfigs.CollectionClassType;
import com.gmail.nossr50.config.collectionconfigs.MultiConfigContainer;
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.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
@ -64,6 +65,7 @@ public final class ConfigManager {
/* CONFIG INSTANCES */
private ConfigDatabase configDatabase;
private MainConfig mainConfig;
private FishingTreasureConfig fishingTreasureConfig;
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
//TODO: Not sure about the order of MainConfig
configDatabase = new ConfigDatabase();
mainConfig = new MainConfig();
fishingTreasureConfig = new FishingTreasureConfig();
@ -299,4 +302,6 @@ public final class ConfigManager {
public ExperienceMapManager getExperienceMapManager() {
return experienceMapManager;
}
public ConfigDatabase getConfigDatabase() { return configDatabase; }
}

View File

@ -7,16 +7,16 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
public class ConfigCategoryDatabase {
@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")
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.")
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")
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")
private ConfigCategoryMaxConnections configCategoryMaxConnections;

View File

@ -7,12 +7,12 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
public class ConfigCategoryMaxConnections {
@Setting(value = "Misc")
private int misc;
private int misc = 30;
@Setting(value = "Load")
private int load;
private int load = 30;
@Setting(value = "Save")
private int save;
private int save = 30;
}

View File

@ -6,11 +6,11 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigCategoryMaxPoolSize {
@Setting(value = "Misc")
private int misc;
private int misc = 10;
@Setting(value = "Load")
private int load;
private int load = 20;
@Setting(value = "Save")
private int save;
private int save = 20;
}

View File

@ -7,7 +7,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
public class ConfigCategoryMySQL {
@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")
private ConfigCategoryDatabase configCategoryDatabase;

View File

@ -1,12 +1,32 @@
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.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigDatabase {
public class ConfigDatabase extends Config {
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database")
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;
}
}