Removes some redundancy
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
This commit is contained in:
@@ -63,10 +63,12 @@ public final class ConfigHelper {
|
||||
*/
|
||||
public static boolean migrateConfig(@NotNull Plugin plugin) {
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File config = new File(dataFolder, CONFIG_FILE);
|
||||
|
||||
//Save the old config just in case something goes wrong
|
||||
try {
|
||||
StargateYamlConfiguration currentConfiguration = new StargateYamlConfiguration();
|
||||
currentConfiguration.load(new File(dataFolder, CONFIG_FILE));
|
||||
currentConfiguration.load(config);
|
||||
currentConfiguration.save(new File(dataFolder, BACKUP_CONFIG_FILE));
|
||||
} catch (IOException | InvalidConfigurationException exception) {
|
||||
plugin.getLogger().log(Level.WARNING, "Unable to save old backup and do migration");
|
||||
@@ -78,7 +80,7 @@ public final class ConfigHelper {
|
||||
FileConfiguration oldConfiguration;
|
||||
try {
|
||||
oldConfiguration = new YamlConfiguration();
|
||||
oldConfiguration.load(new File(dataFolder, CONFIG_FILE));
|
||||
oldConfiguration.load(config);
|
||||
} catch (IOException | InvalidConfigurationException exception) {
|
||||
plugin.getLogger().log(Level.WARNING, "Unable to load old configuration and do migration");
|
||||
return false;
|
||||
@@ -125,7 +127,7 @@ public final class ConfigHelper {
|
||||
}
|
||||
|
||||
try {
|
||||
newConfiguration.save(new File(dataFolder, CONFIG_FILE));
|
||||
newConfiguration.save(config);
|
||||
} catch (IOException exception) {
|
||||
plugin.getLogger().log(Level.WARNING, "Unable to save migrated config");
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user