Fix some errors in config loading.

Technically removing a nonexistant property should be fixed in WE's yaml utils but eh.
This commit is contained in:
wizjany 2022-02-27 17:51:52 -05:00
parent f883899cfe
commit f9d1c2d4e0
No known key found for this signature in database
GPG Key ID: 1DB5861C03B76B5E
2 changed files with 20 additions and 4 deletions

View File

@ -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) {

View File

@ -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;