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) {
|
public static boolean migrateConfig(@NotNull Plugin plugin) {
|
||||||
File dataFolder = plugin.getDataFolder();
|
File dataFolder = plugin.getDataFolder();
|
||||||
|
File config = new File(dataFolder, CONFIG_FILE);
|
||||||
|
|
||||||
//Save the old config just in case something goes wrong
|
//Save the old config just in case something goes wrong
|
||||||
try {
|
try {
|
||||||
StargateYamlConfiguration currentConfiguration = new StargateYamlConfiguration();
|
StargateYamlConfiguration currentConfiguration = new StargateYamlConfiguration();
|
||||||
currentConfiguration.load(new File(dataFolder, CONFIG_FILE));
|
currentConfiguration.load(config);
|
||||||
currentConfiguration.save(new File(dataFolder, BACKUP_CONFIG_FILE));
|
currentConfiguration.save(new File(dataFolder, BACKUP_CONFIG_FILE));
|
||||||
} catch (IOException | InvalidConfigurationException exception) {
|
} catch (IOException | InvalidConfigurationException exception) {
|
||||||
plugin.getLogger().log(Level.WARNING, "Unable to save old backup and do migration");
|
plugin.getLogger().log(Level.WARNING, "Unable to save old backup and do migration");
|
||||||
@@ -78,7 +80,7 @@ public final class ConfigHelper {
|
|||||||
FileConfiguration oldConfiguration;
|
FileConfiguration oldConfiguration;
|
||||||
try {
|
try {
|
||||||
oldConfiguration = new YamlConfiguration();
|
oldConfiguration = new YamlConfiguration();
|
||||||
oldConfiguration.load(new File(dataFolder, CONFIG_FILE));
|
oldConfiguration.load(config);
|
||||||
} catch (IOException | InvalidConfigurationException exception) {
|
} catch (IOException | InvalidConfigurationException exception) {
|
||||||
plugin.getLogger().log(Level.WARNING, "Unable to load old configuration and do migration");
|
plugin.getLogger().log(Level.WARNING, "Unable to load old configuration and do migration");
|
||||||
return false;
|
return false;
|
||||||
@@ -125,7 +127,7 @@ public final class ConfigHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newConfiguration.save(new File(dataFolder, CONFIG_FILE));
|
newConfiguration.save(config);
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
plugin.getLogger().log(Level.WARNING, "Unable to save migrated config");
|
plugin.getLogger().log(Level.WARNING, "Unable to save migrated config");
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user