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

@ -31,7 +31,12 @@ public final class EconomyConfig {
*/
public EconomyConfig(Map<ConfigOption, Object> configOptions) {
this.configOptions = configOptions;
loadEconomyConfig(configOptions);
try {
String freeColor = (String) configOptions.get(ConfigOption.FREE_GATES_COLOR);
PortalSignDrawer.setFreeColor(ChatColor.valueOf(freeColor.toUpperCase()));
} catch (IllegalArgumentException | NullPointerException ignored) {
PortalSignDrawer.setFreeColor(ChatColor.DARK_GREEN);
}
}
/**
@ -220,21 +225,6 @@ public final class EconomyConfig {
}
}
/**
* Loads all config values related to economy
*
* @param configOptions <p>The loaded config options to get values from</p>
*/
private void loadEconomyConfig(Map<ConfigOption, Object> configOptions) {
try {
String freeColor = (String) configOptions.get(ConfigOption.FREE_GATES_COLOR);
PortalSignDrawer.setFreeColor(ChatColor.valueOf(freeColor.toUpperCase()));
} catch (IllegalArgumentException | NullPointerException ignored) {
PortalSignDrawer.setFreeColor(ChatColor.DARK_GREEN);
}
}
/**
* Determines if a player can do a gate action for free
*