Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Save the new config
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniFoldi committed May 14, 2021
1 parent 0ae69fc commit fec41ac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/danifoldi/bungeegui/util/ConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ConfigUtil {

public static String backupAndUpgrade(FileConfig config) throws IOException {
Path folder = config.getFile().toPath().getParent();
String backup = getNextFileName(folder);
String backup = getBackupFilename(folder);

Files.copy(folder.resolve(config.getFile().getName()), folder.resolve(backup));

Expand All @@ -23,7 +23,7 @@ public static String backupAndUpgrade(FileConfig config) throws IOException {
return backup;
}

private static void upgrade(Config config, int oldVersion, int newVersion) {
private static void upgrade(FileConfig config, int oldVersion, int newVersion) {
if (oldVersion >= newVersion) {
return;
}
Expand All @@ -45,6 +45,7 @@ private static void upgrade(Config config, int oldVersion, int newVersion) {
}

config.set("configVersion", newVersion);
config.save();
}

private static void ensureValue(Config config, String path, Object value) {
Expand All @@ -53,7 +54,7 @@ private static void ensureValue(Config config, String path, Object value) {
}
}

private static String getNextFileName(Path folder) {
private static String getBackupFilename(Path folder) {
if (!Files.exists(folder.resolve("config_backup.yml"))) {
return "config_backup.yml";
}
Expand Down

0 comments on commit fec41ac

Please sign in to comment.