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:
parent
21d55563b7
commit
d7bac6d08f
@ -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();
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Initialize custom configuration files
|
|
||||||
this.reloadConfig();
|
this.reloadConfig();
|
||||||
if (this.configuration.getString("scrapper.defaults.dropItem") == null) {
|
this.saveConfig();
|
||||||
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();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user