summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-03 17:25:52 +0200
committerGitHub <noreply@github.com>2024-05-03 17:25:52 +0200
commit323cd55125f1485c71c49568aa919e5311c6263f (patch)
treec4c246921fad48623fb81b769ee78f5fa1873993 /src/main/java/at/hannibal2/skyhanni/features
parent5b2a2d067e68d500bd1c19088dae9e624eeae51f (diff)
downloadskyhanni-323cd55125f1485c71c49568aa919e5311c6263f.tar.gz
skyhanni-323cd55125f1485c71c49568aa919e5311c6263f.tar.bz2
skyhanni-323cd55125f1485c71c49568aa919e5311c6263f.zip
Add hover/click events back to custom chat messages (#1516)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt
index 024835aeb..cb6f68c4d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.chat.playerchat
import at.hannibal2.skyhanni.data.jsonobjects.repo.PlayerChatFilterJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.MultiFilter
+import net.minecraft.util.IChatComponent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PlayerChatFilter {
@@ -11,8 +12,8 @@ class PlayerChatFilter {
private val filters = mutableMapOf<String, MultiFilter>()
- fun shouldChatFilter(original: String): Boolean {
- val message = original.lowercase()
+ fun shouldChatFilter(original: IChatComponent): Boolean {
+ val message = original.formattedText.lowercase()
for (filter in filters) {
filter.value.matchResult(message)?.let {
return true
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 4aabeaf6c..2fbb9630e 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
@@ -5,6 +5,7 @@ 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
+import net.minecraft.util.ChatComponentText
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class PlayerChatModifier {
@@ -21,7 +22,7 @@ class PlayerChatModifier {
fun onChat(event: SystemMessageEvent) {
val newMessage = cutMessage(event.chatComponent.formattedText)
- event.chatComponent = StringUtils.replaceIfNeeded(event.chatComponent, newMessage) ?: return
+ event.chatComponent = StringUtils.replaceIfNeeded(event.chatComponent, ChatComponentText(newMessage)) ?: return
}
private fun cutMessage(input: String): String {