Adds an option for disabling startup fixes
Also fixes configuration default values not being used when the option is missing from the configuration file.
This commit is contained in:
@@ -66,6 +66,11 @@ public enum ConfigOption {
|
||||
*/
|
||||
DESTROYED_BY_EXPLOSION("gates.integrity.destroyedByExplosion", "Whether stargates should be destroyed by explosions", false),
|
||||
|
||||
/**
|
||||
* Whether to fix incorrect signs, buttons or openings during startup
|
||||
*/
|
||||
APPLY_STARTUP_FIXES("gates.integrity.applyStartupFixes", "Whether Stargates should fix incorrect signs, buttons or openings during startup", true),
|
||||
|
||||
/**
|
||||
* Whether to verify each portal's gate layout after each load
|
||||
*/
|
||||
|
@@ -418,13 +418,10 @@ public final class StargateConfig {
|
||||
//Load the option using its correct data type
|
||||
switch (option.getDataType()) {
|
||||
case STRING_LIST -> optionValue = newConfig.getStringList(configNode);
|
||||
case STRING -> {
|
||||
String value = newConfig.getString(configNode);
|
||||
optionValue = value != null ? value.trim() : "";
|
||||
}
|
||||
case BOOLEAN -> optionValue = newConfig.getBoolean(configNode);
|
||||
case INTEGER -> optionValue = newConfig.getInt(configNode);
|
||||
case DOUBLE -> optionValue = newConfig.getDouble(configNode);
|
||||
case STRING -> optionValue = newConfig.getString(configNode, (String) option.getDefaultValue()).trim();
|
||||
case BOOLEAN -> optionValue = newConfig.getBoolean(configNode, (boolean) option.getDefaultValue());
|
||||
case INTEGER -> optionValue = newConfig.getInt(configNode, (int) option.getDefaultValue());
|
||||
case DOUBLE -> optionValue = newConfig.getDouble(configNode, (double) option.getDefaultValue());
|
||||
default -> throw new IllegalArgumentException("Invalid config data type encountered");
|
||||
}
|
||||
configOptions.put(option, optionValue);
|
||||
|
@@ -195,6 +195,15 @@ public final class StargateGateConfig {
|
||||
return (boolean) configOptions.get(ConfigOption.DESTROYED_BY_EXPLOSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to destroy portals when any blocks are broken by explosions
|
||||
*
|
||||
* @return <p>Whether to destroy portals when any blocks are broken by explosions</p>
|
||||
*/
|
||||
public boolean applyStartupFixes() {
|
||||
return (boolean) configOptions.get(ConfigOption.APPLY_STARTUP_FIXES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default portal network to use if no other network is given
|
||||
*
|
||||
|
Reference in New Issue
Block a user