summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
diff options
context:
space:
mode:
authorMikecraft1224 <85994411+Mikecraft1224@users.noreply.github.com>2024-05-08 21:12:47 +0200
committerGitHub <noreply@github.com>2024-05-08 21:12:47 +0200
commitbd117b2d181a6abb419021f815e4ad07cc05a37f (patch)
tree4beae077201fd4edfc75ad7df73a5ae95edaf8b0 /src/main/java/at/hannibal2/skyhanni/features/chat
parentf3bad6b63b3c4efbf3088d58b9f83944949ba367 (diff)
downloadskyhanni-bd117b2d181a6abb419021f815e4ad07cc05a37f.tar.gz
skyhanni-bd117b2d181a6abb419021f815e4ad07cc05a37f.tar.bz2
skyhanni-bd117b2d181a6abb419021f815e4ad07cc05a37f.zip
Feature: Replace Roman Numerals with Arabic Numerals (#1722)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt
index e2a4f779c..52e95b3a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
+import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible
import net.minecraft.event.ClickEvent
import net.minecraft.event.HoverEvent
import net.minecraft.util.ChatComponentText
@@ -22,28 +23,7 @@ class PlayerChatModifier {
@SubscribeEvent
fun onChat(event: SystemMessageEvent) {
- val original = event.chatComponent.formattedText
- val new = cutMessage(original)
- if (new == original) return
-
- val clickEvents = mutableListOf<ClickEvent>()
- val hoverEvents = mutableListOf<HoverEvent>()
- findClickableTexts(event.chatComponent, clickEvents)
- findHoverTexts(event.chatComponent, hoverEvents)
- val clickSize = clickEvents.size
- val hoverSize = hoverEvents.size
-
- // do not change the message if more than one hover or click is found
- if (clickSize > 1 || hoverSize > 1) return
-
- val text = ChatComponentText(new)
- if (clickSize == 1) {
- text.chatStyle.chatClickEvent = clickEvents.first()
- }
- if (hoverSize == 1) {
- text.chatStyle.chatHoverEvent = hoverEvents.first()
- }
- event.chatComponent = text
+ event.applyIfPossible { cutMessage(it) }
}
private fun findClickableTexts(chatComponent: IChatComponent, clickEvents: MutableList<ClickEvent>) {