From f01efd92f50648fc472c8ceabe4f61c18c2b0b4e Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 31 Mar 2021 15:06:59 -0700 Subject: [PATCH] Correct bad default config files --- Changelog.txt | 6 ++++++ .../gmail/nossr50/config/treasure/TreasureConfig.java | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 4e2babd43..d6d819885 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,9 @@ +Version 2.1.184 + Fixed a bug where the default treasures.yml file had incorrect keys (see notes) + + NOTES: + mcMMO will fix bad config files automatically, you don't need to do anything + Version 2.1.183 Players now gain Acrobatics XP from falling even if they don't have the Roll permission node (checks for Acrobatics skill permission) treasures.yml now has separate settings for Drop_Level for Standard/Retro mode (see notes / this change is automatic) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index a4f13e402..1dd4a7217 100755 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -25,6 +25,7 @@ public class TreasureConfig extends ConfigLoader { public static final String FILENAME = "treasures.yml"; public static final String LEVEL_REQUIREMENT_RETRO_MODE = ".Level_Requirement.Retro_Mode"; public static final String LEVEL_REQUIREMENT_STANDARD_MODE = ".Level_Requirement.Standard_Mode"; + public static final String LEVEL_REQUIREMENT_INVALID = ".Level_Requirement.Standard"; public static final String LEGACY_DROP_LEVEL = ".Drop_Level"; private static TreasureConfig instance; @@ -112,6 +113,16 @@ public class TreasureConfig extends ConfigLoader { int legacyDropLevel = config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1); int dropLevel = -1; + int badDefaults = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_INVALID, -1); + + //Hacky fix for bad keys in treasures.yml defaults + if(badDefaults != -1) { + config.set(type + "." + treasureName + LEVEL_REQUIREMENT_INVALID, null); + config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, badDefaults); + updatedFile = true; + } + + if(legacyDropLevel >= 0) { //Config needs to be updated to be more specific mcMMO.p.getLogger().info("(" + treasureName + ") Updating Drop_Level in treasures.yml for treasure to match new expected format");