From 6728f689baaeabfe296c92d606f2326502396d65 Mon Sep 17 00:00:00 2001 From: ASangarin Date: Tue, 3 Sep 2019 01:02:48 +0100 Subject: [PATCH] Added resource bar color options --- .../Indyuce/mmocore/manager/ConfigManager.java | 18 ++++++++++++++++++ src/main/resources/config.yml | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index 536390ee..ace7c800 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -29,6 +29,7 @@ public class ConfigManager { public boolean overrideVanillaExp, hotbarSwap; public double expPartyBuff, regenPartyBuff; public String partyChatPrefix; + public ChatColor manaFull, manaHalf, manaEmpty, staminaFull, staminaHalf, staminaEmpty; private final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(); public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols); @@ -99,6 +100,13 @@ public class ConfigManager { partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix"); formatSymbols.setDecimalSeparator(getFirstChar(MMOCore.plugin.getConfig().getString("number-format.decimal-separator"), ',')); + manaFull = getColorOrDefault("mana-whole", ChatColor.BLUE); + manaHalf = getColorOrDefault("mana-half", ChatColor.AQUA); + manaEmpty = getColorOrDefault("mana-empty", ChatColor.WHITE); + staminaFull = getColorOrDefault("stamina-whole", ChatColor.BLUE); + staminaHalf = getColorOrDefault("stamina-half", ChatColor.AQUA); + staminaEmpty = getColorOrDefault("stamina-empty", ChatColor.WHITE); + neededExp.clear(); int line = 0; try { @@ -115,6 +123,16 @@ public class ConfigManager { } } + private ChatColor getColorOrDefault(String configKey, ChatColor defaultColor) { + ChatColor newColor = ChatColor.valueOf(MMOCore.plugin.getConfig().getString("resource-bar-colors." + configKey).toUpperCase()); + + if(newColor != null) + return newColor; + + MMOCore.log(Level.WARNING, "Resource Bar color config '" + configKey + "' is invalid... Using default color!"); + return defaultColor; + } + public DecimalFormat newFormat(String pattern) { return new DecimalFormat(pattern, formatSymbols); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 74a33cc1..95c6495e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -78,3 +78,13 @@ hotbar-swap: true # Use this option if you're having issue with Anvil GUIs. # This replaces anvil inputs by chat inputs. use-chat-input: true + +# Change this to the name of the color you want for +# the different resource bar placeholders +resource-bar-colors: + mana-whole: 'BLUE' + mana-half: 'AQUA' + mana-empty: 'WHITE' + stamina-whole: 'LIME' + stamina-half: 'GREEN' + stamina-empty: 'WHITE'