diff --git a/src/main/java/dev/fire/TextUtil.java b/src/main/java/dev/fire/TextUtil.java index b620ef6..9634327 100644 --- a/src/main/java/dev/fire/TextUtil.java +++ b/src/main/java/dev/fire/TextUtil.java @@ -200,19 +200,7 @@ public static Text replaceTags(Text text, boolean isTabList) { ChatTag normal = DefaultConfig.newChatTags.get(key); MiniMessageChatTag custom = c.chatTags.get(key); - int color; - TextColor colorObj = null; - - if (!custom.getAsFormatted(custom.mainvalue).getSiblings().isEmpty()) { - colorObj = custom.getAsFormatted(custom.mainvalue).getSiblings().get(0).getStyle().getColor(); - } - if (colorObj == null) { - //color = DefaultConfig.newChatTags.get(key).TextColor; - color = 0xffffff; - } else { - color = colorObj.getRgb(); - } - + int color = custom.ProfileColor; // replace text = replaceTextInternal(text, getProfileLine(normal.TextColor,false), getProfileLine(color,false), false); text = replaceTextInternal(text, getProfileLine(normal.TextColor, true), getProfileLine(color,true), false); @@ -223,18 +211,8 @@ public static Text replaceTags(Text text, boolean isTabList) { // vipenabled / disabled logic MiniMessageChatTag custom_vip = c.chatTags.get("vip"); - int color; - TextColor colorObj = null; - - if (!custom_vip.getAsFormatted(custom_vip.mainvalue).getSiblings().isEmpty()) { - colorObj = custom_vip.getAsFormatted(custom_vip.mainvalue).getSiblings().get(0).getStyle().getColor(); - } - if (colorObj == null) { - //color = DefaultConfig.newChatTags.get(key).TextColor; - color = 0xffffff; - } else { - color = colorObj.getRgb(); - } + int color = custom_vip.ProfileColor; + if (!c.VipEnabled) { text = replaceTextInternal(text, VIP_PREFIX, Text.empty(), true); text = replaceTextInternal(text, VIP_WHOIS, Text.empty(), false); diff --git a/src/main/java/dev/fire/config/Config.java b/src/main/java/dev/fire/config/Config.java index b921c4f..acc66aa 100644 --- a/src/main/java/dev/fire/config/Config.java +++ b/src/main/java/dev/fire/config/Config.java @@ -10,6 +10,7 @@ import dev.isxander.yacl3.api.controller.*; import net.minecraft.text.Text; +import java.awt.*; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -41,9 +42,9 @@ public static Map convertToMinimessage(Map chatTags.get(key).leftvalue, - opt -> chatTags.get(key).leftvalue = opt - ) - .controller(StringControllerBuilder::create) - .build()) .option(Option.createBuilder(String.class) .name(Text.literal("Main Text Value")) .description(OptionDescription.createBuilder() @@ -178,18 +167,6 @@ private OptionGroup groupBuilder(String key, String name) { ) .controller(StringControllerBuilder::create) .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Right Text Value")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Formatted in MiniMessage")) - .build()) - .binding( - DefaultConfig.oldChatTags.get(key).toRightMiniMessage(), - () -> chatTags.get(key).rightvalue, - opt -> chatTags.get(key).rightvalue = opt - ) - .controller(StringControllerBuilder::create) - .build()) .option(Option.createBuilder(String.class) .name(Text.literal("Short Tag Value")) .description(OptionDescription.createBuilder() @@ -201,8 +178,8 @@ private OptionGroup groupBuilder(String key, String name) { opt -> chatTags.get(key).shortvalue = opt ) .controller(StringControllerBuilder::create) - .build()) - .build(); + .build()); + } @@ -277,7 +254,9 @@ private ConfigCategory.Builder staffChatTags() { if (key == "emeritus") { name = "Emeritus"; } - configBuilder.group(groupBuilder(key,name)); + + OptionGroup.Builder builder = groupBuilder(key,name); + configBuilder.group(builder.build()); }); return configBuilder; @@ -293,7 +272,21 @@ private ConfigCategory.Builder normalChatTags() { normalChatTagList.forEach(k -> { String key = (String) k; String name = DefaultConfig.newChatTags.get(key).TextContent; - configBuilder.group(groupBuilder(key,name)); + + OptionGroup.Builder builder = groupBuilder(key,name); + builder.option(Option.createBuilder(Color.class) + .name(Text.literal("/whois Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of your /whois, dictated by the highest paid rank you have. ie: Overlord, Mythic, Emperor, or Noble. ")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).TextColor), + () -> new Color(chatTags.get(key).ProfileColor), + opt -> chatTags.get(key).ProfileColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()); + configBuilder.group(builder.build()); }); return configBuilder; @@ -309,7 +302,9 @@ private ConfigCategory.Builder specialChatTags() { specialChatTagList.forEach(k -> { String key = (String) k; String name = DefaultConfig.newChatTags.get(key).TextContent; - configBuilder.group(groupBuilder(key,name)); + + OptionGroup.Builder builder = groupBuilder(key,name); + configBuilder.group(builder.build()); }); return configBuilder; diff --git a/src/main/java/dev/fire/utils/ChatTag.java b/src/main/java/dev/fire/utils/ChatTag.java index bb81b07..187976d 100644 --- a/src/main/java/dev/fire/utils/ChatTag.java +++ b/src/main/java/dev/fire/utils/ChatTag.java @@ -32,24 +32,15 @@ public String toJson(){ return object.toString(); } - public String toLeftMiniMessage() { + public String toMainMiniMessage() { String minimessage = ""; minimessage = minimessage + convertStringWithColorToMiniMessage("[", BracketColor); minimessage = minimessage + convertStringWithColorToMiniMessage(Symbol, SymbolColor); if ( addBoldSpace ) minimessage = minimessage + "\u200C"; - return minimessage; - } - public String toRightMiniMessage() { - String minimessage = ""; + minimessage = minimessage + convertStringWithColorToMiniMessage(TextContent, TextColor); if ( addBoldSpace ) minimessage = minimessage + "\u200C"; minimessage = minimessage + convertStringWithColorToMiniMessage(Symbol, SymbolColor); minimessage = minimessage + convertStringWithColorToMiniMessage("]", BracketColor); - return minimessage; - } - - public String toMainMiniMessage() { - String minimessage = ""; - minimessage = minimessage + convertStringWithColorToMiniMessage(TextContent, TextColor); return minimessage; } diff --git a/src/main/java/dev/fire/utils/MiniMessageChatTag.java b/src/main/java/dev/fire/utils/MiniMessageChatTag.java index d5cd6ca..3423795 100644 --- a/src/main/java/dev/fire/utils/MiniMessageChatTag.java +++ b/src/main/java/dev/fire/utils/MiniMessageChatTag.java @@ -7,26 +7,17 @@ public class MiniMessageChatTag implements Serializable { public String mainvalue; - public String leftvalue; - public String rightvalue; public String shortvalue; - - public MiniMessageChatTag(String leftvalue, String mainvalue, String rightvalue, String shortvalue) { - this.leftvalue = leftvalue; - this.mainvalue = mainvalue; - this.rightvalue = rightvalue; - this.shortvalue = shortvalue; - } + public int ProfileColor; public MiniMessageChatTag(ChatTag chattag) { - this.leftvalue = chattag.toLeftMiniMessage(); this.mainvalue = chattag.toMainMiniMessage(); - this.rightvalue = chattag.toRightMiniMessage(); this.shortvalue = chattag.toShortValue(); + this.ProfileColor = chattag.TextColor; } public Text getAsFormatted() { - return MiniMessage.format(leftvalue +mainvalue+ rightvalue, false); + return MiniMessage.format( mainvalue, false); } public Text getAsFormatted(String input) { return MiniMessage.format(input, false); @@ -37,9 +28,8 @@ public Text getAsShortFormatted() { public String toJson(){ JsonObject object = new JsonObject(); object.addProperty("mainvalue", mainvalue); - object.addProperty("leftvalue", leftvalue); - object.addProperty("rightvalue", rightvalue); object.addProperty("shortvalue", shortvalue); + object.addProperty("ProfileColor", ProfileColor); return object.toString(); } }