diff --git a/README.md b/README.md index 92ab23f..0dfcfa6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,11 @@ Replaces the **TERRIBLE** and **UGLY** _new rank tags_ 👎👎LLLL with the **A ## This mod is exclusively for the minecraft server [DiamondFire](https://mcdiamondfire.com/) Do not use this mod if you don't player DiamondFire, you'll be very disappointed! +### New Chat Tags (L) +![new](https://cdn.modrinth.com/data/cached_images/3974d68eb66ba03106bd9bec253081e3f0792589.png) +### Replaced with Old Chat Tags (very WWW) +![old](https://cdn.modrinth.com/data/cached_images/5d210ff4a57f48ad3bbf3df55ad97821438163fe.png) +### You can also use custom colors and symbols! ![Customized Rank Tags](https://cdn.modrinth.com/data/cached_images/5fb4989387991c053c7951d76ac5fabed84a30ac.png) ## Supported Rank Tags @@ -23,6 +28,9 @@ The following Rank tags are supported: - Dev - Admin - Owner (real) +- Emeritus +- Retired +- Builder ## Additional Features This mod also allows you to disable VIP tags/badges completely (from [YouAintCool](https://github.com/Reasonlesss/YouAintCool) by [ReasonLess](https://github.com/Reasonlesss)) in the VIP section of the config. diff --git a/gradle.properties b/gradle.properties index cb429b0..52855a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.4+build.3 loader_version=0.15.11 # Mod Properties -mod_version=1.0.0-alpha +mod_version=1.1.0 maven_group=dev.fire archives_base_name=dfrevert diff --git a/src/main/java/dev/fire/TextUtil.java b/src/main/java/dev/fire/TextUtil.java index 0eadd91..39e9d25 100644 --- a/src/main/java/dev/fire/TextUtil.java +++ b/src/main/java/dev/fire/TextUtil.java @@ -1,33 +1,33 @@ package dev.fire; import dev.fire.config.ChatTag; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.PlainTextContent; -import net.minecraft.text.Text; +import net.minecraft.network.message.SentMessage; +import net.minecraft.text.*; import dev.fire.config.Config; import dev.fire.config.DefaultConfig; +import java.util.Map; +import java.util.Objects; + public class TextUtil { public static final String MOD_NAME = "DFrevert"; public static final String MOD_ID = "dfrevert"; private static final Text VIP_PREFIX = Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Vip.BracketColor)) + .append(Text.literal("[").withColor(DefaultConfig.newChatTags.get("vip").BracketColor)) .append(Text.literal("⭐") .styled(style -> style - .withColor(DefaultConfig.Vip.SymbolColor) + .withColor(DefaultConfig.newChatTags.get("vip").SymbolColor) .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/vip")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("VIP").withColor(DefaultConfig.Vip.SymbolColor))) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("VIP").withColor(DefaultConfig.newChatTags.get("vip").SymbolColor))) )) - .append(Text.literal("]").withColor(DefaultConfig.Vip.BracketColor)); + .append(Text.literal("]").withColor(DefaultConfig.newChatTags.get("vip").BracketColor)); private static final Text VIP_WHOIS = Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Vip.BracketColor)) - .append(Text.literal("VIP").withColor(DefaultConfig.Vip.SymbolColor)) - .append(Text.literal("]").withColor(DefaultConfig.Vip.BracketColor)); - private static final Text FOUNDING_BADGE = Text.literal("⭐ ").styled(style -> style.withColor(DefaultConfig.Vip.SymbolColor) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Founding VIP").withColor(DefaultConfig.Vip.SymbolColor)))); + .append(Text.literal("[").withColor(DefaultConfig.newChatTags.get("vip").BracketColor)) + .append(Text.literal("VIP").withColor(DefaultConfig.newChatTags.get("vip").SymbolColor)) + .append(Text.literal("]").withColor(DefaultConfig.newChatTags.get("vip").BracketColor)); + private static final Text FOUNDING_BADGE = Text.literal("⭐ ").styled(style -> style.withColor(DefaultConfig.newChatTags.get("vip").SymbolColor) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Founding VIP").withColor(DefaultConfig.newChatTags.get("vip").SymbolColor)))); public static Text getProfileLine(int color, boolean custom_line) { String txt = " "; @@ -48,129 +48,83 @@ public static Text getProfileArrow(int color) { // the reason im doing it like this is cus some tags have weird text literal sibling structures - public static Text getOldOverlord() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Overlord.BracketColor)) - .append(Text.empty().append(Text.literal(DefaultConfig.Overlord.Symbol).withColor(DefaultConfig.Overlord.SymbolColor)) - .append(Text.literal(DefaultConfig.Overlord.TextContent).withColor(DefaultConfig.Overlord.TextColor)) - .append(Text.literal(DefaultConfig.Overlord.Symbol).withColor(DefaultConfig.Overlord.SymbolColor))) - .append(Text.literal("]").withColor(DefaultConfig.Overlord.BracketColor)); - } - public static Text getOldMythic() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Mythic.BracketColor)) - .append(Text.literal(DefaultConfig.Mythic.TextContent).withColor(DefaultConfig.Mythic.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Mythic.BracketColor)); - } - public static Text getOldEmperor() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Emperor.BracketColor)) - .append(Text.literal(DefaultConfig.Emperor.TextContent).withColor(DefaultConfig.Emperor.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Emperor.BracketColor)); - } - public static Text getOldNoble() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Noble.BracketColor)) - .append(Text.literal(DefaultConfig.Noble.TextContent).withColor(DefaultConfig.Noble.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Noble.BracketColor)); - } - - // Old Staff Chat Tags - - public static Text getOldOwner() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Owner.BracketColor)) - .append(Text.literal(DefaultConfig.Owner.TextContent).withColor(DefaultConfig.Owner.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Owner.BracketColor)); - } - public static Text getOldAdmin() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Admin.BracketColor)) - .append(Text.literal(DefaultConfig.Admin.TextContent).withColor(DefaultConfig.Admin.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Admin.BracketColor)); - } - public static Text getOldDev() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Dev.BracketColor)) - .append(Text.literal(DefaultConfig.Dev.TextContent).withColor(DefaultConfig.Dev.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Dev.BracketColor)); - } - public static Text getOldSrMod() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.SrMod.BracketColor)) - .append(Text.literal(DefaultConfig.SrMod.TextContent).withColor(DefaultConfig.SrMod.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.SrMod.BracketColor)); - } - public static Text getOldMod() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Mod.BracketColor)) - .append(Text.literal(DefaultConfig.Mod.TextContent).withColor(DefaultConfig.Mod.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Mod.BracketColor)); - } - public static Text getOldJrMod() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.JrMod.BracketColor)) - .append(Text.literal(DefaultConfig.JrMod.TextContent).withColor(DefaultConfig.JrMod.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.JrMod.BracketColor)); - } - public static Text getOldSrHelper() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.SrHelper.BracketColor)) - .append(Text.literal(DefaultConfig.SrHelper.TextContent).withColor(DefaultConfig.SrHelper.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.SrHelper.BracketColor)); - } - public static Text getOldHelper() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.Helper.BracketColor)) - .append(Text.literal(DefaultConfig.Helper.TextContent).withColor(DefaultConfig.Helper.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.Helper.BracketColor)); - } - public static Text getOldJrHelper() { - return Text.empty() - .append(Text.literal("[").withColor(DefaultConfig.JrHelper.BracketColor)) - .append(Text.literal(DefaultConfig.JrHelper.TextContent).withColor(DefaultConfig.JrHelper.TextColor)) - .append(Text.literal("]").withColor(DefaultConfig.JrHelper.BracketColor)); - } - public static Text getCustomTag(ChatTag chattag, boolean add_space) { + public static Text getCustomTag(ChatTag chattag, boolean add_space, boolean encase_inTextEmpty) { int bracket_color = chattag.BracketColor; int symbol_color = chattag.SymbolColor; int text_color = chattag.TextColor; String symbol = chattag.Symbol; String main_text = chattag.TextContent; - if (symbol == "") { + + if (chattag.addBoldSpace) { + Text returnText; + + // has symbol + if (Objects.equals(symbol, "")) { + returnText = Text.empty() + .append(Text.literal("[").withColor(bracket_color)) + .append( + Text.empty() + .append(Text.literal("\u200C").styled(style -> style.withBold(true))) + .append(Text.literal(main_text).withColor(text_color)) + .append(Text.literal("\u200C").styled(style -> style.withBold(true))) + ) + .append(Text.literal("]").withColor(bracket_color)); + } else { + returnText = Text.empty() + .append(Text.literal("[").withColor(bracket_color)) + .append( + Text.empty() + .append(Text.literal(symbol).withColor(symbol_color)) + .append(Text.literal("\u200C").styled(style -> style.withBold(true))) + .append(Text.literal(main_text).withColor(text_color)) + .append(Text.literal("\u200C").styled(style -> style.withBold(true))) + .append(Text.literal(symbol).withColor(symbol_color)) + ) + .append(Text.literal("]").withColor(bracket_color)); + } + // default + if (encase_inTextEmpty) { + returnText = Text.empty().append(returnText); + } + return returnText; + + + // old/staff ----- + } else { + if (Objects.equals(symbol, "")) { + if (add_space) { + return Text.empty() + .append(Text.literal("[").withColor(bracket_color)) + .append(Text.literal(main_text).withColor(text_color)) + .append(Text.literal("]").withColor(bracket_color)) + .append(Text.literal(" ")); + } + return Text.empty() + .append(Text.literal("[").withColor(bracket_color)) + .append(Text.literal(main_text).withColor(text_color)) + .append(Text.literal("]").withColor(bracket_color)); + } if (add_space) { return Text.empty() .append(Text.literal("[").withColor(bracket_color)) + .append(Text.literal(symbol).withColor(symbol_color)) .append(Text.literal(main_text).withColor(text_color)) + .append(Text.literal(symbol).withColor(symbol_color)) .append(Text.literal("]").withColor(bracket_color)) .append(Text.literal(" ")); } - return Text.empty() - .append(Text.literal("[").withColor(bracket_color)) - .append(Text.literal(main_text).withColor(text_color)) - .append(Text.literal("]").withColor(bracket_color)); - } - if (add_space) { return Text.empty() .append(Text.literal("[").withColor(bracket_color)) .append(Text.literal(symbol).withColor(symbol_color)) .append(Text.literal(main_text).withColor(text_color)) .append(Text.literal(symbol).withColor(symbol_color)) - .append(Text.literal("]").withColor(bracket_color)) - .append(Text.literal(" ")); - + .append(Text.literal("]").withColor(bracket_color)); } - return Text.empty() - .append(Text.literal("[").withColor(bracket_color)) - .append(Text.literal(symbol).withColor(symbol_color)) - .append(Text.literal(main_text).withColor(text_color)) - .append(Text.literal(symbol).withColor(symbol_color)) - .append(Text.literal("]").withColor(bracket_color)); - } +} public static Text getShortCustomTag(ChatTag chattag, boolean add_space, boolean return_empty) { if (return_empty) { @@ -195,89 +149,52 @@ public static Text getShortCustomTag(ChatTag chattag, boolean add_space, boolean public static Text replaceTags(Text text, boolean isTabList) { Config c = Config.getConfig(); + if (c.DisableMod){ return text; } - ChatTag custom_vip = new ChatTag(c.VipBracketColor, c.VipSymbolColor, c.VipTextColor, c.VipSymbol, c.VipTextContent); - - ChatTag custom_overlord = new ChatTag(c.OverlordBracketColor, c.OverlordSymbolColor, c.OverlordTextColor, c.OverlordSymbol, c.OverlordTextContent); - ChatTag custom_mythic = new ChatTag(c.MythicBracketColor, c.MythicSymbolColor, c.MythicTextColor, c.MythicSymbol, c.MythicTextContent); - ChatTag custom_emperor = new ChatTag(c.EmperorBracketColor, c.EmperorSymbolColor, c.EmperorTextColor, c.EmperorSymbol, c.EmperorTextContent); - ChatTag custom_noble = new ChatTag(c.NobleBracketColor, c.NobleSymbolColor, c.NobleTextColor, c.NobleSymbol, c.NobleTextContent); - - ChatTag custom_owner = new ChatTag(c.OwnerBracketColor, c.OwnerSymbolColor, c.OwnerTextColor, c.OwnerSymbol, c.OwnerTextContent); - ChatTag custom_admin = new ChatTag(c.AdminBracketColor, c.AdminSymbolColor, c.AdminTextColor, c.AdminSymbol, c.AdminTextContent); - ChatTag custom_dev = new ChatTag(c.DevBracketColor, c.DevSymbolColor, c.DevTextColor, c.DevSymbol, c.DevTextContent); - ChatTag custom_srmod = new ChatTag(c.SrModBracketColor, c.SrModSymbolColor, c.SrModTextColor, c.SrModSymbol, c.SrModTextContent); - ChatTag custom_mod = new ChatTag(c.ModBracketColor, c.ModSymbolColor, c.ModTextColor, c.ModSymbol, c.ModTextContent); - ChatTag custom_jrmod = new ChatTag(c.JrModBracketColor, c.JrModSymbolColor, c.JrModTextColor, c.JrModSymbol, c.JrModTextContent); - ChatTag custom_srhelper = new ChatTag(c.SrHelperBracketColor, c.SrHelperSymbolColor, c.SrHelperTextColor, c.SrHelperSymbol, c.SrHelperTextContent); - ChatTag custom_helper = new ChatTag(c.HelperBracketColor, c.HelperSymbolColor, c.HelperTextColor, c.HelperSymbol, c.HelperTextContent); - ChatTag custom_jrhelper = new ChatTag(c.JrHelperBracketColor, c.JrHelperSymbolColor, c.JrHelperTextColor, c.JrHelperSymbol, c.JrHelperTextContent); - - // replace old tags - text = replaceTextInternal(text, getOldOverlord(), getCustomTag(custom_overlord, false), false); - text = replaceTextInternal(text, getOldMythic(), getCustomTag(custom_mythic, false), false); - text = replaceTextInternal(text, getOldEmperor(), getCustomTag(custom_emperor, false), false); - text = replaceTextInternal(text, getOldNoble(), getCustomTag(custom_noble, false), false); - - text = replaceTextInternal(text, getOldOwner(), getCustomTag(custom_owner, false), false); - text = replaceTextInternal(text, getOldAdmin(), getCustomTag(custom_admin, false), false); - text = replaceTextInternal(text, getOldDev(), getCustomTag(custom_dev, false), false); - text = replaceTextInternal(text, getOldSrMod(), getCustomTag(custom_srmod, false), false); - text = replaceTextInternal(text, getOldMod(), getCustomTag(custom_mod, false), false); - text = replaceTextInternal(text, getOldJrMod(), getCustomTag(custom_jrmod, false), false); - text = replaceTextInternal(text, getOldSrHelper(), getCustomTag(custom_srhelper, false), false); - text = replaceTextInternal(text, getOldHelper(), getCustomTag(custom_helper, false), false); - text = replaceTextInternal(text, getOldJrHelper(), getCustomTag(custom_jrhelper, false), false); - - // replace old shortened tags - boolean return_empty = !c.ShortenedChatTags && !isTabList; - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Overlord, isTabList, false), getShortCustomTag(custom_overlord, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Mythic, isTabList, false), getShortCustomTag(custom_mythic, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Emperor, isTabList, false), getShortCustomTag(custom_emperor, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Noble, isTabList, false), getShortCustomTag(custom_noble, isTabList, return_empty), false); - - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Owner, isTabList, false), getShortCustomTag(custom_owner, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Admin, isTabList, false), getShortCustomTag(custom_admin, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Dev, isTabList, false), getShortCustomTag(custom_dev, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.SrMod, isTabList, false), getShortCustomTag(custom_srmod, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Mod, isTabList, false), getShortCustomTag(custom_mod, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.JrMod, isTabList, false), getShortCustomTag(custom_jrmod, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.SrHelper, isTabList, false), getShortCustomTag(custom_srhelper, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.Helper, isTabList, false), getShortCustomTag(custom_helper, isTabList, return_empty), false); - text = replaceTextInternal(text, getShortCustomTag(DefaultConfig.JrHelper, isTabList, false), getShortCustomTag(custom_jrhelper, isTabList, return_empty), false); - - if (isTabList) { - text = replaceTextInternal(text, getCustomTag(DefaultConfig.Owner, true), getCustomTag(custom_owner, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.Admin, true), getCustomTag(custom_admin, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.Dev, true), getCustomTag(custom_dev, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.SrMod, true), getCustomTag(custom_srmod, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.Mod, true), getCustomTag(custom_mod, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.JrMod, true), getCustomTag(custom_jrmod, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.SrHelper, true), getCustomTag(custom_srhelper, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.Helper, true), getCustomTag(custom_helper, true), false); - text = replaceTextInternal(text, getCustomTag(DefaultConfig.JrHelper, true), getCustomTag(custom_jrhelper, true), false); - } + // custom tags + + for (Map.Entry entry : DefaultConfig.oldChatTags.entrySet()) { + String key = entry.getKey(); + ChatTag chattag = entry.getValue(); + ChatTag custom = c.chatTags.get(key); + ChatTag replacetag = DefaultConfig.newChatTags.get(key); - // replace old profile lines - boolean set_newline = false; - for (int i = 0; i < 2; i++) { - text = replaceTextInternal(text, getProfileLine(0xAA0000,set_newline), getProfileLine(custom_overlord.TextColor,set_newline), false); - text = replaceTextInternal(text, getProfileLine(0xAA00AA,set_newline), getProfileLine(custom_mythic.TextColor,set_newline), false); - text = replaceTextInternal(text, getProfileLine(0x55FFFF,set_newline), getProfileLine(custom_emperor.TextColor,set_newline), false); - text = replaceTextInternal(text, getProfileLine(0xFFAA00,set_newline), getProfileLine(custom_noble.TextColor,set_newline), false); - set_newline = true; + if (!Objects.equals(key, "vip")) { + + text = replaceTextInternal(text, getCustomTag(replacetag, false, false), getCustomTag(custom, false, false), false); + text = replaceTextInternal(text, getCustomTag(replacetag, false, true), getCustomTag(custom, false, false), false); + + // replace shortened chat tags and tab list for normal tags + boolean return_empty = !c.ShortenedChatTags && !isTabList; + text = replaceTextInternal(text, getShortCustomTag(replacetag, isTabList, false), getShortCustomTag(custom, isTabList, return_empty), false); + + // check if its the tab list and if its a staff tag (staff tags in the tab list are displayed fully but with an add_space, different from above) + if (isTabList) { + if (DefaultConfig.staffList.contains(key)) { + text = replaceTextInternal(text, getCustomTag(replacetag, true, false), getCustomTag(custom, true, false), false); + } + } + + } } - // replace old profile arrows - text = replaceTextInternal(text, getProfileArrow(0xAA0000), getProfileArrow(custom_overlord.TextColor), false); - text = replaceTextInternal(text, getProfileArrow(0xAA00AA), getProfileArrow(custom_mythic.TextColor), false); - text = replaceTextInternal(text, getProfileArrow(0x55FFFF), getProfileArrow(custom_emperor.TextColor), false); - text = replaceTextInternal(text, getProfileArrow(0xFFAA00), getProfileArrow(custom_noble.TextColor), false); + // replace profile line and arrow colors + for (String key : DefaultConfig.normalList) { + ChatTag normal = DefaultConfig.newChatTags.get(key); + ChatTag custom = c.chatTags.get(key); + + text = replaceTextInternal(text, getProfileLine(normal.TextColor,false), getProfileLine(custom.TextColor,false), false); + text = replaceTextInternal(text, getProfileLine(normal.TextColor, true), getProfileLine(custom.TextColor,true), false); + + text = replaceTextInternal(text, getProfileArrow(normal.TextColor), getProfileArrow(custom.TextColor), false); - // vipenabled/disabled logic + } + + // vipenabled / disabled logic + ChatTag custom_vip = c.chatTags.get("vip"); if (!c.VipEnabled) { text = replaceTextInternal(text, VIP_PREFIX, Text.empty(), true); text = replaceTextInternal(text, VIP_WHOIS, Text.empty(), false); @@ -287,7 +204,7 @@ public static Text replaceTags(Text text, boolean isTabList) { .append(Text.literal("[").withColor(custom_vip.BracketColor)) .append(Text.literal(custom_vip.Symbol).withColor(custom_vip.SymbolColor)) .append(Text.literal("]").withColor(custom_vip.BracketColor)), - true); + false); text = replaceTextInternal(text, VIP_WHOIS, Text.empty() .append(Text.literal("[").withColor(custom_vip.BracketColor)) .append(Text.literal(custom_vip.TextContent).withColor(custom_vip.TextColor)) @@ -300,7 +217,6 @@ public static Text replaceTags(Text text, boolean isTabList) { .withColor(custom_vip.SymbolColor)))) , false); } - return text; } diff --git a/src/main/java/dev/fire/config/ChatTag.java b/src/main/java/dev/fire/config/ChatTag.java index d5331d6..d0db864 100644 --- a/src/main/java/dev/fire/config/ChatTag.java +++ b/src/main/java/dev/fire/config/ChatTag.java @@ -1,18 +1,36 @@ package dev.fire.config; +import com.google.gson.JsonObject; import net.minecraft.network.message.SentMessage; -public class ChatTag { +import java.io.Serializable; +import java.util.Map; + +public class ChatTag implements Serializable { public int BracketColor; public int SymbolColor; public int TextColor; public String Symbol; public String TextContent; - public ChatTag(int bracketcolor, int symbolcolor, int textcolor, String sym, String textcontent) { - BracketColor = bracketcolor; - SymbolColor = symbolcolor; - TextColor = textcolor; - Symbol = sym; - TextContent = textcontent; + public boolean addBoldSpace; + public ChatTag(int bracketcolor, int symbolcolor, int textcolor, String sym, String textcontent, boolean addBoldSpace) { + this.BracketColor = bracketcolor; + this.SymbolColor = symbolcolor; + this.TextColor = textcolor; + this.Symbol = sym; + this.TextContent = textcontent; + this.addBoldSpace = addBoldSpace; + } + + public String toJson(){ + JsonObject object = new JsonObject(); + object.addProperty("BracketColor", BracketColor); + object.addProperty("SymbolColor", SymbolColor); + object.addProperty("TextColor", TextColor); + object.addProperty("Symbol", Symbol); + object.addProperty("TextContent", TextContent); + object.addProperty("addBoldSpace", addBoldSpace); + return object.toString(); } + } diff --git a/src/main/java/dev/fire/config/Config.java b/src/main/java/dev/fire/config/Config.java index bcb71d3..e0bc584 100644 --- a/src/main/java/dev/fire/config/Config.java +++ b/src/main/java/dev/fire/config/Config.java @@ -1,25 +1,18 @@ package dev.fire.config; -import com.google.gson.JsonObject; +import com.google.gson.*; import dev.fire.DFrevert; import dev.fire.FileManager; import dev.isxander.yacl3.api.*; import dev.isxander.yacl3.api.controller.*; -import dev.isxander.yacl3.gui.controllers.cycling.EnumController; -import dev.isxander.yacl3.impl.controller.IntegerFieldControllerBuilderImpl; -import io.netty.handler.ssl.IdentityCipherSuiteFilter; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.Style; import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import dev.fire.config.DefaultConfig; -import dev.fire.config.ChatTag; import java.awt.*; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; public class Config { private static Config instance; @@ -30,99 +23,50 @@ public class Config { public boolean DisableMod = DefaultConfig.DisableMod; public boolean VipEnabled = true; - public int VipBracketColor = DefaultConfig.Vip.BracketColor; - public int VipSymbolColor = DefaultConfig.Vip.SymbolColor; - public int VipTextColor = DefaultConfig.Vip.TextColor; - public String VipSymbol = DefaultConfig.Vip.Symbol; - public String VipTextContent = DefaultConfig.Vip.TextContent; + public Map chatTags = Map.copyOf(DefaultConfig.oldChatTags); - public int OverlordBracketColor = DefaultConfig.Overlord.BracketColor; - public int OverlordSymbolColor = DefaultConfig.Overlord.SymbolColor; - public int OverlordTextColor = DefaultConfig.Overlord.TextColor; - public String OverlordSymbol = DefaultConfig.Overlord.Symbol; - public String OverlordTextContent = DefaultConfig.Overlord.TextContent; - - public int MythicBracketColor = DefaultConfig.Mythic.BracketColor; - public int MythicSymbolColor = DefaultConfig.Mythic.SymbolColor; - public int MythicTextColor = DefaultConfig.Mythic.TextColor; - public String MythicSymbol = DefaultConfig.Mythic.Symbol; - public String MythicTextContent = DefaultConfig.Mythic.TextContent; - - public int EmperorBracketColor = DefaultConfig.Emperor.BracketColor; - public int EmperorSymbolColor = DefaultConfig.Emperor.SymbolColor; - public int EmperorTextColor = DefaultConfig.Emperor.TextColor; - public String EmperorSymbol = DefaultConfig.Emperor.Symbol; - public String EmperorTextContent = DefaultConfig.Emperor.TextContent; - - public int NobleBracketColor = DefaultConfig.Noble.BracketColor; - public int NobleSymbolColor = DefaultConfig.Noble.SymbolColor; - public int NobleTextColor = DefaultConfig.Noble.TextColor; - public String NobleSymbol = DefaultConfig.Noble.Symbol; - public String NobleTextContent = DefaultConfig.Noble.TextContent; - - - - public int OwnerBracketColor = DefaultConfig.Owner.BracketColor; - public int OwnerSymbolColor = DefaultConfig.Owner.SymbolColor; - public int OwnerTextColor = DefaultConfig.Owner.TextColor; - public String OwnerSymbol = DefaultConfig.Owner.Symbol; - public String OwnerTextContent = DefaultConfig.Owner.TextContent; - - public int AdminBracketColor = DefaultConfig.Admin.BracketColor; - public int AdminSymbolColor = DefaultConfig.Admin.SymbolColor; - public int AdminTextColor = DefaultConfig.Admin.TextColor; - public String AdminSymbol = DefaultConfig.Admin.Symbol; - public String AdminTextContent = DefaultConfig.Admin.TextContent; + public Config() { } - public int DevBracketColor = DefaultConfig.Dev.BracketColor; - public int DevSymbolColor = DefaultConfig.Dev.SymbolColor; - public int DevTextColor = DefaultConfig.Dev.TextColor; - public String DevSymbol = DefaultConfig.Dev.Symbol; - public String DevTextContent = DefaultConfig.Dev.TextContent; + public static Config getConfig() { + if (instance == null) { + try { + instance = new Config(); - public int SrModBracketColor = DefaultConfig.SrMod.BracketColor; - public int SrModSymbolColor = DefaultConfig.SrMod.SymbolColor; - public int SrModTextColor = DefaultConfig.SrMod.TextColor; - public String SrModSymbol = DefaultConfig.SrMod.Symbol; - public String SrModTextContent = DefaultConfig.SrMod.TextContent; + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + JsonObject object = new JsonParser().parse(FileManager.readConfig()).getAsJsonObject(); - public int ModBracketColor = DefaultConfig.Mod.BracketColor; - public int ModSymbolColor = DefaultConfig.Mod.SymbolColor; - public int ModTextColor = DefaultConfig.Mod.TextColor; - public String ModSymbol = DefaultConfig.Mod.Symbol; - public String ModTextContent = DefaultConfig.Mod.TextContent; - public int JrModBracketColor = DefaultConfig.JrMod.BracketColor; - public int JrModSymbolColor = DefaultConfig.JrMod.SymbolColor; - public int JrModTextColor = DefaultConfig.JrMod.TextColor; - public String JrModSymbol = DefaultConfig.JrMod.Symbol; - public String JrModTextContent = DefaultConfig.JrMod.TextContent; + // create chat tags + Map chattaghashmap = new HashMap(); - public int SrHelperBracketColor = DefaultConfig.SrHelper.BracketColor; - public int SrHelperSymbolColor = DefaultConfig.SrHelper.SymbolColor; - public int SrHelperTextColor = DefaultConfig.SrHelper.TextColor; - public String SrHelperSymbol = DefaultConfig.SrHelper.Symbol; - public String SrHelperTextContent = DefaultConfig.SrHelper.TextContent; + JsonObject map_json_object = new JsonParser().parse(object.get("_JsonChatTags").getAsString()).getAsJsonObject(); - public int HelperBracketColor = DefaultConfig.Helper.BracketColor; - public int HelperSymbolColor = DefaultConfig.Helper.SymbolColor; - public int HelperTextColor = DefaultConfig.Helper.TextColor; - public String HelperSymbol = DefaultConfig.Helper.Symbol; - public String HelperTextContent = DefaultConfig.Helper.TextContent; + map_json_object.keySet().forEach(chatkey -> { + try { + JsonElement map_chat_key = map_json_object.get(chatkey); + ChatTag new_value = gson.fromJson(map_chat_key.getAsString(), ChatTag.class); + chattaghashmap.put(chatkey, new_value); + } catch (Exception exception) { + try { + throw new DfrevertException("Invalid Config!"); + } catch (DfrevertException e) { + throw new RuntimeException(e); + } + } + }); - public int JrHelperBracketColor = DefaultConfig.JrHelper.BracketColor; - public int JrHelperSymbolColor = DefaultConfig.JrHelper.SymbolColor; - public int JrHelperTextColor = DefaultConfig.JrHelper.TextColor; - public String JrHelperSymbol = DefaultConfig.JrHelper.Symbol; - public String JrHelperTextContent = DefaultConfig.JrHelper.TextContent; + Map copy_chatmap = Map.copyOf(chattaghashmap); + if (copy_chatmap.size() != DefaultConfig.newChatTags.size()) { + throw new DfrevertException("Invalid Config!"); + } + instance.chatTags = copy_chatmap; - public Config() { } + // load primitives + instance.VipEnabled = object.get("VipEnabled").getAsBoolean(); + instance.ShortenedChatTags = object.get("ShortenedChatTags").getAsBoolean(); + instance.DisableMod = object.get("DisableMod").getAsBoolean(); - public static Config getConfig() { - if (instance == null) { - try { - instance = DFrevert.gson.fromJson(FileManager.readConfig(), Config.class); } catch (Exception exception) { DFrevert.LOGGER.info("Config didn't load: " + exception); DFrevert.LOGGER.info("Making a new one."); @@ -137,40 +81,23 @@ public static void clear() { instance = null; } - private JsonObject addChatTag(JsonObject object, String name, int BracketColor, int SymbolColor, int TextColor, String Symbol, String TextContent) { - object.addProperty(name+"BracketColor", BracketColor); - object.addProperty(name+"SymbolColor", SymbolColor); - object.addProperty(name+"TextColor", TextColor); - object.addProperty(name+"Symbol", Symbol); - object.addProperty(name+"TextContent", TextContent); - return object; - } - private void save() { try { JsonObject object = new JsonObject(); - String name = ""; object.addProperty("VipEnabled", VipEnabled); + object.addProperty("ShortenedChatTags", ShortenedChatTags); + object.addProperty("DisableMod", DisableMod); - object = addChatTag(object, "Vip", VipBracketColor, VipSymbolColor, VipTextColor, VipSymbol, VipTextContent); - object = addChatTag(object, "Overlord", OverlordBracketColor, OverlordSymbolColor, OverlordTextColor, OverlordSymbol, OverlordTextContent); - object = addChatTag(object, "Mythic", MythicBracketColor, MythicSymbolColor, MythicTextColor, MythicSymbol, MythicTextContent); - object = addChatTag(object, "Emperor", EmperorBracketColor, EmperorSymbolColor, EmperorTextColor, EmperorSymbol, EmperorTextContent); - object = addChatTag(object, "Noble", NobleBracketColor, NobleSymbolColor, NobleTextColor, NobleSymbol, NobleTextContent); - - object = addChatTag(object, "Owner", OwnerBracketColor, OwnerSymbolColor, OwnerTextColor, OwnerSymbol, OwnerTextContent); - object = addChatTag(object, "Admin", AdminBracketColor, AdminSymbolColor, AdminTextColor, AdminSymbol, AdminTextContent); - object = addChatTag(object, "Dev", DevBracketColor, DevSymbolColor, DevTextColor, DevSymbol, DevTextContent); - object = addChatTag(object, "SrMod", SrModBracketColor, SrModSymbolColor, SrModTextColor, SrModSymbol, SrModTextContent); - object = addChatTag(object, "Mod", ModBracketColor, ModSymbolColor, ModTextColor, ModSymbol, ModTextContent); - object = addChatTag(object, "JrMod", JrModBracketColor, JrModSymbolColor, JrModTextColor, JrModSymbol, JrModTextContent); - object = addChatTag(object, "SrHelper", SrHelperBracketColor, SrHelperSymbolColor, SrHelperTextColor, SrHelperSymbol, SrHelperTextContent); - object = addChatTag(object, "Helper", HelperBracketColor, HelperSymbolColor, HelperTextColor, HelperSymbol, HelperTextContent); - object = addChatTag(object, "JrHelper", JrHelperBracketColor, JrHelperSymbolColor, JrHelperTextColor, JrHelperSymbol, JrHelperTextContent); - + JsonObject JsonChatTags = new JsonObject(); + for (Map.Entry entry : chatTags.entrySet()) { + String key = entry.getKey(); + ChatTag chattag = entry.getValue(); + JsonChatTags.addProperty(key, chattag.toJson()); + } + object.addProperty("_JsonChatTags", JsonChatTags.toString()); FileManager.writeConfig(object.toString()); } catch (Exception e) { @@ -179,1017 +106,301 @@ private void save() { } public YetAnotherConfigLib getLibConfig() { - return YetAnotherConfigLib.createBuilder() - .title(Text.literal("Used for narration. Could be used to render a title in the future.")) - .category(ConfigCategory.createBuilder() - .name(Text.literal("Chat Tags")) - .tooltip(Text.literal("Modify the default chat tags.")) - - // VIP - .group(OptionGroup.createBuilder() - .name(Text.literal("⭐ VIP")) - .description(OptionDescription.of(Text.literal("VIP Chat Tag"))) - - .option(Option.createBuilder(boolean.class) - .name(Text.literal("Vip Enabled")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Toggles weather the VIP tag is shown.")) - .text(Text.literal("This also affects the VIP tag and VIP founding badge in player's profiles when you /whois them.")) - .text(Text.literal("")) - .build()) - .binding( - DefaultConfig.VipEnabled, - () -> VipEnabled, - opt -> VipEnabled = opt - ) - .controller(TickBoxControllerBuilder::create) - .build()) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Vip.BracketColor), - () -> new Color(VipBracketColor), - opt -> VipBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Vip.SymbolColor), - () -> new Color(VipSymbolColor), - opt -> VipSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Vip.TextColor), - () -> new Color(VipTextColor), - opt -> VipTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the chat tag, also affects the founding badge.")) - .build()) - .binding( - DefaultConfig.Vip.Symbol, - () -> VipSymbol, - opt -> VipSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text content, this only appears in the /whois")) - .build()) - .binding( - DefaultConfig.Vip.TextContent, - () -> VipTextContent, - opt -> VipTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - - .build()) - - //Overlord - .group(OptionGroup.createBuilder() - .name(Text.literal("Overlord")) - .description(OptionDescription.of(Text.literal("Overlord Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Overlord.BracketColor), - () -> new Color(OverlordBracketColor), - opt -> OverlordBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Overlord.SymbolColor), - () -> new Color(OverlordSymbolColor), - opt -> OverlordSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Overlord.TextColor), - () -> new Color(OverlordTextColor), - opt -> OverlordTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Overlord.Symbol, - () -> OverlordSymbol, - opt -> OverlordSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Overlord.TextContent, - () -> OverlordTextContent, - opt -> OverlordTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - - .build()) - - // Mythic - .group(OptionGroup.createBuilder() - .name(Text.literal("Mythic")) - .description(OptionDescription.of(Text.literal("Mythic Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Mythic.BracketColor), - () -> new Color(MythicBracketColor), - opt -> MythicBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Mythic.SymbolColor), - () -> new Color(MythicSymbolColor), - opt -> MythicSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Mythic.TextColor), - () -> new Color(MythicTextColor), - opt -> MythicTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Mythic.Symbol, - () -> MythicSymbol, - opt -> MythicSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Mythic.TextContent, - () -> MythicTextContent, - opt -> MythicTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - - .build()) - // Emperor - .group(OptionGroup.createBuilder() - .name(Text.literal("Emperor")) - .description(OptionDescription.of(Text.literal("Emperor Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Emperor.BracketColor), - () -> new Color(EmperorBracketColor), - opt -> EmperorBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Emperor.SymbolColor), - () -> new Color(EmperorSymbolColor), - opt -> EmperorSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Emperor.TextColor), - () -> new Color(EmperorTextColor), - opt -> EmperorTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Emperor.Symbol, - () -> EmperorSymbol, - opt -> EmperorSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Emperor.TextContent, - () -> EmperorTextContent, - opt -> EmperorTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) + YetAnotherConfigLib.Builder yacl = + YetAnotherConfigLib.createBuilder() + .title(Text.literal("Used for narration. Could be used to render a title in the future.")) + .category(normalChatTags().build()) + .category(staffChatTags().build()) + .category(miscCategory().build()); + return yacl.save(this::save).build(); + } - .build()) - // Noble - .group(OptionGroup.createBuilder() - .name(Text.literal("Noble")) - .description(OptionDescription.of(Text.literal("Noble Chat Tag"))) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Noble.BracketColor), - () -> new Color(NobleBracketColor), - opt -> NobleBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Noble.SymbolColor), - () -> new Color(NobleSymbolColor), - opt -> NobleSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Noble.TextColor), - () -> new Color(NobleTextColor), - opt -> NobleTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Noble.Symbol, - () -> NobleSymbol, - opt -> NobleSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Noble.TextContent, - () -> NobleTextContent, - opt -> NobleTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) + private ConfigCategory.Builder miscCategory() { + return ConfigCategory.createBuilder() + .name(Text.literal("Misc. Toggles")) + .tooltip(Text.literal("Toggle visibility of chat tags.")) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Disable Mod")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Disables all changes this mod makes (idk why you would want this)")) .build()) + .binding( + DefaultConfig.DisableMod, + () -> DisableMod, + opt -> DisableMod = opt + ) + .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Enable Shortened Chat Tags")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Toggles weather you can see shortened chat tags while on plots.")) + .build()) + .binding( + DefaultConfig.ShortenedChatTags, + () -> ShortenedChatTags, + opt -> ShortenedChatTags = opt + ) + .controller(TickBoxControllerBuilder::create) + .build()); + } + private ConfigCategory.Builder staffChatTags() { + ConfigCategory.Builder configBuilder = ConfigCategory.createBuilder() + .name(Text.literal("Staff Chat Tags")) + .tooltip(Text.literal("Modify the Staff chat tags.")); + ArrayList staffChatTagList = new ArrayList<>(); + staffChatTagList.addAll(DefaultConfig.staffList); + staffChatTagList.forEach(key -> { + String name = DefaultConfig.newChatTags.get(key).TextContent; + if (key == "emeritus") { + name = "Emeritus"; + } + configBuilder.group(OptionGroup.createBuilder() + .name(Text.literal(name)) + .description(OptionDescription.of(Text.literal(name + " Chat Tag"))) + + .option(Option.createBuilder(Color.class) + .name(Text.literal("Bracket Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of brackets")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).BracketColor), + () -> new Color(chatTags.get(key).BracketColor), + opt -> chatTags.get(key).BracketColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Symbol Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of symbols")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).SymbolColor), + () -> new Color(chatTags.get(key).SymbolColor), + opt -> chatTags.get(key).SymbolColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Text Content Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of the main tag text")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).TextColor), + () -> new Color(chatTags.get(key).TextColor), + opt -> chatTags.get(key).TextColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(String.class) + .name(Text.literal("Symbol")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) + .build()) + .binding( + DefaultConfig.oldChatTags.get(key).Symbol, + () -> chatTags.get(key).Symbol, + opt -> chatTags.get(key).Symbol = opt + ) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.createBuilder(String.class) + .name(Text.literal("Text Content")) + .description(OptionDescription.createBuilder() + .text(Text.literal("The main text of the tag")) + .build()) + .binding( + DefaultConfig.oldChatTags.get(key).TextContent, + () -> chatTags.get(key).TextContent, + opt -> chatTags.get(key).TextContent = opt + ) + .controller(StringControllerBuilder::create) + .build()) + .build()); + }); + + return configBuilder; + } - // Staff Chat Tags -------------------------------------------------------------------------------------------- - .category(ConfigCategory.createBuilder() - .name(Text.literal("Staff Chat Tags")) - .tooltip(Text.literal("Modify the Staff chat tags.")) - - // Owner - .group(OptionGroup.createBuilder() - .name(Text.literal("Owner")) - .description(OptionDescription.of(Text.literal("Owner Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Owner.BracketColor), - () -> new Color(OwnerBracketColor), - opt -> OwnerBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Owner.SymbolColor), - () -> new Color(OwnerSymbolColor), - opt -> OwnerSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Owner.TextColor), - () -> new Color(OwnerTextColor), - opt -> OwnerTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Owner.Symbol, - () -> OwnerSymbol, - opt -> OwnerSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Owner.TextContent, - () -> OwnerTextContent, - opt -> OwnerTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - - .build()) - // Admin - .group(OptionGroup.createBuilder() - .name(Text.literal("Admin")) - .description(OptionDescription.of(Text.literal("Admin Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Admin.BracketColor), - () -> new Color(AdminBracketColor), - opt -> AdminBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Admin.SymbolColor), - () -> new Color(AdminSymbolColor), - opt -> AdminSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Admin.TextColor), - () -> new Color(AdminTextColor), - opt -> AdminTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Admin.Symbol, - () -> AdminSymbol, - opt -> AdminSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Admin.TextContent, - () -> AdminTextContent, - opt -> AdminTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - - .build()) - // Dev - .group(OptionGroup.createBuilder() - .name(Text.literal("Dev")) - .description(OptionDescription.of(Text.literal("Dev Chat Tag"))) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Dev.BracketColor), - () -> new Color(DevBracketColor), - opt -> DevBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Dev.SymbolColor), - () -> new Color(DevSymbolColor), - opt -> DevSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Dev.TextColor), - () -> new Color(DevTextColor), - opt -> DevTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Dev.Symbol, - () -> DevSymbol, - opt -> DevSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Dev.TextContent, - () -> DevTextContent, - opt -> DevTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .build()) - // SrMod - .group(OptionGroup.createBuilder() - .name(Text.literal("SrMod")) - .description(OptionDescription.of(Text.literal("SrMod Chat Tag"))) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.SrMod.BracketColor), - () -> new Color(SrModBracketColor), - opt -> SrModBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.SrMod.SymbolColor), - () -> new Color(SrModSymbolColor), - opt -> SrModSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.SrMod.TextColor), - () -> new Color(SrModTextColor), - opt -> SrModTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.SrMod.Symbol, - () -> SrModSymbol, - opt -> SrModSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.SrMod.TextContent, - () -> SrModTextContent, - opt -> SrModTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .build()) - // Mod - .group(OptionGroup.createBuilder() - .name(Text.literal("Mod")) - .description(OptionDescription.of(Text.literal("Mod Chat Tag"))) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Mod.BracketColor), - () -> new Color(ModBracketColor), - opt -> ModBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Mod.SymbolColor), - () -> new Color(ModSymbolColor), - opt -> ModSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Mod.TextColor), - () -> new Color(ModTextColor), - opt -> ModTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Mod.Symbol, - () -> ModSymbol, - opt -> ModSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Mod.TextContent, - () -> ModTextContent, - opt -> ModTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) + private ConfigCategory.Builder normalChatTags() { + ConfigCategory.Builder configBuilder = ConfigCategory.createBuilder() + .name(Text.literal("Chat Tags")) + .tooltip(Text.literal("Modify the default chat tags.")); - .build()) - // JrMod - .group(OptionGroup.createBuilder() - .name(Text.literal("JrMod")) - .description(OptionDescription.of(Text.literal("JrMod Chat Tag"))) + ArrayList normalChatTagList = new ArrayList<>(); + normalChatTagList.addAll(DefaultConfig.normalList); - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.JrMod.BracketColor), - () -> new Color(JrModBracketColor), - opt -> JrModBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.JrMod.SymbolColor), - () -> new Color(JrModSymbolColor), - opt -> JrModSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.JrMod.TextColor), - () -> new Color(JrModTextColor), - opt -> JrModTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.JrMod.Symbol, - () -> JrModSymbol, - opt -> JrModSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.JrMod.TextContent, - () -> JrModTextContent, - opt -> JrModTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) + OptionGroup vipGroup = OptionGroup.createBuilder() + .name(Text.literal("⭐ VIP")) + .description(OptionDescription.of(Text.literal("VIP Chat Tag"))) + .option(Option.createBuilder(boolean.class) + .name(Text.literal("Vip Enabled")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Toggles weather the VIP tag is shown.")) + .text(Text.literal("This also affects the VIP tag and VIP founding badge in player's profiles when you /whois them.")) + .text(Text.literal("")) .build()) - // SrHelper - .group(OptionGroup.createBuilder() - .name(Text.literal("SrHelper")) - .description(OptionDescription.of(Text.literal("SrHelper Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.SrHelper.BracketColor), - () -> new Color(SrHelperBracketColor), - opt -> SrHelperBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.SrHelper.SymbolColor), - () -> new Color(SrHelperSymbolColor), - opt -> SrHelperSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.SrHelper.TextColor), - () -> new Color(SrHelperTextColor), - opt -> SrHelperTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.SrHelper.Symbol, - () -> SrHelperSymbol, - opt -> SrHelperSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.SrHelper.TextContent, - () -> SrHelperTextContent, - opt -> SrHelperTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) + .binding( + DefaultConfig.VipEnabled, + () -> VipEnabled, + opt -> VipEnabled = opt + ) + .controller(TickBoxControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Bracket Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of brackets")) .build()) - // Helper - .group(OptionGroup.createBuilder() - .name(Text.literal("Helper")) - .description(OptionDescription.of(Text.literal("Helper Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.Helper.BracketColor), - () -> new Color(HelperBracketColor), - opt -> HelperBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.Helper.SymbolColor), - () -> new Color(HelperSymbolColor), - opt -> HelperSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.Helper.TextColor), - () -> new Color(HelperTextColor), - opt -> HelperTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.Helper.Symbol, - () -> HelperSymbol, - opt -> HelperSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.Helper.TextContent, - () -> HelperTextContent, - opt -> HelperTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - + .binding( + new Color(DefaultConfig.oldChatTags.get("vip").BracketColor), + () -> new Color(chatTags.get("vip").BracketColor), + opt -> chatTags.get("vip").BracketColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Symbol Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of symbols")) .build()) - // JrHelper - .group(OptionGroup.createBuilder() - .name(Text.literal("JrHelper")) - .description(OptionDescription.of(Text.literal("JrHelper Chat Tag"))) - - .option(Option.createBuilder(Color.class) - .name(Text.literal("Bracket Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of brackets")) - .build()) - .binding( - new Color(DefaultConfig.JrHelper.BracketColor), - () -> new Color(JrHelperBracketColor), - opt -> JrHelperBracketColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Symbol Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of symbols")) - .build()) - .binding( - new Color(DefaultConfig.JrHelper.SymbolColor), - () -> new Color(JrHelperSymbolColor), - opt -> JrHelperSymbolColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(Color.class) - .name(Text.literal("Text Content Color")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Color of the main tag text")) - .build()) - .binding( - new Color(DefaultConfig.JrHelper.TextColor), - () -> new Color(JrHelperTextColor), - opt -> JrHelperTextColor = opt.getRGB() - ) - .controller(ColorControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Symbol")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) - .build()) - .binding( - DefaultConfig.JrHelper.Symbol, - () -> JrHelperSymbol, - opt -> JrHelperSymbol = opt - ) - .controller(StringControllerBuilder::create) - .build()) - .option(Option.createBuilder(String.class) - .name(Text.literal("Text Content")) - .description(OptionDescription.createBuilder() - .text(Text.literal("The main text of the tag")) - .build()) - .binding( - DefaultConfig.JrHelper.TextContent, - () -> JrHelperTextContent, - opt -> JrHelperTextContent = opt - ) - .controller(StringControllerBuilder::create) - .build()) - + .binding( + new Color(DefaultConfig.oldChatTags.get("vip").SymbolColor), + () -> new Color(chatTags.get("vip").SymbolColor), + opt -> chatTags.get("vip").SymbolColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Text Content Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of the main tag text")) .build()) - - + .binding( + new Color(DefaultConfig.oldChatTags.get("vip").TextColor), + () -> new Color(chatTags.get("vip").TextColor), + opt -> chatTags.get("vip").TextColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) .build()) - // MISC ------------------------------------------------------------ - - .category(ConfigCategory.createBuilder() - .name(Text.literal("Misc. Toggles")) - .tooltip(Text.literal("Toggle visibility of chat tags.")) - - .option(Option.createBuilder(boolean.class) - .name(Text.literal("Disable Mod")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Disables all changes this mod makes (idk why you would want this)")) - .build()) - .binding( - DefaultConfig.DisableMod, - () -> DisableMod, - opt -> DisableMod = opt - ) - .controller(TickBoxControllerBuilder::create) + .option(Option.createBuilder(String.class) + .name(Text.literal("Symbol")) + .description(OptionDescription.createBuilder() + .text(Text.literal("The main text of the chat tag, also affects the founding badge.")) .build()) - .option(Option.createBuilder(boolean.class) - .name(Text.literal("Enable Shortened Chat Tags")) - .description(OptionDescription.createBuilder() - .text(Text.literal("Toggles weather you can see shortened chat tags while on plots.")) - .build()) - .binding( - DefaultConfig.ShortenedChatTags, - () -> ShortenedChatTags, - opt -> ShortenedChatTags = opt - ) - .controller(TickBoxControllerBuilder::create) + .binding( + DefaultConfig.oldChatTags.get("vip").Symbol, + () -> chatTags.get("vip").Symbol, + opt -> chatTags.get("vip").Symbol = opt + ) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.createBuilder(String.class) + .name(Text.literal("Text Content")) + .description(OptionDescription.createBuilder() + .text(Text.literal("The main text content, this only appears in the /whois")) .build()) - + .binding( + DefaultConfig.oldChatTags.get("vip").TextContent, + () -> chatTags.get("vip").TextContent, + opt -> chatTags.get("vip").TextContent = opt + ) + .controller(StringControllerBuilder::create) .build()) - .save(this::save) .build(); + + configBuilder.group(vipGroup); + + normalChatTagList.forEach(key -> { + String name = DefaultConfig.newChatTags.get(key).TextContent; + configBuilder.group(OptionGroup.createBuilder() + .name(Text.literal(name)) + .description(OptionDescription.of(Text.literal(name + " Chat Tag"))) + + .option(Option.createBuilder(Color.class) + .name(Text.literal("Bracket Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of brackets")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).BracketColor), + () -> new Color(chatTags.get(key).BracketColor), + opt -> chatTags.get(key).BracketColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Symbol Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of symbols")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).SymbolColor), + () -> new Color(chatTags.get(key).SymbolColor), + opt -> chatTags.get(key).SymbolColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(Color.class) + .name(Text.literal("Text Content Color")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Color of the main tag text")) + .build()) + .binding( + new Color(DefaultConfig.oldChatTags.get(key).TextColor), + () -> new Color(chatTags.get(key).TextColor), + opt -> chatTags.get(key).TextColor = opt.getRGB() + ) + .controller(ColorControllerBuilder::create) + .build()) + .option(Option.createBuilder(String.class) + .name(Text.literal("Symbol")) + .description(OptionDescription.createBuilder() + .text(Text.literal("Symbol(s) that go on the left and right side of the main text content")) + .build()) + .binding( + DefaultConfig.oldChatTags.get(key).Symbol, + () -> chatTags.get(key).Symbol, + opt -> chatTags.get(key).Symbol = opt + ) + .controller(StringControllerBuilder::create) + .build()) + .option(Option.createBuilder(String.class) + .name(Text.literal("Text Content")) + .description(OptionDescription.createBuilder() + .text(Text.literal("The main text of the tag")) + .build()) + .binding( + DefaultConfig.oldChatTags.get(key).TextContent, + () -> chatTags.get(key).TextContent, + opt -> chatTags.get(key).TextContent = opt + ) + .controller(StringControllerBuilder::create) + .build()) + .build()); + }); + + return configBuilder; } + + public enum CharSetOption { ISO_8859_1(StandardCharsets.ISO_8859_1), UTF_8(StandardCharsets.UTF_8); diff --git a/src/main/java/dev/fire/config/DefaultConfig.java b/src/main/java/dev/fire/config/DefaultConfig.java index fb93add..a3863f9 100644 --- a/src/main/java/dev/fire/config/DefaultConfig.java +++ b/src/main/java/dev/fire/config/DefaultConfig.java @@ -1,10 +1,10 @@ package dev.fire.config; +import net.minecraft.text.Text; -import java.lang.reflect.Array; -import dev.fire.config.ChatTag; -import java.util.Arrays; -import java.util.List; +import java.util.*; + +import static java.util.Map.entry; public class DefaultConfig { public static Config.CharSetOption SaveCharSet = Config.CharSetOption.UTF_8; @@ -15,23 +15,78 @@ public class DefaultConfig { public static boolean DisableMod = false; public static boolean ShortenedChatTags = true; - public static ChatTag Vip = new ChatTag(0xFFAA00,0xFFD47F,0xFFD47F,"⭐","VIP"); + public static Map oldChatTags = Map.ofEntries( + entry("vip", new ChatTag(0xFFAA00, 0xFFD47F, 0xFFD47F, "⭐","VIP", false)), + entry("overlord", new ChatTag(0x00AAAA, 0xAAAAAA, 0xAA0000, "◆", "Overlord", false)), + entry("mythic", new ChatTag(0x555555, 0x555555, 0xAA00AA, "", "Mythic", false)), + entry("emperor", new ChatTag(0x00AA00, 0x00AA00, 0x55FFFF, "", "Emperor", false)), + entry("noble", new ChatTag(0xFFAA00, 0xFFAA00, 0x55FF55, "", "Noble", false)), + + entry("owner", new ChatTag(0x000000, 0x000000, 0xFF0000, "", "Owner", false)), + entry("admin", new ChatTag(0x555555, 0x555555, 0xFF0000, "", "Admin", false)), + entry("dev", new ChatTag(0x555555, 0x555555, 0xFF7FAA, "", "Dev", false)), + entry("srmod", new ChatTag(0x808080, 0x808080, 0xAAFF55, "", "SrMod", false)), + entry("mod", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55FF55, "", "Mod", false)), + entry("jrmod", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x2AD42A, "", "JrMod", false)), + entry("srhelper", new ChatTag(0x808080, 0x808080, 0x2AFFAA, "", "SrHelper", false)), + entry("helper", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55FFFF, "", "Helper", false)), + entry("jrhelper", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55AAFF, "", "JrHelper", false)), + entry("emeritus", new ChatTag(0xFFAA00, 0xFFAA00, 0x2AD4D4, "", "Retired", false)), + entry("retired", new ChatTag(0x005555, 0x005555, 0x00AAAA, "", "Retired", false)), + entry("builder", new ChatTag(0x80552A, 0x80552A, 0xFFAA00, "", "Builder", false)) + ); + + public static Map newChatTags = Map.ofEntries( + entry("vip", new ChatTag(0xFFAA00, 0xFFD47F, 0xFFD47F, "⭐","VIP", false)), + entry("overlord", new ChatTag(0xAA002A, 0xFF7F7F, 0xFF5555, "◆", "Overlord", true)), + entry("mythic", new ChatTag(0x7F00AA, 0xFF7FD4, 0xD42AD4, "◇", "Mythic", true)), + entry("emperor", new ChatTag(0x2A70D4, 0xAAFFFF, 0x55AAFF, "◦", "Emperor", true)), + entry("noble", new ChatTag(0x00AA00, 0x00AA00, 0x7FFF7F, "", "Noble", true)), + + entry("owner", new ChatTag(0x000000, 0x000000, 0xFF0000, "", "Owner", false)), + entry("admin", new ChatTag(0x555555, 0x555555, 0xFF0000, "", "Admin", false)), + entry("dev", new ChatTag(0x555555, 0x555555, 0xFF7FAA, "", "Dev", false)), + entry("srmod", new ChatTag(0x808080, 0x808080, 0xAAFF55, "", "SrMod", false)), + entry("mod", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55FF55, "", "Mod", false)), + entry("jrmod", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x2AD42A, "", "JrMod", false)), + entry("srhelper", new ChatTag(0x808080, 0x808080, 0x2AFFAA, "", "SrHelper", false)), + entry("helper", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55FFFF, "", "Helper", false)), + entry("jrhelper", new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55AAFF, "", "JrHelper", false)), + entry("emeritus", new ChatTag(0xFFAA00, 0xFFAA00, 0x2AD4D4, "", "Retired", false)), + entry("retired", new ChatTag(0x005555, 0x005555, 0x00AAAA, "", "Retired", false)), + entry("builder", new ChatTag(0x80552A, 0x80552A, 0xFFAA00, "", "Builder", false)) + ); - public static ChatTag Overlord = new ChatTag(0x00AAAA, 0xAAAAAA, 0xAA0000, "◆", "Overlord"); - public static ChatTag Mythic = new ChatTag(0x555555, 0x555555, 0xAA00AA, "", "Mythic"); - public static ChatTag Emperor = new ChatTag(0x00AA00, 0x00AA00, 0x55FFFF, "", "Emperor"); - public static ChatTag Noble = new ChatTag(0xFFAA00, 0xFFAA00, 0x55FF55, "", "Noble"); + public static ArrayList normalList = new ArrayList(Arrays.asList( + "overlord", + "mythic", + "emperor", + "noble" + )); - public static ChatTag Owner = new ChatTag(0x000000, 0x000000, 0xFF0000, "", "Owner"); - public static ChatTag Admin = new ChatTag(0x555555, 0x555555, 0xFF0000, "", "Admin"); - public static ChatTag Dev = new ChatTag(0x555555, 0x555555, 0xFF7FAA, "", "Dev"); - public static ChatTag SrMod = new ChatTag(0x808080, 0x808080, 0xAAFF55, "", "SrMod"); - public static ChatTag Mod = new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55FF55, "", "Mod"); - public static ChatTag JrMod = new ChatTag(0xAAAAAA, 0xAAAAAA, 0x2AD42A, "", "JrMod"); - public static ChatTag SrHelper = new ChatTag(0x808080, 0x808080, 0x2AFFAA, "", "SrHelper"); - public static ChatTag Helper = new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55FFFF, "", "Helper"); - public static ChatTag JrHelper = new ChatTag(0xAAAAAA, 0xAAAAAA, 0x55AAFF, "", "JrHelper"); + public static ArrayList staffList = new ArrayList(Arrays.asList( + "emeritus", + "retired", + "builder", + "owner", + "admin", + "dev", + "srmod", + "mod", + "jrmod", + "srhelper", + "helper", + "jrhelper" + )); - public static ChatTag Retired = new ChatTag(0xFFAA00, 0xFFAA00, 0x2AD4D4, "", "Retired"); + public static Text getOldOverlord() { + ChatTag overlord = oldChatTags.get("overlord"); + return Text.empty() + .append(Text.literal("[").withColor(overlord.BracketColor)) + .append(Text.empty().append(Text.literal(overlord.Symbol).withColor(overlord.SymbolColor)) + .append(Text.literal(overlord.TextContent).withColor(overlord.TextColor)) + .append(Text.literal(overlord.Symbol).withColor(overlord.SymbolColor))) + .append(Text.literal("]").withColor(overlord.BracketColor)); + } } diff --git a/src/main/java/dev/fire/config/DfrevertException.java b/src/main/java/dev/fire/config/DfrevertException.java new file mode 100644 index 0000000..0cce6d6 --- /dev/null +++ b/src/main/java/dev/fire/config/DfrevertException.java @@ -0,0 +1,7 @@ +package dev.fire.config; + +public class DfrevertException extends Exception { + public DfrevertException(String errorMessage) { + super(errorMessage); + } +} \ No newline at end of file diff --git a/src/main/java/dev/fire/mixin/ChatHudMixin.java b/src/main/java/dev/fire/mixin/ChatHudMixin.java index 91397cf..619c249 100644 --- a/src/main/java/dev/fire/mixin/ChatHudMixin.java +++ b/src/main/java/dev/fire/mixin/ChatHudMixin.java @@ -14,7 +14,6 @@ public class ChatHudMixin { @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", at = @At("HEAD"), ordinal = 0, argsOnly = true) public Text inject(Text message) { - //DFrevert.LOGGER.info(String.valueOf(message)); return TextUtil.replaceTags(message, false); } } \ No newline at end of file