From 1d61933a29785f873a04a93f6c32e9570e13dfc6 Mon Sep 17 00:00:00 2001 From: Zickles <76439587+Zickles@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:11:36 -0400 Subject: Improvement: Add event level up message to chat filter (#1214) --- .../config/features/chat/FilterTypesConfig.java | 6 ++++++ .../hannibal2/skyhanni/features/chat/ChatFilter.kt | 21 +++++++++++++-------- .../java/at/hannibal2/skyhanni/utils/StringUtils.kt | 3 +++ 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java index d8f930423..503be4347 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java @@ -80,6 +80,12 @@ public class FilterTypesConfig { @FeatureToggle public boolean fireSale = true; + @Expose + @ConfigOption(name = "Event Level Up", desc = "Hide the message that shows on event level up.") + @ConfigEditorBoolean + @FeatureToggle + public boolean eventLevelUp = false; + @Expose @ConfigOption(name = "Diana", desc = "Hide chat messages around griffin burrow chains and griffin feather drops and coin drops.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt index 7ba5102bc..c0764c247 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpaceAndResets @@ -343,6 +344,11 @@ class ChatFilter { "§c♨ §r§eFire Sales? for .* §r§eended!".toPattern(), "§c {3}♨ §eAnd \\d+ more!".toPattern(), ) + private val eventPatterns = listOf( + "§r§7You are now §r§.Event Level §r§.*§r§7!".toPattern(), + "§r§7You earned §r§.* Event Silver§r§7!".toPattern(), + "§r§.§k#§r§. LEVEL UP! §r§.§k#".toPattern(), + ) private val powderMiningMessages = listOf( "§aYou uncovered a treasure chest!", "§aYou received §r§f1 §r§aWishing Compass§r§a.", @@ -356,6 +362,9 @@ class ChatFilter { "§6§k§lA§r §c§lFIRE SALE §r§6§k§lA", "§c♨ §eSelling multiple items for a limited time!", ) + private val eventMessage = listOf( + "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", + ) private val patternsMap: Map> = mapOf( "lobby" to lobbyPatterns, @@ -372,6 +381,7 @@ class ChatFilter { "winter_gift" to winterGiftPatterns, "powder_mining" to powderMiningPatterns, "fire_sale" to fireSalePatterns, + "event" to eventPatterns, ) private val messagesMap: Map> = mapOf( @@ -389,6 +399,7 @@ class ChatFilter { "annoying_spam" to annoyingSpamMessages, "powder_mining" to powderMiningMessages, "fire_sale" to fireSaleMessages, + "event" to eventMessage, ) private val messagesContainsMap: Map> = mapOf( "lobby" to lobbyMessagesContains, @@ -414,7 +425,7 @@ class ChatFilter { */ private fun block(message: String): String = when { config.hypixelHub && message.isPresent("lobby") -> "lobby" - config.empty && isEmpty(message) -> "empty" + config.empty && StringUtils.isEmpty(message) -> "empty" config.warping && message.isPresent("warping") -> "warping" config.welcome && message.isPresent("welcome") -> "welcome" config.guildExp && message.isPresent("guild_exp") -> "guild_exp" @@ -425,6 +436,7 @@ class ChatFilter { config.winterGift && message.isPresent("winter_gift") -> "winter_gift" config.powderMining && message.isPresent("powder_mining") -> "powder_mining" + config.eventLevelUp && (message.isPresent("event") || StringUtils.isEmpty(message)) -> "event" config.fireSale && (fireSalePattern.matches(message) || message.isPresent("fire_sale")) -> "fire_sale" generalConfig.hideJacob && !GardenAPI.inGarden() && anitaFortunePattern.matches(message) -> "jacob_event" generalConfig.hideSkyMall && !LorenzUtils.inMiningIsland() && skymallPerkPattern.matches(message) -> "skymall" @@ -432,13 +444,6 @@ class ChatFilter { else -> "" } - /** - * Checks if the message is an empty message - * @param message The message to check - * @return True if the message is empty - */ - private fun isEmpty(message: String) = message.removeColor().trimWhiteSpaceAndResets().isEmpty() - private var othersMsg = "" /** diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index c8863fcea..bede93187 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -307,4 +307,7 @@ object StringUtils { fun String.isRoman(): Boolean { return UtilsPatterns.isRomanPattern.matches(this) } + fun isEmpty(message: String): Boolean { + return message.removeColor().trimWhiteSpaceAndResets().isEmpty() + } } -- cgit