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() { |     public void onEnable() { | ||||||
|         instance = this; |         instance = this; | ||||||
|  |  | ||||||
|         //Copy default config to disk |         //Copy default config to disk, and add missing configuration values | ||||||
|         this.saveDefaultConfig(); |         this.saveDefaultConfig(); | ||||||
|         this.getConfig(); |         this.getConfig().options().copyDefaults(true); | ||||||
|         this.configuration = new StargateYamlConfiguration(); |         this.reloadConfig(); | ||||||
|         try { |         this.saveConfig(); | ||||||
|             this.configuration.load(new File(getDataFolder(), CONFIG_FILE_NAME)); |  | ||||||
|         } catch (IOException | InvalidConfigurationException exception) { |  | ||||||
|             getLogger().log(Level.SEVERE, exception.getMessage()); |  | ||||||
|         } |  | ||||||
|         this.configuration.options().copyDefaults(true); |  | ||||||
|  |  | ||||||
|         // Initialize custom configuration files |         //Migrate from an earlier configuration file syntax if necessary  | ||||||
|         this.reloadConfig(); |         if (getConfiguration().getString("scrapper.defaults.dropItem") == null) { | ||||||
|         if (this.configuration.getString("scrapper.defaults.dropItem") == null) { |             ConfigHelper.migrateConfig(this.getDataFolder().getPath().replaceAll("\\\\", "/"), | ||||||
|             ConfigHelper.migrateConfig(this.getDataFolder().getPath().replaceAll("\\\\", "/"), this.configuration); |                     getConfiguration()); | ||||||
|             this.reloadConfig(); |             this.reloadConfig(); | ||||||
|         } |         } | ||||||
|         initializeConfigurations(this.configuration); |         initializeConfigurations(getConfiguration()); | ||||||
|  |  | ||||||
|         //Set up Vault integration |         //Set up Vault integration | ||||||
|         if (!setUpVault()) { |         if (!setUpVault()) { | ||||||
| @@ -237,6 +232,9 @@ public class BlacksmithPlugin extends JavaPlugin { | |||||||
|             prefix = description.getPrefix(); |             prefix = description.getPrefix(); | ||||||
|         } |         } | ||||||
|         BlacksmithPlugin.stringFormatter = new StringFormatter(prefix, translator); |         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