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),
|
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
|
* 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
|
//Load the option using its correct data type
|
||||||
switch (option.getDataType()) {
|
switch (option.getDataType()) {
|
||||||
case STRING_LIST -> optionValue = newConfig.getStringList(configNode);
|
case STRING_LIST -> optionValue = newConfig.getStringList(configNode);
|
||||||
case STRING -> {
|
case STRING -> optionValue = newConfig.getString(configNode, (String) option.getDefaultValue()).trim();
|
||||||
String value = newConfig.getString(configNode);
|
case BOOLEAN -> optionValue = newConfig.getBoolean(configNode, (boolean) option.getDefaultValue());
|
||||||
optionValue = value != null ? value.trim() : "";
|
case INTEGER -> optionValue = newConfig.getInt(configNode, (int) option.getDefaultValue());
|
||||||
}
|
case DOUBLE -> optionValue = newConfig.getDouble(configNode, (double) option.getDefaultValue());
|
||||||
case BOOLEAN -> optionValue = newConfig.getBoolean(configNode);
|
|
||||||
case INTEGER -> optionValue = newConfig.getInt(configNode);
|
|
||||||
case DOUBLE -> optionValue = newConfig.getDouble(configNode);
|
|
||||||
default -> throw new IllegalArgumentException("Invalid config data type encountered");
|
default -> throw new IllegalArgumentException("Invalid config data type encountered");
|
||||||
}
|
}
|
||||||
configOptions.put(option, optionValue);
|
configOptions.put(option, optionValue);
|
||||||
|
@@ -195,6 +195,15 @@ public final class StargateGateConfig {
|
|||||||
return (boolean) configOptions.get(ConfigOption.DESTROYED_BY_EXPLOSION);
|
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
|
* Gets the default portal network to use if no other network is given
|
||||||
*
|
*
|
||||||
|
@@ -236,16 +236,19 @@ public final class PortalFileHelper {
|
|||||||
Stargate.logInfo(String.format("{%s} Loaded %d stargates with %d set as always-on", world.getName(),
|
Stargate.logInfo(String.format("{%s} Loaded %d stargates with %d set as always-on", world.getName(),
|
||||||
portalCount, openCount));
|
portalCount, openCount));
|
||||||
|
|
||||||
//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",
|
if (Stargate.getGateConfig().applyStartupFixes()) {
|
||||||
String.format("Updating portal signs/buttons for %s", world));
|
//Re-draw the signs in case a bug in the config prevented the portal from loading and has been fixed since
|
||||||
for (Portal portal : PortalRegistry.getAllPortals()) {
|
Stargate.debug("PortalFileHelper::doPostLoadTasks::update",
|
||||||
if (portal.isRegistered() && portal.getWorld() != null && portal.getWorld().equals(world) &&
|
String.format("Updating portal signs/buttons for %s", world));
|
||||||
world.getWorldBorder().isInside(portal.getSignLocation())) {
|
for (Portal portal : PortalRegistry.getAllPortals()) {
|
||||||
portal.drawSign();
|
if (portal.isRegistered() && portal.getWorld() != null && portal.getWorld().equals(world) &&
|
||||||
updatePortalButton(portal);
|
world.getWorldBorder().isInside(portal.getSignLocation())) {
|
||||||
Stargate.debug("UpdateSignsButtons", String.format("Updated sign and button for portal %s",
|
portal.drawSign();
|
||||||
portal.getName()));
|
updatePortalButton(portal);
|
||||||
|
Stargate.debug("UpdateSignsButtons", String.format("Updated sign and button for portal %s",
|
||||||
|
portal.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Save the portals to disk to update with any changes
|
//Save the portals to disk to update with any changes
|
||||||
@@ -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
|
//Register the portal, and close it in case it wasn't properly closed when the server stopped
|
||||||
boolean buttonLocationChanged = updateButtonVector(portal);
|
boolean buttonLocationChanged = updateButtonVector(portal);
|
||||||
PortalHandler.registerPortal(portal);
|
PortalHandler.registerPortal(portal);
|
||||||
portal.getPortalOpener().closePortal(true);
|
if (Stargate.getGateConfig().applyStartupFixes()) {
|
||||||
|
portal.getPortalOpener().closePortal(true);
|
||||||
|
}
|
||||||
return buttonLocationChanged;
|
return buttonLocationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,6 +106,11 @@ gates:
|
|||||||
# This is more resource intensive, and should really only be used if verifyPortals is true.
|
# This is more resource intensive, and should really only be used if verifyPortals is true.
|
||||||
# Or if using an easily destroyable open/closed material.
|
# Or if using an easily destroyable open/closed material.
|
||||||
protectEntrance: false
|
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 | #
|
# | Aesthetic Tweaks | #
|
||||||
|
Reference in New Issue
Block a user