From f9d1c2d4e0fbb95cb3a14617da84e54a6edc14b0 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sun, 27 Feb 2022 17:51:52 -0500 Subject: [PATCH] Fix some errors in config loading. Technically removing a nonexistant property should be fixed in WE's yaml utils but eh. --- .../bukkit/BukkitWorldConfiguration.java | 23 ++++++++++++++++--- .../worldguard/config/WorldConfiguration.java | 1 - 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java index 539721ef..d3816095 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/BukkitWorldConfiguration.java @@ -140,6 +140,8 @@ public void loadConfiguration() { throw e; } + boolean needParentSave = false; + summaryOnStart = getBoolean("summary-on-start", true); opPermissions = getBoolean("op-permissions", true); @@ -158,7 +160,8 @@ public void loadConfiguration() { itemDurability = getBoolean("protection.item-durability", true); removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false); disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false); - disableObsidianGenerators = getBoolean("protection.disable-obsidian-generators", false); + + needParentSave |= removeProperty("protection.disable-obsidian-generators"); useMaxPriorityAssociation = getBoolean("protection.use-max-priority-association", false); @@ -181,7 +184,7 @@ public void loadConfiguration() { if (simulateSponge) { log.warning("Sponge simulation is deprecated for removal in a future version. We recommend using CraftBook's sponge simulation instead."); } else { - config.removeProperty("simulation.sponge"); + needParentSave |= removeProperty("simulation"); } pumpkinScuba = getBoolean("default.pumpkin-scuba", false); @@ -245,7 +248,7 @@ public void loadConfiguration() { if (signChestProtection) { log.warning("Sign-based chest protection is deprecated for removal in a future version. See https://worldguard.enginehub.org/en/latest/chest-protection/ for details."); } else { - config.removeProperty("chest-protection"); + needParentSave |= removeProperty("chest-protection"); } disableCreatureCropTrampling = getBoolean("crops.disable-creature-trampling", false); @@ -413,6 +416,20 @@ public void loadConfiguration() { config.setHeader(CONFIG_HEADER); config.save(); + if (needParentSave) { + parentConfig.save(); + } + } + + private boolean removeProperty(String prop) { + if (config.getProperty(prop) != null) { + config.removeProperty(prop); + } + if (parentConfig.getProperty(prop) != null) { + parentConfig.removeProperty(prop); + return true; + } + return false; } public boolean isChestProtected(Location block, LocalPlayer player) { diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java b/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java index a2f85eed..e3e0f125 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/config/WorldConfiguration.java @@ -172,7 +172,6 @@ public abstract class WorldConfiguration { public boolean fakePlayerBuildOverride; public boolean explosionFlagCancellation; public boolean disableDeathMessages; - public boolean disableObsidianGenerators; public boolean strictEntitySpawn; public boolean ignoreHopperMoveEvents; public boolean breakDeniedHoppers;