diff options
author | Zickles <76439587+Zickles@users.noreply.github.com> | 2024-03-21 15:11:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-21 20:11:36 +0100 |
commit | 1d61933a29785f873a04a93f6c32e9570e13dfc6 (patch) | |
tree | 06ba68e24264b0a5176f9c3ecee65b9dd9aeb558 /src | |
parent | 183330cffcced59da0bc3f317706b2d054b4ca44 (diff) | |
download | skyhanni-1d61933a29785f873a04a93f6c32e9570e13dfc6.tar.gz skyhanni-1d61933a29785f873a04a93f6c32e9570e13dfc6.tar.bz2 skyhanni-1d61933a29785f873a04a93f6c32e9570e13dfc6.zip |
Improvement: Add event level up message to chat filter (#1214)
Diffstat (limited to 'src')
3 files changed, 22 insertions, 8 deletions
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 @@ -81,6 +81,12 @@ public class FilterTypesConfig { 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 @FeatureToggle 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<String, List<Pattern>> = 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<String, List<String>> = 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<String, List<String>> = 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() + } } |