refactor: use the built-in adventure LegacyComponentSerializer extractUrls in the serializer builder

still does not fix `&d` leaking and breaking the click event and shit
This commit is contained in:
ChomeNS
2025-04-10 13:41:20 +07:00
parent 29ca22101a
commit 7cd77fe850
6 changed files with 43 additions and 62 deletions

View File

@@ -6,12 +6,11 @@ import me.chayapak1.chomens_bot.command.CommandContext;
import me.chayapak1.chomens_bot.command.CommandException;
import me.chayapak1.chomens_bot.command.TrustLevel;
import me.chayapak1.chomens_bot.data.chat.ChatPacketType;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import me.chayapak1.chomens_bot.util.ChatMessageUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.List;
@@ -53,9 +52,7 @@ public class NetMessageCommand extends Command {
final String rawMessage = context.getString(true, true);
final Component stylizedMessage = LegacyComponentSerializer.legacyAmpersand()
.deserialize(rawMessage)
.replaceText(ComponentUtilities.URL_REPLACEMENT_CONFIG);
final Component stylizedMessage = ChatMessageUtilities.applyChatMessageStyling(rawMessage);
final Component component = Component.translatable(
"[%s]%s%s%s %s",