mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Move config loading outside of constructors
This commit is contained in:
		@@ -76,7 +76,10 @@ public abstract class Config implements VersionedConfig, Unload {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        DIRECTORY_DATA_FOLDER = pathToParentFolder; //Data Folder for our plugin
 | 
					        DIRECTORY_DATA_FOLDER = pathToParentFolder; //Data Folder for our plugin
 | 
				
			||||||
        FILE_RELATIVE_PATH = relativePath + fileName + HOCON_FILE_EXTENSION; //Relative path to config from a parent folder
 | 
					        FILE_RELATIVE_PATH = relativePath + fileName + HOCON_FILE_EXTENSION; //Relative path to config from a parent folder
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void initFullConfig()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        //Attempt IO Operations
 | 
					        //Attempt IO Operations
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            //Makes sure we have valid Files corresponding to this config
 | 
					            //Makes sure we have valid Files corresponding to this config
 | 
				
			||||||
@@ -181,17 +184,20 @@ public abstract class Config implements VersionedConfig, Unload {
 | 
				
			|||||||
        Path potentialFile = Paths.get(getDefaultConfigCopyRelativePath());
 | 
					        Path potentialFile = Paths.get(getDefaultConfigCopyRelativePath());
 | 
				
			||||||
        ConfigurationLoader<CommentedConfigurationNode> generation_loader
 | 
					        ConfigurationLoader<CommentedConfigurationNode> generation_loader
 | 
				
			||||||
                = HoconConfigurationLoader.builder().setPath(potentialFile).build();
 | 
					                = HoconConfigurationLoader.builder().setPath(potentialFile).build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            mcMMO.p.getLogger().info("Config File Full Path: "+getDefaultConfigFile().getAbsolutePath());
 | 
					            mcMMO.p.getLogger().info("Config File Full Path: "+getDefaultConfigFile().getAbsolutePath());
 | 
				
			||||||
            //Delete any existing default config
 | 
					            //Delete any existing default config
 | 
				
			||||||
            if(getDefaultConfigFile().exists())
 | 
					            if(getDefaultConfigFile().exists())
 | 
				
			||||||
                getDefaultConfigFile().delete();
 | 
					                getDefaultConfigFile().delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //Make new file
 | 
				
			||||||
 | 
					            getDefaultConfigFile().createNewFile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //Load the config
 | 
					            //Load the config
 | 
				
			||||||
            defaultRootNode = generation_loader.load();
 | 
					            defaultRootNode = generation_loader.load();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //Save to a new file
 | 
					            //Save to a new file
 | 
				
			||||||
            getDefaultConfigFile().createNewFile();
 | 
					 | 
				
			||||||
            generation_loader.save(defaultRootNode);
 | 
					            generation_loader.save(defaultRootNode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            mcMMO.p.getLogger().info("Generated a default file for "+fileName);
 | 
					            mcMMO.p.getLogger().info("Generated a default file for "+fileName);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,8 @@ public class ConfigDatabase extends Config {
 | 
				
			|||||||
    public ConfigDatabase() {
 | 
					    public ConfigDatabase() {
 | 
				
			||||||
        super("mysql", ConfigConstants.getDataFolder(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR,
 | 
					        super("mysql", ConfigConstants.getDataFolder(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR,
 | 
				
			||||||
                true,true, false, true);
 | 
					                true,true, false, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        initFullConfig(); //Load Config
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user