Skip to content

Commit

Permalink
fix: Fix chat translator removing colors from messages
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed Dec 3, 2023
1 parent a1bc7ed commit 9db34b6
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/
package com.xpdustry.imperium.mindustry.chat

import arc.util.Strings
import com.xpdustry.imperium.common.application.ImperiumApplication
import com.xpdustry.imperium.common.config.ImperiumConfig
import com.xpdustry.imperium.common.inject.InstanceManager
import com.xpdustry.imperium.common.inject.get
import com.xpdustry.imperium.common.misc.LoggerDelegate
import com.xpdustry.imperium.common.misc.stripMindustryColors
import com.xpdustry.imperium.common.translator.Translator
import com.xpdustry.imperium.common.translator.TranslatorResult
import com.xpdustry.imperium.common.user.User
Expand All @@ -47,7 +47,7 @@ class ChatTranslatorListener(instances: InstanceManager) : ImperiumApplication.L

val sourceLocale = sender?.let(Players::getLocale) ?: config.language
val targetLocale = target?.let(Players::getLocale) ?: config.language
val rawMessage = Strings.stripColors(message)
val rawMessage = message.stripMindustryColors()

val result =
withTimeoutOrNull(3000L) {
Expand Down Expand Up @@ -77,7 +77,7 @@ class ChatTranslatorListener(instances: InstanceManager) : ImperiumApplication.L
is TranslatorResult.Success -> {
return@register if (rawMessage.lowercase(sourceLocale) ==
result.text.lowercase(targetLocale))
rawMessage
message
else "$message [lightgray](${result.text})"
}
}
Expand Down

0 comments on commit 9db34b6

Please sign in to comment.