aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/chat
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-09-08 19:32:27 +0200
committerLorenz <lo.scherf@gmail.com>2022-09-08 19:32:27 +0200
commit4eea94b0459760053819ddae136e7db109aea464 (patch)
treee519cef2dad7496cb6091175aa4b3ce2a79fe93a /src/main/java/at/hannibal2/skyhanni/features/chat
parent63d23eff40d6014a5014d8bef85560af38cf39b0 (diff)
downloadskyhanni-4eea94b0459760053819ddae136e7db109aea464.tar.gz
skyhanni-4eea94b0459760053819ddae136e7db109aea464.tar.bz2
skyhanni-4eea94b0459760053819ddae136e7db109aea464.zip
Added msg support to fancy chat format.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt
index a96997ba6..a6b5e0bf9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt
@@ -16,6 +16,9 @@ class PlayerChatFilter {
//§8[§9109§8] §b[MVP§c+§b] 4Apex§f§r§f: omg selling
private val patternSkyBlockLevel = Pattern.compile("§8\\[§(.)(\\d+)§8] (.+)")
+ //§dTo §r§b[MVP§r§3+§r§b] Skyfall55§r§7: §r§7hello :)
+ var patternPrivateMessage: Pattern = Pattern.compile("§d(To|From) §r(.+)§r§7: §r§7(.+)")
+
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (!LorenzUtils.isOnHypixel) return
@@ -26,6 +29,8 @@ class PlayerChatFilter {
}
private fun shouldBlock(originalMessage: String): Boolean {
+ if (handlePrivateMessage(originalMessage)) return true
+
//since hypixel sends own chat messages really weird " §r§8[§r§d205§r§8] §r§6[MVP§r§c++§r§6] hannibal2"
var rawMessage = originalMessage.replace("§r", "").trim()
@@ -62,6 +67,21 @@ class PlayerChatFilter {
return true
}
+ private fun handlePrivateMessage(originalMessage: String): Boolean {
+ if (!SkyHanniMod.feature.chat.playerMessagesFormat) return false
+
+ val matcher = patternPrivateMessage.matcher(originalMessage)
+ if (!matcher.matches()) return false
+ val direction = matcher.group(1)
+ val rawName = matcher.group(2)
+ val name = grabName(rawName) ?: return false
+
+ val message = matcher.group(3)
+ LorenzUtils.chat("§d$direction §b$name §f$message")
+ loggerPlayerChat.log("[Msg_$direction] $name: $message")
+ return true
+ }
+
private fun grabChannel(name: String): PlayerMessageChannel {
return PlayerMessageChannel.values()
.find { it != PlayerMessageChannel.ALL && name.startsWith(it.originalPrefix) } ?: PlayerMessageChannel.ALL