diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-09-08 19:32:27 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-09-08 19:32:27 +0200 |
commit | 4eea94b0459760053819ddae136e7db109aea464 (patch) | |
tree | e519cef2dad7496cb6091175aa4b3ce2a79fe93a /src/main/java/at/hannibal2/skyhanni/features | |
parent | 63d23eff40d6014a5014d8bef85560af38cf39b0 (diff) | |
download | skyhanni-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')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt | 20 |
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 |