diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-09-10 13:56:00 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-09-10 13:56:00 +0200 |
commit | 9e0eb60ef9f53553361d61182c99d1925547e20d (patch) | |
tree | 01019d15edda991a830fd858c2986483905c7077 | |
parent | da201d2e2bf73bf455b970d445e011c0525abae9 (diff) | |
download | skyhanni-9e0eb60ef9f53553361d61182c99d1925547e20d.tar.gz skyhanni-9e0eb60ef9f53553361d61182c99d1925547e20d.tar.bz2 skyhanni-9e0eb60ef9f53553361d61182c99d1925547e20d.zip |
Added more player chat format options (show all channel prefix, hide player rank, hide colon after player name, hide/change elite position format, channel prefix design)
8 files changed, 182 insertions, 67 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3605af845..00f5117d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Added hiding the flame particles when using the Fire Veil Wand ability - Added circle around the player when having the Fire Veil Wand ability is active - The config GUI how has a search function (top right corner) +- Added more player chat format options (show all channel prefix, hide player rank, hide colon after player name, hide/change elite position format, channel prefix design) ### Small Changes - Changed the ashfang gravity orb highlight from square to cylinder diff --git a/FEATURES.md b/FEATURES.md index 0ef26cfa1..91d0df789 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -13,9 +13,10 @@ - Many other messages (Not separated into own categories yet) ## Chat -+ Using a clean chat format for player messages (removing the rank prefix, every player writes in the same color) -+ Dungeon Filter (Removing annoying messages from in the dungeon) -+ Dungeon Boss Message hider (includes The Watcher as well) +- Options to change the player chat format (show all channel prefix, hide player rank, hide colon after player name, hide/change elite position format, channel prefix design +- Using a clean chat format for player messages (removing the rank prefix, every player writes in the same color) +- Dungeon Filter (Removing annoying messages from in the dungeon) +- Dungeon Boss Message hider (includes The Watcher as well) - Option to hide the Skyblock Level from the chat messages. - Option to change the way the Skyblock Level gets displayed in the chat (only working when skyblock level and fancy player message format are enabled) - Option to hide the death messages of other players, except for players who are close to the player, inside dungeon or during a Kuudra fight. diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index d4803d679..8688ab603 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.config.core.config.Position; import at.hannibal2.skyhanni.config.core.config.annotations.Category; import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor; import at.hannibal2.skyhanni.config.features.*; +import at.hannibal2.skyhanni.features.chat.PlayerChatFilter; import com.google.gson.annotations.Expose; import net.minecraft.client.Minecraft; @@ -84,6 +85,16 @@ public class Features extends Config { editOverlay(activeConfigCategory, 200, 16, dungeon.copilotPos); return; } + + if (runnableId.equals("testAllChat")) { + PlayerChatFilter.Companion.testAllChat(); + return; + } + + if (runnableId.equals("testGuildChat")) { + PlayerChatFilter.Companion.testGuildChat(); + return; + } } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java index b1ccc4a7c..0d34e2744 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Chat.java @@ -47,32 +47,79 @@ public class Chat { public boolean playerMessages = false; @Expose - @ConfigOption(name = "Player Messages Format", desc = "Add a fancy new chat format for player messages.") + @ConfigOption(name = "All Channel Prefix", desc = "Show the prefix for the all channel chat.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean playerMessagesFormat = false; + public boolean allChannelPrefix = false; @Expose - @ConfigOption(name = "Hide SkyBlock Level", desc = "Hiding the Skyblock Level from the chat messages") + @ConfigOption(name = "Player Rank Hider", desc = "Hide player ranks in the chat.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) - public boolean hideSkyblockLevel = false; + public boolean playerRankHider = false; + + @Expose + @ConfigOption(name = "Player Colon Hider", desc = "Hide the colon after the player name in the chat.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean playerColonHider = false; @Expose @ConfigOption( name = "SkyBlock Level Design", - desc = "Change the way the Skyblock Level gets displayed in the chat\n" + - "§cRequires SkyBlock Level and player messages format both enabled" + desc = "Change the design of the Skyblock Level in the chat.\n" + + "§cRequires 'SkyBlock Level in Chat' enabled in the SkyBlock Menu." ) @ConfigEditorDropdown( - values = {"§8[§6123§8] §bname §fmsg", - "§6§l123 §bname §fmsg", - "§bname §8[§6123§8]§f: msg"} + values = {"§8[§6123§8] §bname§f: msg", + "§6§l123 §bname§f: §fmsg", + "§bname §8[§6123§8]§f: msg", + "§cHide SkyBlock Level"} ) @ConfigAccordionId(id = 1) public int skyblockLevelDesign = 0; @Expose + @ConfigOption( + name = "Elite Design", + desc = "Change the design of the Elite position in the chat." + ) + @ConfigEditorDropdown( + values = {"§6[⌬55]", + "§6§l⌬55", + "§cHide Elite Position"} + ) + @ConfigAccordionId(id = 1) + public int eliteFormat = 0; + + @Expose + @ConfigOption( + name = "Channel Design", + desc = "Change the design of the Channel Prefix in the chat." + ) + @ConfigEditorDropdown( + values = {"§2Guild >", + "§2G>", + "§8<§2G§8>", + "§8[§2G§8]", + "§8(§2G§8)"} + ) + @ConfigAccordionId(id = 1) + public int channelDesign = 0; + + @Expose + @ConfigOption(name = "Test All Chat", desc = "Test the All Chat message format locally (no message gets sent to hypixel)") + @ConfigEditorButton(runnableId = "testAllChat") + @ConfigAccordionId(id = 1) + public boolean testAllChat = false; + + @Expose + @ConfigOption(name = "Test Guild Chat", desc = "Test the Guild Chat message format locally (no message gets sent to hypixel)") + @ConfigEditorButton(runnableId = "testGuildChat") + @ConfigAccordionId(id = 1) + public boolean testGuildChat = false; + + @Expose @ConfigOption(name = "Dungeon Filter", desc = "Hide annoying messages in the dungeon.") @ConfigEditorBoolean public boolean dungeonMessages = false; diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt index 2b051add9..88193de67 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.features.chat.PlayerMessageChannel class PlayerSendChatEvent( val channel: PlayerMessageChannel, - val playerName: String, + val formattedName: String, var message: String, var cancelledReason: String = "", ) : LorenzEvent()
\ No newline at end of file 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 a6b5e0bf9..3e24b1130 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerChatFilter.kt @@ -6,6 +6,8 @@ import at.hannibal2.skyhanni.events.PlayerSendChatEvent import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraft.client.Minecraft +import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern @@ -13,6 +15,9 @@ class PlayerChatFilter { private val loggerPlayerChat = LorenzLogger("chat/player") + //§6[⌬57] §r§8[§r§b235§r§8] §r§6[MVP§r§c++§r§6] hannibal2§r§f: Hello World! + private val patternElitePrefix = Pattern.compile("§6\\[⌬(\\d+)] (.+)") + //§8[§9109§8] §b[MVP§c+§b] 4Apex§f§r§f: omg selling private val patternSkyBlockLevel = Pattern.compile("§8\\[§(.)(\\d+)§8] (.+)") @@ -34,9 +39,25 @@ class PlayerChatFilter { //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() + val matcherElite = patternElitePrefix.matcher(rawMessage) + val elitePrefix = if (matcherElite.matches()) { + val elitePosition = matcherElite.group(1).toInt() + rawMessage = matcherElite.group(2) + when (SkyHanniMod.feature.chat.eliteFormat) { + 0 -> "§6[⌬$elitePosition]" + 1 -> "§6§l⌬$elitePosition" + 2 -> "" + else -> "" + } + } else { + "" + } + SkyBlockLevelChatMessage.elitePrefix = elitePrefix + val matcher = patternSkyBlockLevel.matcher(rawMessage) if (matcher.matches()) { - SkyBlockLevelChatMessage.setData(matcher.group(2).toInt(), matcher.group(1)) + SkyBlockLevelChatMessage.levelColor = matcher.group(1) + SkyBlockLevelChatMessage.level = matcher.group(2).toInt() rawMessage = matcher.group(3) } @@ -54,21 +75,12 @@ class PlayerChatFilter { rawName = rawName.substring(channel.originalPrefix.length) val name = grabName(rawName) ?: return false - if (!SkyHanniMod.feature.chat.playerMessagesFormat) { - if (SkyHanniMod.feature.chat.hideSkyblockLevel) { - LorenzUtils.chat(rawMessage) - return true - } - return false - } - val message = split[1] - send(channel, name.removeColor(), message.removeColor()) + send(channel, name, message.removeColor(), if (elitePrefix != "") " $elitePrefix" else elitePrefix) 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 @@ -77,52 +89,89 @@ class PlayerChatFilter { val name = grabName(rawName) ?: return false val message = matcher.group(3) - LorenzUtils.chat("§d$direction §b$name §f$message") + val colon = if (SkyHanniMod.feature.chat.playerColonHider) "" else ":" + LorenzUtils.chat("§d$direction $name§f$colon $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 + .find { it != PlayerMessageChannel.ALL && name.startsWith(it.originalPrefix) } + ?: PlayerMessageChannel.ALL } private fun grabName(rawName: String): String? { val nameSplit = rawName.split(" ") val last = nameSplit.last() - val name = if (last.endsWith("]")) { + val cleanName = if (last.endsWith("]")) { nameSplit[nameSplit.size - 2] } else { last } val first = nameSplit[0] - if (first != name) { + if (first != cleanName) { if (!first.contains("VIP") && !first.contains("MVP")) { //TODO support yt + admin return null } } - - return name + return if (SkyHanniMod.feature.chat.playerRankHider) { + "§b$cleanName" + } else { + rawName + } } - private fun send(channel: PlayerMessageChannel, name: String, message: String) { - loggerPlayerChat.log("[$channel] $name: $message") + private fun send(channel: PlayerMessageChannel, name: String, message: String, elitePrefix: String) { + loggerPlayerChat.log("[$channel] ${name.removeColor()}: $message") val event = PlayerSendChatEvent(channel, name, message) event.postAndCatch() if (event.cancelledReason != "") { loggerPlayerChat.log("cancelled: " + event.cancelledReason) - } else { - val finalMessage = event.message - if (finalMessage != message) { - loggerPlayerChat.log("message changed: $finalMessage") - } + return + } - val prefix = channel.prefix - LorenzUtils.chat("$prefix §b$name §f$finalMessage") + val finalMessage = event.message + if (finalMessage != message) { + loggerPlayerChat.log("message changed: $finalMessage") } + + val prefix = if (channel == PlayerMessageChannel.ALL && !SkyHanniMod.feature.chat.allChannelPrefix) + "" else getChannelPrefix(channel) + + val colon = if (SkyHanniMod.feature.chat.playerColonHider) "" else ":" + LorenzUtils.chat("$prefix$elitePrefix $name§f$colon $finalMessage") } + companion object { + + fun getChannelPrefix(channel: PlayerMessageChannel): String { + val color = channel.prefixColor + val small = channel.prefixSmall + val large = channel.prefixLarge + return when (SkyHanniMod.feature.chat.channelDesign) { + 0 -> "$color$large §8>" + 1 -> "$color$small>" + 2 -> "§8<$color$small§8>" + 3 -> "§8[$color$small§8]" + 4 -> "§8($color$small§8)" + else -> "$color$large §8>" + } + } + + fun testAllChat() { + val name = Minecraft.getMinecraft().thePlayer.name + val message = "§6[⌬499] §8[§b123§8] §6[MVP§c++§6] $name§f: This is a all chat test message and will not be sent to hypixel." + LorenzChatEvent(message, ChatComponentText(message)).postAndCatch() + } + + fun testGuildChat() { + val name = Minecraft.getMinecraft().thePlayer.name + val message = "§2Guild > §6[MVP§f++§6] $name §2[GuildRank]§f: This is a guild chat test message and will not be sent to hypixel." + LorenzChatEvent(message, ChatComponentText(message)).postAndCatch() + } + } }
\ No newline at end of file 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 593e592ed..cef380628 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerMessageChannel.kt @@ -1,12 +1,17 @@ package at.hannibal2.skyhanni.features.chat -enum class PlayerMessageChannel(val prefix: String, val originalPrefix: String) { +enum class PlayerMessageChannel( + val prefixColor: String, + val prefixSmall: String, + val prefixLarge: 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("§f", "A", "", ""), + ALL_GUESTING("§a", "g", "Guest", "§a[✌] "), + ALL_DUNGEON_DEAD("§7", "D", "Dead", "§7[GHOST] "), + PARTY("§9", "P", "Party", "§9Party §8> "), + GUILD("§2", "G", "Guild", "§2Guild > "), + COOP("§b", "CC", "Co-op", "§bCo-op > "), }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/SkyBlockLevelChatMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/SkyBlockLevelChatMessage.kt index deacc0de6..7133a2e9b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/SkyBlockLevelChatMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/SkyBlockLevelChatMessage.kt @@ -10,11 +10,7 @@ class SkyBlockLevelChatMessage { companion object { var level = -1 var levelColor = "" - - fun setData(level: Int, levelColor: String) { - this.level = level - this.levelColor = levelColor - } + var elitePrefix = "" } @SubscribeEvent @@ -22,26 +18,31 @@ class SkyBlockLevelChatMessage { if (level == -1) return event.cancelledReason = "skyblock level" - val finalMessage = event.message - val name = event.playerName - val prefix = event.channel.prefix + val message = event.message + val name = event.formattedName + var prefix = if (event.channel == PlayerMessageChannel.ALL && !SkyHanniMod.feature.chat.allChannelPrefix) + "" else PlayerChatFilter.getChannelPrefix(event.channel) - if (SkyHanniMod.feature.chat.hideSkyblockLevel) { - LorenzUtils.chat("$prefix §b$name §f$finalMessage") - } else { + if (elitePrefix != "") { + prefix = "$prefix $elitePrefix".trim() + } + val colon = if (SkyHanniMod.feature.chat.playerColonHider) "" else ":" - when (SkyHanniMod.feature.chat.skyblockLevelDesign) { - 0 -> { - LorenzUtils.chat("$prefix §8[§${levelColor}${level}§8] §b$name §f$finalMessage") - } + when (SkyHanniMod.feature.chat.skyblockLevelDesign) { + 0 -> { + LorenzUtils.chat("$prefix §8[§$levelColor$level§8] $name§f$colon $message") + } - 1 -> { - LorenzUtils.chat("$prefix §${levelColor}§l${level} §b$name §f$finalMessage") - } + 1 -> { + LorenzUtils.chat("$prefix §$levelColor§l$level $name§f$colon $message") + } + + 2 -> { + LorenzUtils.chat("$prefix $name §8[§$levelColor$level§8]§f$colon $message") + } - 2 -> { - LorenzUtils.chat("$prefix §b$name §8[§${levelColor}${level}§8]§f: $finalMessage") - } + 3 -> { + LorenzUtils.chat("$prefix $name§f$colon $message") } } level = -1 |