Skip to content

Commit

Permalink
Fixed upgrading to a newer version falsely converting the config
Browse files Browse the repository at this point in the history
  • Loading branch information
A5H73Y committed Jan 16, 2018
1 parent 71aa1da commit 1e4de28
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/main/java/me/A5H73Y/Parkour/Other/StartPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class StartPlugin {

private static boolean freshInstall = false;
private static boolean updateExisting = false;
private static boolean fromBeforeVersion4 = false;

public static void run() {
checkConvertToLatest();
Expand Down Expand Up @@ -217,14 +216,18 @@ private static void checkConvertToLatest() {
if (configVersion >= currentVersion)
return;

if (configVersion >= 4.0)
fromBeforeVersion4 = true;
boolean fromBeforeVersion4 = configVersion < 4.0;

updateExisting = true;
Utils.log("[Backup] Updating config to " + currentVersion + "...");
// We backup all their files first before touching them
Backup.backupNow(false);
convertToLatest();

if (fromBeforeVersion4) {
Utils.log("[Backup] Your config is very outdated. Beginning conversion process...");
convertToLatest();
} else {
Utils.log("[Backup] Updating config to " + currentVersion + "...");
}
Parkour.getPlugin().getConfig().set("Version", currentVersion);
Parkour.getPlugin().saveConfig();
}
Expand All @@ -250,13 +253,11 @@ private static void convertToLatest() {
String[] lobbyData = getLobbyData("Lobby");
List<String> linkedLobbyData = getLinkedLobbyData();

if (fromBeforeVersion4) {
// Reset current config
for (String key : Parkour.getPlugin().getConfig().getKeys(false)) {
Parkour.getPlugin().getConfig().set(key, null);
}
Utils.broadcastMessage("[Backup] Your existing config has been backed up. We have generated a new config, please reapply the settings you want.", "Parkour.Admin");
// Reset current config
for (String key : Parkour.getPlugin().getConfig().getKeys(false)) {
Parkour.getPlugin().getConfig().set(key, null);
}
Utils.broadcastMessage("[Backup] Your existing config has been backed up. We have generated a new config, please reapply the settings you want.", "Parkour.Admin");

Parkour.getPlugin().saveConfig();
Parkour.getParkourConfig().reload();
Expand Down

0 comments on commit 1e4de28

Please sign in to comment.