Rewrites a lot of the config command to only do the minimum necessary steps to load the changes

Adds a ConfigTag class for helping to decide the action necessary for updating a given config option
Splits the color setting in PortalSignDrawer as only one color is set at a time when the /config command is used
Updates the configOptions map when a config option is changed
This commit is contained in:
2021-11-24 22:33:45 +01:00
parent 6e7ac5dbb9
commit 32975ca35d
6 changed files with 218 additions and 51 deletions

View File

@ -190,13 +190,13 @@ public final class StargateGateConfig {
private void loadSignColor(String mainSignColor, String highlightSignColor) {
if (mainSignColor != null && highlightSignColor != null) {
try {
PortalSignDrawer.setColors(ChatColor.valueOf(mainSignColor.toUpperCase()),
ChatColor.valueOf(highlightSignColor.toUpperCase()));
return;
PortalSignDrawer.setMainColor(ChatColor.valueOf(highlightSignColor.toUpperCase()));
PortalSignDrawer.setHighlightColor(ChatColor.valueOf(highlightSignColor.toUpperCase()));
} catch (IllegalArgumentException | NullPointerException ignored) {
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE");
PortalSignDrawer.setMainColor(ChatColor.BLACK);
PortalSignDrawer.setHighlightColor(ChatColor.WHITE);
}
}
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE");
PortalSignDrawer.setColors(ChatColor.BLACK, ChatColor.WHITE);
}
}