aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
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
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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt4
3 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt
index 035a166bb..b5108c6ac 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt
@@ -13,8 +13,10 @@ import at.hannibal2.skyhanni.features.bingo.BingoAPI
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList
+import at.hannibal2.skyhanni.utils.ChatUtils.changeColor
import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.matchStyledMatcher
import at.hannibal2.skyhanni.utils.ComponentSpan
+import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.applyFormattingFrom
@@ -140,7 +142,10 @@ class PlayerNameFormatter {
level = event.levelComponent
)
)
- appendSibling(event.action.intoComponent())
+
+ appendText(" ")
+ appendSibling(event.action.intoComponent().changeColor(LorenzColor.GRAY))
+
appendText(" ")
appendSibling(event.item.intoComponent())
}) ?: return
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) {