diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-08-18 10:04:18 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-08-18 10:04:18 +0200 |
commit | 2f78bd32d9bebd216581d61dcdc53bd6adcea13a (patch) | |
tree | 356ed346cd5f72931f9219e2112df84f50610a01 | |
parent | ab5987a3929378e5118f409ea7df014fd70cbdf2 (diff) | |
download | skyhanni-2f78bd32d9bebd216581d61dcdc53bd6adcea13a.tar.gz skyhanni-2f78bd32d9bebd216581d61dcdc53bd6adcea13a.tar.bz2 skyhanni-2f78bd32d9bebd216581d61dcdc53bd6adcea13a.zip |
adding dungeon dead and other island spectator chat format
3 files changed, 28 insertions, 29 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt index 1776b2bd0..49f56bdb4 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.features.chat.PlayerMessageChannel - class PlayerSendChatEvent( val channel: PlayerMessageChannel, val playerName: String, 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 1a1047501..f1cef1ed8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt @@ -10,6 +10,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PlayerChatFilter { + private val loggerPlayerChat = LorenzLogger("chat/player") + @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { if (!LorenzUtils.isOnHypixel) return @@ -20,10 +22,8 @@ class PlayerChatFilter { } } - val loggerPlayerChat = LorenzLogger("chat/player") - - fun shouldBlock(originalMessage: String): Boolean { - val split: List<String> = if (originalMessage.contains("§7§r§7: ")) { + private fun shouldBlock(originalMessage: String): Boolean { + val split = if (originalMessage.contains("§7§r§7: ")) { originalMessage.split("§7§r§7: ") } else if (originalMessage.contains("§f: ")) { originalMessage.split("§f: ") @@ -32,25 +32,23 @@ class PlayerChatFilter { } var rawName = split[0] + val channel = grabChannel(rawName) + + rawName = rawName.substring(channel.originalPrefix.length) + val name = grabName(rawName) ?: return false + val message = split[1] + send(channel, name.removeColor(), message.removeColor()) + return true + } - val channel: PlayerMessageChannel - if (rawName.startsWith("§9Party §8> ")) { - channel = PlayerMessageChannel.PARTY - rawName = rawName.substring(12) - } else if (rawName.startsWith("§2Guild > ")) { - channel = PlayerMessageChannel.GUILD - rawName = rawName.substring(10) - } else if (rawName.startsWith("§bCo-op > ")) { - channel = PlayerMessageChannel.COOP - rawName = rawName.substring(10) - } else { - channel = PlayerMessageChannel.ALL - } + private fun grabChannel(name: String): PlayerMessageChannel { + return PlayerMessageChannel.values() + .find { it != PlayerMessageChannel.ALL && name.startsWith(it.originalPrefix) } ?: PlayerMessageChannel.ALL + } + private fun grabName(rawName: String): String? { val nameSplit = rawName.split(" ") - val first = nameSplit[0] - val last = nameSplit.last() val name = if (last.endsWith("]")) { nameSplit[nameSplit.size - 2] @@ -58,15 +56,15 @@ class PlayerChatFilter { last } + val first = nameSplit[0] if (first != name) { if (!first.contains("VIP") && !first.contains("MVP")) { //TODO support yt + admin - return false + return null } } - send(channel, name.removeColor(), message.removeColor()) - return true + return name } private fun send(channel: PlayerMessageChannel, name: String, message: String) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt index 7d65f47ce..593e592ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt @@ -1,10 +1,12 @@ package at.hannibal2.skyhanni.features.chat -enum class PlayerMessageChannel(val prefix: String) { +enum class PlayerMessageChannel(val prefix: String, val originalPrefix: String) { + + ALL("§fA>", ""), + ALL_GUESTING("§aA>", "§a[✌] "), + ALL_DUNGEON_DEAD("§7A>", "§7[GHOST] "), + PARTY("§9P>", "§9Party §8> "), + GUILD("§2G>", "§2Guild > "), + COOP("§bCC>", "§bCo-op > "), - ALL("§fA>"), - ALL_ADVERTISEMENT("§8A>"), - PARTY("§9P>"), - GUILD("§2G>"), - COOP("§bCC>"), }
\ No newline at end of file |