aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-13 12:43:11 +0200
committerGitHub <noreply@github.com>2024-05-13 12:43:11 +0200
commit46a27942a8881172063055dc4780da01642fb219 (patch)
tree9f61dcad8246c2647e7b016d0652078ce9e7ed0f /src/main/java/at/hannibal2/skyhanni/utils
parent4e98f4a176fb8bfe2b9c9afcdb4b941d5b721704 (diff)
downloadskyhanni-46a27942a8881172063055dc4780da01642fb219.tar.gz
skyhanni-46a27942a8881172063055dc4780da01642fb219.tar.bz2
skyhanni-46a27942a8881172063055dc4780da01642fb219.zip
Fix: wrong chat color when using hypixel command /show (#1781)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
index d1dce7fe3..728fa667b 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.chat.Text.prefix
import at.hannibal2.skyhanni.utils.chat.Text.url
import net.minecraft.client.Minecraft
import net.minecraft.util.ChatComponentText
+import net.minecraft.util.ChatStyle
import net.minecraft.util.IChatComponent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.LinkedList
@@ -268,4 +269,11 @@ object ChatUtils {
}
)
}
+
+ fun IChatComponent.changeColor(color: LorenzColor): IChatComponent {
+ chatStyle = ChatStyle().also {
+ it.color = color.toChatFormatting()
+ }
+ return this
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
index bb9ab0c03..8309a8f86 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.test.command.ErrorManager
import net.minecraft.item.EnumDyeColor
+import net.minecraft.util.EnumChatFormatting
import java.awt.Color
enum class LorenzColor(val chatColorCode: Char, private val color: Color, private val coloredLabel: String) {
@@ -62,6 +63,9 @@ enum class LorenzColor(val chatColorCode: Char, private val color: Color, privat
CHROMA -> EnumDyeColor.WHITE
}
+ fun toChatFormatting(): EnumChatFormatting? =
+ EnumChatFormatting.entries.firstOrNull { it.toString() == getChatColor() }
+
companion object {
fun EnumDyeColor.toLorenzColor() = when (this) {