From 5b2a2d067e68d500bd1c19088dae9e624eeae51f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 3 May 2024 14:52:59 +0200 Subject: fix color in /translate --- .../at/hannibal2/skyhanni/features/chat/Translator.kt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/Translator.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/Translator.kt index 8e61f4b6c..e513871fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/Translator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/Translator.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.getPlayerNameFromChatMessage +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.JsonArray import kotlinx.coroutines.launch import net.minecraft.event.ClickEvent @@ -42,18 +43,9 @@ class Translator { } private fun createClickStyle(message: String, style: ChatStyle): ChatStyle { - style.setChatClickEvent( - ClickEvent( - ClickEvent.Action.RUN_COMMAND, - "/shtranslate ${messageContentRegex.find(message)!!.groupValues[1]}" - ) - ) - style.setChatHoverEvent( - HoverEvent( - HoverEvent.Action.SHOW_TEXT, - ChatComponentText("§bClick to translate!") - ) - ) + val text = messageContentRegex.find(message)!!.groupValues[1].removeColor() + style.setChatClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND, "/shtranslate $text")) + style.setChatHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("§bClick to translate!"))) return style } @@ -135,7 +127,7 @@ class Translator { } fun toEnglish(args: Array) { - val message = args.joinToString(" ") + val message = args.joinToString(" ").removeColor() coroutineScope.launch { val translation = getTranslationToEnglish(message) -- cgit