Updates per-sign inverted colors when the main or highlighting color is changed
This commit is contained in:
parent
02f6c6e9fc
commit
366cd3107e
@ -15,7 +15,8 @@ can share a network or be split into clusters; they can be hidden on a network o
|
|||||||
- **API available** -- using the API, a lot of behavior can be changed
|
- **API available** -- using the API, a lot of behavior can be changed
|
||||||
- **Button customization** -- a large amount of materials usable as buttons (buttons, wall corals, shulkers, chests)
|
- **Button customization** -- a large amount of materials usable as buttons (buttons, wall corals, shulkers, chests)
|
||||||
- **Config commands** -- All main config values can be changed from the commandline
|
- **Config commands** -- All main config values can be changed from the commandline
|
||||||
- **RGB and dye support** -- Signs can use RGB colors as their default colors, and can also be dyed on a per-sign basis
|
- **RGB and dye support** -- Signs can use RGB colors (using hex codes) as their main and highlighting colors, and can
|
||||||
|
also be dyed on a per-sign basis
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
|
@ -200,20 +200,27 @@ public class CommandConfig implements CommandExecutor {
|
|||||||
if (ConfigTag.requiresFullReload(configOption)) {
|
if (ConfigTag.requiresFullReload(configOption)) {
|
||||||
//Reload everything
|
//Reload everything
|
||||||
Stargate.getStargateConfig().reload(commandSender);
|
Stargate.getStargateConfig().reload(commandSender);
|
||||||
} else if (ConfigTag.requiresPortalReload(configOption)) {
|
} else {
|
||||||
//Just unload and reload the portals
|
if (ConfigTag.requiresColorReload(configOption)) {
|
||||||
Stargate.getStargateConfig().unloadAllPortals();
|
Stargate.getStargateConfig().getStargateGateConfig().loadPerSignColors();
|
||||||
Stargate.getStargateConfig().loadAllPortals();
|
}
|
||||||
} else if (ConfigTag.requiresLanguageReload(configOption)) {
|
if (ConfigTag.requiresPortalReload(configOption)) {
|
||||||
//Reload the language loader
|
//Just unload and reload the portals
|
||||||
Stargate.getStargateConfig().getLanguageLoader().reload();
|
Stargate.getStargateConfig().unloadAllPortals();
|
||||||
//Re-draw all portal signs
|
Stargate.getStargateConfig().loadAllPortals();
|
||||||
for (Portal portal : PortalRegistry.getAllPortals()) {
|
}
|
||||||
portal.drawSign();
|
if (ConfigTag.requiresLanguageReload(configOption)) {
|
||||||
|
//Reload the language loader
|
||||||
|
Stargate.getStargateConfig().getLanguageLoader().reload();
|
||||||
|
//Re-draw all portal signs
|
||||||
|
for (Portal portal : PortalRegistry.getAllPortals()) {
|
||||||
|
portal.drawSign();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ConfigTag.requiresEconomyReload(configOption)) {
|
||||||
|
//Load or unload Vault and Economy as necessary
|
||||||
|
Stargate.getStargateConfig().reloadEconomy();
|
||||||
}
|
}
|
||||||
} else if (ConfigTag.requiresEconomyReload(configOption)) {
|
|
||||||
//Load or unload Vault and Economy as necessary
|
|
||||||
Stargate.getStargateConfig().reloadEconomy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,16 @@ public enum ConfigTag {
|
|||||||
return Arrays.stream(taggedOptions).anyMatch((item) -> item == option);
|
return Arrays.stream(taggedOptions).anyMatch((item) -> item == option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether a given config option requires a "reload of colors" to take effect
|
||||||
|
*
|
||||||
|
* @param configOption <p>The config option to check</p>
|
||||||
|
* @return <p>True if changing the config option requires a "reload of colors" to take effect</p>
|
||||||
|
*/
|
||||||
|
public static boolean requiresColorReload(ConfigOption configOption) {
|
||||||
|
return COLOR.isTagged(configOption) && configOption != ConfigOption.FREE_GATES_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a given config option requires a full reload to take effect
|
* Checks whether a given config option requires a full reload to take effect
|
||||||
*
|
*
|
||||||
|
@ -193,7 +193,7 @@ public final class StargateGateConfig {
|
|||||||
/**
|
/**
|
||||||
* Loads the per-sign colors specified in the config file
|
* Loads the per-sign colors specified in the config file
|
||||||
*/
|
*/
|
||||||
private void loadPerSignColors() {
|
public void loadPerSignColors() {
|
||||||
List<?> perSignColors = (List<?>) configOptions.get(ConfigOption.PER_SIGN_COLORS);
|
List<?> perSignColors = (List<?>) configOptions.get(ConfigOption.PER_SIGN_COLORS);
|
||||||
ChatColor[] defaultColors = new ChatColor[]{PortalSignDrawer.getMainColor(), PortalSignDrawer.getHighlightColor()};
|
ChatColor[] defaultColors = new ChatColor[]{PortalSignDrawer.getMainColor(), PortalSignDrawer.getHighlightColor()};
|
||||||
List<Map<Material, ChatColor>> colorMaps = new ArrayList<>();
|
List<Map<Material, ChatColor>> colorMaps = new ArrayList<>();
|
||||||
@ -279,10 +279,15 @@ public final class StargateGateConfig {
|
|||||||
private void loadPerSignColor(String mainSignColor, String highlightSignColor) {
|
private void loadPerSignColor(String mainSignColor, String highlightSignColor) {
|
||||||
try {
|
try {
|
||||||
PortalSignDrawer.setMainColor(ChatColor.of(mainSignColor.toUpperCase()));
|
PortalSignDrawer.setMainColor(ChatColor.of(mainSignColor.toUpperCase()));
|
||||||
|
} catch (IllegalArgumentException | NullPointerException exception) {
|
||||||
|
Stargate.logWarning("You have specified an invalid main sign color in your config.yml. Defaulting to BLACK");
|
||||||
|
PortalSignDrawer.setMainColor(ChatColor.BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
PortalSignDrawer.setHighlightColor(ChatColor.of(highlightSignColor.toUpperCase()));
|
PortalSignDrawer.setHighlightColor(ChatColor.of(highlightSignColor.toUpperCase()));
|
||||||
} catch (IllegalArgumentException | NullPointerException exception) {
|
} catch (IllegalArgumentException | NullPointerException exception) {
|
||||||
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE");
|
Stargate.logWarning("You have specified an invalid highlighting sign color in your config.yml. Defaulting to WHITE");
|
||||||
PortalSignDrawer.setMainColor(ChatColor.BLACK);
|
|
||||||
PortalSignDrawer.setHighlightColor(ChatColor.WHITE);
|
PortalSignDrawer.setHighlightColor(ChatColor.WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user