Fixes missing config values not loading properly until a reload
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
				
			This commit is contained in:
		| @@ -148,24 +148,19 @@ public class BlacksmithPlugin extends JavaPlugin { | ||||
|     public void onEnable() { | ||||
|         instance = this; | ||||
|  | ||||
|         //Copy default config to disk | ||||
|         //Copy default config to disk, and add missing configuration values | ||||
|         this.saveDefaultConfig(); | ||||
|         this.getConfig(); | ||||
|         this.configuration = new StargateYamlConfiguration(); | ||||
|         try { | ||||
|             this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME)); | ||||
|         } catch (IOException | InvalidConfigurationException exception) { | ||||
|             getLogger().log(Level.SEVERE, exception.getMessage()); | ||||
|         } | ||||
|         this.configuration.options().copyDefaults(true); | ||||
|         this.getConfig().options().copyDefaults(true); | ||||
|         this.reloadConfig(); | ||||
|         this.saveConfig(); | ||||
|  | ||||
|         // Initialize custom configuration files | ||||
|         this.reloadConfig(); | ||||
|         if (this.configuration.getString("scrapper.defaults.dropItem") == null) { | ||||
|             ConfigHelper.migrateConfig(this.getDataFolder().getPath().replaceAll("\\\\", "/"), this.configuration); | ||||
|         //Migrate from an earlier configuration file syntax if necessary  | ||||
|         if (getConfiguration().getString("scrapper.defaults.dropItem") == null) { | ||||
|             ConfigHelper.migrateConfig(this.getDataFolder().getPath().replaceAll("\\\\", "/"), | ||||
|                     getConfiguration()); | ||||
|             this.reloadConfig(); | ||||
|         } | ||||
|         initializeConfigurations(this.configuration); | ||||
|         initializeConfigurations(getConfiguration()); | ||||
|  | ||||
|         //Set up Vault integration | ||||
|         if (!setUpVault()) { | ||||
| @@ -237,6 +232,9 @@ public class BlacksmithPlugin extends JavaPlugin { | ||||
|             prefix = description.getPrefix(); | ||||
|         } | ||||
|         BlacksmithPlugin.stringFormatter = new StringFormatter(prefix, translator); | ||||
|  | ||||
|         // This reload is necessary to get values just added to the configuration for some reason | ||||
|         this.reload(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user