diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java index 15f16ec..f203993 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/config/ConfigHandler.java @@ -229,6 +229,21 @@ public class ConfigHandler { return config.getInt("hover-text-amount-lighter", 20); } + /** Returns a String that represents either a Chat Color, hex color code, or a Style. Default values are: + *
Style: "italic"
+ *Color: "gray"
*/ + public String getSharedByTextDecoration(boolean getStyle) { + String def = getStyle ? "italic" : "gray"; + return getDecorationString(null, getStyle, def, "shared-by"); + } + + /** Returns a String that represents either a Chat Color, hex color code, or a Style. Default values are: + *Style: "none"
+ *Color: "#845EC2"
*/ + public String getSharerNameDecoration(boolean getStyle) { + return getDecorationString(null, getStyle, "#845EC2", "player-name"); + } + /** Returns a String that represents either a Chat Color, hex color code, or a Style. Default values are:Style: "none"
Color Top: "green"
@@ -360,6 +375,9 @@ public class ConfigHandler { /** Returns the config section that contains the relevant color or style option. */ private @Nullable ConfigurationSection getRelevantSection(Target selection) { + if (selection == null) { //rather than rework the whole Target enum, I have added shared-stats as the null-option for now + return config.getConfigurationSection("shared-stats"); + } switch (selection) { case TOP -> { return config.getConfigurationSection("top-list"); diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/BukkitConsoleComponentFactory.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/BukkitConsoleComponentFactory.java index 20198c1..d55d471 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/BukkitConsoleComponentFactory.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/BukkitConsoleComponentFactory.java @@ -4,6 +4,7 @@ import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler; import com.gmail.artemis.the.gr8.playerstats.enums.DebugLevel; import com.gmail.artemis.the.gr8.playerstats.enums.PluginColor; import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger; +import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; public class BukkitConsoleComponentFactory extends ComponentFactory { @@ -31,4 +32,10 @@ public class BukkitConsoleComponentFactory extends ComponentFactory { public TextColor getSharerNameColor() { return PluginColor.NAME_5.getConsoleColor(); } + + @Override + protected TextColor getHexColor(String hexColor) { + TextColor hex = TextColor.fromHexString(hexColor); + return hex != null ? NamedTextColor.nearestTo(hex) : NamedTextColor.WHITE; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/ComponentFactory.java b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/ComponentFactory.java index 44ef554..f0bcfec 100644 --- a/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/ComponentFactory.java +++ b/src/main/java/com/gmail/artemis/the/gr8/playerstats/msg/ComponentFactory.java @@ -65,11 +65,6 @@ public class ComponentFactory { HOVER_ACCENT = PluginColor.LIGHT_GOLD.getColor(); } - //TODO try the share-purple for sharer-names - public TextColor getSharerNameColor() { - return PluginColor.NAME_5.getColor(); - } - public TextColor prefix() { return PREFIX; } @@ -101,6 +96,10 @@ public class ComponentFactory { return HOVER_ACCENT; } + public TextColor getSharerNameColor() { + return getColorFromString(config.getSharerNameDecoration(false)); + } + /** Returns [PlayerStats]. */ public TextComponent pluginPrefixComponent() { @@ -321,17 +320,19 @@ public class ComponentFactory { public TextComponent messageSharedComponent(Component playerName) { return surroundingBracketComponent( - text().append(text("Shared by") - .color(BRACKETS) - .decorate(TextDecoration.ITALIC)) + text().append( + getComponent("Shared by", + getColorFromString(config.getSharedByTextDecoration(false)), + getStyleFromString(config.getSharedByTextDecoration(true)))) .append(space()) .append(playerName) .build()); } public TextComponent sharerNameComponent(String sharerName) { - return text(sharerName) - .color(getSharerNameColor()); + return getComponent(sharerName, + getSharerNameColor(), + getStyleFromString(config.getSharerNameDecoration(true))); } private TextComponent surroundingBracketComponent(TextComponent component) { @@ -394,7 +395,7 @@ public class ComponentFactory { if (configString != null) { try { if (configString.contains("#")) { - return TextColor.fromHexString(configString); + return getHexColor(configString); } else { return getTextColorByName(configString); @@ -407,6 +408,10 @@ public class ComponentFactory { return null; } + protected TextColor getHexColor(String hexColor) { + return TextColor.fromHexString(hexColor); + } + private TextColor getTextColorByName(String textColor) { Index