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
|
||||
*
|
||||
|
@@ -236,6 +236,8 @@ public final class PortalFileHelper {
|
||||
Stargate.logInfo(String.format("{%s} Loaded %d stargates with %d set as always-on", world.getName(),
|
||||
portalCount, openCount));
|
||||
|
||||
|
||||
if (Stargate.getGateConfig().applyStartupFixes()) {
|
||||
//Re-draw the signs in case a bug in the config prevented the portal from loading and has been fixed since
|
||||
Stargate.debug("PortalFileHelper::doPostLoadTasks::update",
|
||||
String.format("Updating portal signs/buttons for %s", world));
|
||||
@@ -248,6 +250,7 @@ public final class PortalFileHelper {
|
||||
portal.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Save the portals to disk to update with any changes
|
||||
Stargate.debug("PortalFileHelper::doPostLoadTasks", String.format("Saving database for world %s", world));
|
||||
if (needsToSaveDatabase) {
|
||||
@@ -299,7 +302,9 @@ public final class PortalFileHelper {
|
||||
//Register the portal, and close it in case it wasn't properly closed when the server stopped
|
||||
boolean buttonLocationChanged = updateButtonVector(portal);
|
||||
PortalHandler.registerPortal(portal);
|
||||
if (Stargate.getGateConfig().applyStartupFixes()) {
|
||||
portal.getPortalOpener().closePortal(true);
|
||||
}
|
||||
return buttonLocationChanged;
|
||||
}
|
||||
|
||||
|
@@ -107,6 +107,11 @@ gates:
|
||||
# Or if using an easily destroyable open/closed material.
|
||||
protectEntrance: false
|
||||
|
||||
# Should things like outdated signs, invalid button materials and not properly closed Stargates be fixed at startup?
|
||||
# It is generally recommended to enable this, but for huge servers, the amount of chunks loaded might require way
|
||||
# too much RAM.
|
||||
applyStartupFixes: true
|
||||
|
||||
# +----------------------------------------------------------------------------------------------+ #
|
||||
# | Aesthetic Tweaks | #
|
||||
# +----------------------------------------------------------------------------------------------+ #
|
||||
|
Reference in New Issue
Block a user