diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt index 814de64ef811..6aed78beba2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -20,18 +21,42 @@ class CompactBingoChat { private var newArea = 0 // 0 = nothing, 1 = after first message, 2 = after second message private val patternGroup = RepoPattern.group("bingo.compactchat") - private val healthPattern by patternGroup.pattern( - "health", - " {3}§r§7§8\\+§a.* §c❤ Health" - ) - private val strengthPattern by patternGroup.pattern( - "strength", - " {3}§r§7§8\\+§a. §c❁ Strength" - ) private val borderPattern by patternGroup.pattern( "border", "§[e3]§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬" ) + private val inSkyblockPattern by patternGroup.pattern( + "inskyblock", + "(^\\s{3}§r§7§8\\+§a. §c❁ Strength\\s*$)|(^\\s{3}§r§7§8\\+§a.* §c❤ Health\\s*$)|(^ {3}§r§7§bAccess to Community Shop\\s*$)|(^ {3}§r§7§8\\+§aAuto-pickup block and mob drops\\s*$)|(^ §r§7§6Access to Bazaar\\s*$)|(^ §r§a§lREWARDS\\s*$)\n" + ) + private val skillLevelUpPattern by patternGroup.pattern( + "skilllevelup", + " {2}§r§b§lSKILL LEVEL UP.*" + ) + private val tradeRecipePattern by patternGroup.pattern( + "traderecipe", + "Trade|Recipe" + ) + private val enchantPattern by patternGroup.pattern( + "enchant", + "Access to.* Enchantment\$" + ) + private val collectionLevelUpPattern by patternGroup.pattern( + "collection", + " {2}§r§6§lCOLLECTION LEVEL UP.*" + ) + private val skyblockLevelUpPattern by patternGroup.pattern( + "enchant", + " {2}§r§3§lSKYBLOCK LEVEL UP §bLevel.*" + ) + private val newAreaDiscoverdPattern by patternGroup.pattern( + "newareadiscovered", + " §r§6§lNEW AREA DISCOVERED!" + ) + private val newAreaPattern by patternGroup.pattern( + "newarea", + "^(§7\\s*■\\s*§r|\\s*§r.*)" + ) @SubscribeEvent fun onChat(event: LorenzChatEvent) { @@ -57,12 +82,13 @@ class CompactBingoChat { // TODO USE SH-REPO private fun onSkillLevelUp(message: String): Boolean { - if (message.startsWith(" §r§b§lSKILL LEVEL UP ")) { + if (skillLevelUpPattern.matches(message)) { inSkillLevelUp = true return false } - if (inSkillLevelUp && !message.contains("Access to") && !message.endsWith(" Enchantment")) { + + if (inSkillLevelUp && !enchantPattern.matches(message)) { return true } @@ -70,41 +96,26 @@ class CompactBingoChat { } private fun onSkyBlockLevelUp(message: String): Boolean { - if (message.startsWith(" §r§3§lSKYBLOCK LEVEL UP §bLevel ")) { + if (skyblockLevelUpPattern.matches(message)) { inSkyBlockLevelUp = true return false } - if (inSkyBlockLevelUp) { - if (message == " §r§a§lREWARDS") return true - // We don't care about extra health & strength - healthPattern.matchMatcher(message) { - return true - } - strengthPattern.matchMatcher(message) { - return true - } - - // No Bazaar and Community Shop in bingo - if (message == " §r§7§6Access to Bazaar") return true - if (message == " §r§7§bAccess to Community Shop") return true - - // Always enabled in bingo - if (message == " §r§7§8+§aAuto-pickup block and mob drops") return true - } + if (inSkyBlockLevelUp && inSkyblockPattern.matches(message)) return true return false } private fun onCollectionLevelUp(message: String): Boolean { - if (message.startsWith(" §r§6§lCOLLECTION LEVEL UP ")) { + if (collectionLevelUpPattern.matches(message)) { inCollectionLevelUp = true return false } if (inCollectionLevelUp) { - if (message.contains("Trade") || message.contains("Recipe")) { + if (tradeRecipePattern.matches(message)) { val text = message.removeColor().replace(" ", "") + //TODO seraid if (text == "Trade" || text == "Recipe") { collectionLevelUpLastLine?.let { ChatUtils.chat(it, false) } } @@ -118,7 +129,7 @@ class CompactBingoChat { } private fun onNewAreaDiscovered(message: String): Boolean { - if (message == " §r§6§lNEW AREA DISCOVERED!") { + if (newAreaDiscoverdPattern.matches(message)) { newArea = 1 return false } @@ -130,7 +141,7 @@ class CompactBingoChat { } if (newArea == 2) { - if (message.startsWith("§7 ■ §r") || message.startsWith(" §r") || message.startsWith(" §r")) { + if (newAreaPattern.matches(message)) { return true } else { newArea = 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index 35741622a56a..009aa2985e32 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonArray @@ -33,10 +34,15 @@ class MinionCraftHelper { private val config get() = SkyHanniMod.feature.event.bingo + private val patternGroup = RepoPattern.group("bingo.minion") private val minionNamePattern by RepoPattern.pattern( - "bingo.minion.name", + "name", "(?.*) Minion (?.*)" ) + private val minionCheckPattern by patternGroup.pattern( + "minioncheck", + "Minion(?! Skin)" + ) private var display = emptyList() private var hasMinionInInventory = false @@ -258,7 +264,7 @@ class MinionCraftHelper { return replace(lastText, "" + next) } - private fun isMinionName(itemName: String) = itemName.contains(" Minion ") && !itemName.contains(" Minion Skin") + private fun isMinionName(itemName: String) = minionCheckPattern.matches(itemName) @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { 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 c02a769e5766..e1f3631c3dd2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -20,32 +20,37 @@ class ChatFilter { /// // Lobby Messages - private val lobbyPatterns = listOf( + private val patternGroup = RepoPattern.group("chat.filter") + private val lobbyPattern by patternGroup.list( + "lobby", // player join - "(?: §b>§c>§a>§r §r)?.* §6(?:joined|(?:spooked|slid) into) the lobby!(?:§r §a<§c<§b<)?".toPattern(), + "(?: §b>§c>§a>§r §r)?.* §6(?:joined|(?:spooked|slid) into) the lobby!(?:§r §a<§c<§b<)?", // Hypixel SMP - "§2[\\s]*?§aYou can now create your own Hypixel SMP server![\\s]*?".toPattern(), + "§2[\\s]*?§aYou can now create your own Hypixel SMP server![\\s]*?", // Snow Particles in the Lobby - "[\\s]*?.*§bFor the best experience, click the text below to enable Snow[\\s]§.*§bParticles in this lobby![\\s]*?.*§3§lClick to enable Snow Particles[\\s]*?".toPattern(), + "[\\s]*?.*§bFor the best experience, click the text below to enable Snow[\\s]§.*§bParticles in this lobby![\\s]*?.*§3§lClick to enable Snow Particles[\\s]*?", // mystery box - "§b✦ §r.* §r§7found a §r§e.* §r§bMystery Box§r§7!".toPattern(), - "§b✦ §r.* §r§7found (a|an) §r.* §r§7in a §r§a(Holiday )?Mystery Box§r§7!".toPattern(), + "§b✦ §r.* §r§7found a §r§e.* §r§bMystery Box§r§7!", + "§b✦ §r.* §r§7found (a|an) §r.* §r§7in a §r§a(Holiday )?Mystery Box§r§7!", // mystery dust - "§b✦ §r§7You earned §r§b\\d+ §r§7Mystery Dust!".toPattern(), + "§b✦ §r§7You earned §r§b\\d+ §r§7Mystery Dust!", // pet consumables - "§b✦ §r§7You earned §r§a\\d+ §r§7Pet Consumables?!".toPattern(), + "§b✦ §r§7You earned §r§a\\d+ §r§7Pet Consumables?!", ) - private val lobbyMessages = listOf( + private val lobbyMessagesPattern by patternGroup.list( + "lobbymessages", // prototype - " §r§f§l➤ §r§6You have reached your Hype limit! Add Hype to Prototype Lobby minigames by right-clicking with the Hype Diamond!" + " {2}§r§f§l➤ §r§6You have reached your Hype limit! Add Hype to Prototype Lobby minigames by right-clicking with the Hype Diamond!", ) - private val lobbyMessagesContains = listOf( + + private val lobbyMessagesContainsPattern by patternGroup.list( + "lobbymessagecontains", // prototype "§r§6§lWelcome to the Prototype Lobby§r", @@ -55,55 +60,66 @@ class ChatFilter { "§r§e§6§lHYPIXEL§e is hosting a §b§lTNT RUN§e tournament!", // other - "§aYou are still radiating with §bGenerosity§r§a!" + "§aYou are still radiating with §bGenerosity§r§a!", ) // Warping - private val warpingPatterns = listOf( - "§7Sending to server (.*)\\.\\.\\.".toPattern(), - "§7Request join for Hub (.*)\\.\\.\\.".toPattern(), - "§7Request join for Dungeon Hub #(.*)\\.\\.\\.".toPattern(), + private val warpingPattern by patternGroup.list( + "warping", + "§7Sending to server (.*)\\.\\.\\.", + "§7Request join for Hub (.*)\\.\\.\\.", + "§7Request join for Dungeon Hub #(.*)\\.\\.\\.", + // warp portals on public islands // (canvas room – flower house, election room – community center, void sepulchre – the end) - "§dWarped to (.*)§r§d!".toPattern() + "§dWarped to (.*)§r§d!", ) - private val warpingMessages = listOf( + + private val warpingMessagesPattern by patternGroup.list( + "warpingmessages", "§7Warping...", "§7Warping you to your SkyBlock island...", "§7Warping using transfer token...", // visiting other players - "§7Finding player...", "§7Sending a visit request..." + "§7Finding player...", "§7Sending a visit request...", ) // Welcome - private val welcomeMessages = listOf( - "§eWelcome to §r§aHypixel SkyBlock§r§e!" + private val welcomeMessagesPattern by patternGroup.list( + "welcomemessages", + "§eWelcome to §r§aHypixel SkyBlock§r§e!", ) // Guild EXP - private val guildExpPatterns = listOf( + private val guildExpPattern by patternGroup.list( + "guildexp", // §aYou earned §r§22 GEXP §r§afrom playing SkyBlock! // §aYou earned §r§22 GEXP §r§a+ §r§c210 Event EXP §r§afrom playing SkyBlock! - "§aYou earned §r§2.* GEXP (§r§a\\+ §r§.* Event EXP )?§r§afrom playing SkyBlock!".toPattern() + "§aYou earned §r§2.* GEXP (§r§a\\+ §r§.* Event EXP )?§r§afrom playing SkyBlock!", ) // Kill Combo - private val killComboPatterns = listOf( + private val killComboPattern by patternGroup.list( + "killcombo", //§a§l+5 Kill Combo §r§8+§r§b3% §r§b? Magic Find - "§.§l\\+(.*) Kill Combo (.*)".toPattern(), - "§cYour Kill Combo has expired! You reached a (.*) Kill Combo!".toPattern() + "§.§l\\+(.*) Kill Combo (.*)", + "§cYour Kill Combo has expired! You reached a (.*) Kill Combo!", ) - private val killComboMessages = listOf( - "§6§l+50 Kill Combo" + + private val killComboMessagesPattern by patternGroup.list( + "killcombomessages", + "§6§l+50 Kill Combo", ) // Profile Join - private val profileJoinMessageStartsWith = listOf( - "§aYou are playing on profile: §e", "§8Profile ID: " + private val profileJoinMessageStartsWithPattern by patternGroup.list( + "profilejoinmessagesstartswith", + "§aYou are playing on profile: §e", "§8Profile ID: ", ) // OTHERS // Bazaar And AH Mini - private val miniBazaarAndAHMessages = listOf( + private val miniBazaarAndAHMessagesPattern by patternGroup.list( + "minibazaarandahmessages", "§7Putting item in escrow...", "§7Putting coins in escrow...", @@ -124,85 +140,97 @@ class ChatFilter { // Bank "§8Depositing coins...", - "§8Withdrawing coins..." + "§8Withdrawing coins...", ) // Slayer - private val slayerPatterns = listOf( + private val slayerPattern by patternGroup.list( + "slayer", // start - " {2}§r§5§lSLAYER QUEST STARTED!".toPattern(), - " {3}§5§l» §7Slay §c(.*) Combat XP §7worth of (.*)§7.".toPattern(), + " {2}§r§5§lSLAYER QUEST STARTED!", + " {3}§5§l» §7Slay §c(.*) Combat XP §7worth of (.*)§7.", // end - " {2}§r§a§lSLAYER QUEST COMPLETE!".toPattern(), - " {3}§r§e(.*)Slayer LVL 9 §r§5- §r§a§lLVL MAXED OUT!".toPattern(), - " {3}§r§5§l» §r§7Talk to Maddox to claim your (.*) Slayer XP!".toPattern() + " {2}§r§a§lSLAYER QUEST COMPLETE!", + " {3}§r§e(.*)Slayer LVL 9 §r§5- §r§a§lLVL MAXED OUT!", + " {3}§r§5§l» §r§7Talk to Maddox to claim your (.*) Slayer XP!", ) - private val slayerMessages = listOf( - " §r§6§lNICE! SLAYER BOSS SLAIN!", "§eYou received kill credit for assisting on a slayer miniboss!" + + private val slayerMessagesPattern by patternGroup.list( + "slayermessages", + " {2}§r§6§lNICE! SLAYER BOSS SLAIN!", "§eYou received kill credit for assisting on a slayer miniboss!", ) - private val slayerMessageStartWith = listOf( + + private val slayerMessageStartWithPattern by patternGroup.list( + "slayermessagestartwith", "§e✆ RING... " ) // Slayer Drop - private val slayerDropPatterns = listOf( + private val slayerDropPattern by patternGroup.list( + "slayerdrop", // Zombie - "§b§lRARE DROP! §r§7\\(§r§f§r§9Revenant Viscera§r§7\\) (.*)".toPattern(), - "§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§9Foul Flesh§r§7\\) (.*)".toPattern(), - "§b§lRARE DROP! §r§7\\(§r§f§r§9Foul Flesh§r§7\\) (.*)".toPattern(), - "§6§lRARE DROP! §r§5Golden Powder (.*)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§2(.*) Pestilence Rune I§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5Revenant Catalyst§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§9Undead Catalyst§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§2◆ Pestilence Rune I§r§7\\) §r§b(.*)".toPattern(), + "§b§lRARE DROP! §r§7\\(§r§f§r§9Revenant Viscera§r§7\\) (.*)", + "§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§9Foul Flesh§r§7\\) (.*)", + "§b§lRARE DROP! §r§7\\(§r§f§r§9Foul Flesh§r§7\\) (.*)", + "§6§lRARE DROP! §r§5Golden Powder (.*)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§2(.*) Pestilence Rune I§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5Revenant Catalyst§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§9Undead Catalyst§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§2◆ Pestilence Rune I§r§7\\) §r§b(.*)", // Tarantula - "§6§lRARE DROP! §r§9Arachne's Keeper Fragment (.+)".toPattern(), - "§6§lRARE DROP! §r§5Travel Scroll to Spider's Den Top of Nest (.+)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§a◆ Bite Rune I§r§7\\) (.+)".toPattern(), - "§b§lRARE DROP! §r§7\\(§r§f§r§7(.+)x §r§f§r§aToxic Arrow Poison§r§7\\) (.+)".toPattern(), - "§b§lRARE DROP! §r§7\\(§r§f§r§aToxic Arrow Poison§r§7\\) (.+)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§9Bane of Arthropods VI§r§7\\) (.+)".toPattern(), + "§6§lRARE DROP! §r§9Arachne's Keeper Fragment (.+)", + "§6§lRARE DROP! §r§5Travel Scroll to Spider's Den Top of Nest (.+)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§a◆ Bite Rune I§r§7\\) (.+)", + "§b§lRARE DROP! §r§7\\(§r§f§r§7(.+)x §r§f§r§aToxic Arrow Poison§r§7\\) (.+)", + "§b§lRARE DROP! §r§7\\(§r§f§r§aToxic Arrow Poison§r§7\\) (.+)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§9Bane of Arthropods VI§r§7\\) (.+)", // Enderman - "§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§aTwilight Arrow Poison§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§fMana Steal I§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5Sinful Dice§r§7\\) (.*)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§9Null Atom§r§7\\) (.*)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5Transmission Tuner§r§7\\) (.*)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§fMana Steal I§r§7\\) (.*)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5◆ Endersnake Rune I§r§7\\) (.*)".toPattern(), - "§d§lCRAZY RARE DROP! {2}§r§7\\(§r§f§r§fPocket Espresso Machine§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5◆ End Rune I§r§7\\) (.*)".toPattern(), - "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§6Hazmat Enderman§r§7\\) .*".toPattern(), + "§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§aTwilight Arrow Poison§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§fMana Steal I§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5Sinful Dice§r§7\\) (.*)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§9Null Atom§r§7\\) (.*)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5Transmission Tuner§r§7\\) (.*)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§fMana Steal I§r§7\\) (.*)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5◆ Endersnake Rune I§r§7\\) (.*)", + "§d§lCRAZY RARE DROP! {2}§r§7\\(§r§f§r§fPocket Espresso Machine§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§5◆ End Rune I§r§7\\) (.*)", + "§5§lVERY RARE DROP! {2}§r§7\\(§r§f§r§6Hazmat Enderman§r§7\\) .*", // Blaze - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§fWisp's Ice-Flavored Water I Splash Potion§r§7\\) (.*)".toPattern(), - "§b§lRARE DROP! §r§7\\(§r§f§r§5Bundle of Magma Arrows§r§7\\) (.*)".toPattern(), - "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§7\\d+x §r§f§r§9(Glowstone|Blaze Rod|Magma Cream|Nether Wart) Distillate§r§7\\) (.*)".toPattern() + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§fWisp's Ice-Flavored Water I Splash Potion§r§7\\) (.*)", + "§b§lRARE DROP! §r§7\\(§r§f§r§5Bundle of Magma Arrows§r§7\\) (.*)", + "§9§lVERY RARE DROP! {2}§r§7\\(§r§f§r§7\\d+x §r§f§r§9(Glowstone|Blaze Rod|Magma Cream|Nether Wart) Distillate§r§7\\) (.*)", ) // Useless Drop - private val uselessDropPatterns = listOf( - "§6§lRARE DROP! §r§aEnchanted Ender Pearl (.*)".toPattern(), - "§6§lRARE DROP! §r§fCarrot (.*)".toPattern(), - "§6§lRARE DROP! §r§fPotato (.*)".toPattern(), - "§6§lRARE DROP! §r§9Machine Gun Bow (.*)".toPattern(), - "§6§lRARE DROP! §r§5Earth Shard (.*)".toPattern(), - "§6§lRARE DROP! §r§5Zombie Lord Chestplate (.*)".toPattern() - ) - private val uselessDropMessages = listOf( + private val uselessDropPattern by patternGroup.list( + "uselessdrop", + "§6§lRARE DROP! §r§aEnchanted Ender Pearl (.*)", + "§6§lRARE DROP! §r§fCarrot (.*)", + "§6§lRARE DROP! §r§fPotato (.*)", + "§6§lRARE DROP! §r§9Machine Gun Bow (.*)", + "§6§lRARE DROP! §r§5Earth Shard (.*)", + "§6§lRARE DROP! §r§5Zombie Lord Chestplate (.*)", + ) + + private val uselessDropMessagesPattern by patternGroup.list( + "uselessdropmessages", "§6§lRARE DROP! §r§aEnchanted Ender Pearl", "§6§lRARE DROP! §r§aEnchanted End Stone", "§6§lRARE DROP! §r§5Crystal Fragment", ) // Useless Notification - private val uselessNotificationPatterns = listOf( - "§aYou tipped \\d+ players? in \\d+(?: different)? games?!".toPattern() + private val uselessNotificationPattern by patternGroup.list( + "uselessnotification", + "§aYou tipped \\d+ players? in \\d+(?: different)? games?!", ) - private val uselessNotificationMessages = listOf( + + private val uselessNotificationMessagesPattern by patternGroup.list( + "uselessnotificationmessages", "§eYour previous §r§6Plasmaflux Power Orb §r§ewas removed!", "§aYou used your §r§6Mining Speed Boost §r§aPickaxe Ability!", "§cYour Mining Speed Boost has expired!", @@ -213,31 +241,36 @@ class ChatFilter { ) // Party - private val partyMessages = listOf( + private val partyMessagesPattern by patternGroup.list( + "partymessages", "§9§m-----------------------------------------------------", ) // MONEY // Auction House - private val auctionHouseMessages = listOf( + private val auctionHouseMessagesPattern by patternGroup.list( + "auctionhousemessages", "§b-----------------------------------------------------", "§eVisit the Auction House to collect your item!", ) // Bazaar - private val bazaarPatterns = listOf( - "§eBuy Order Setup! §r§a(.*)§r§7x (.*) §r§7for §r§6(.*) coins§r§7.".toPattern(), - "§eSell Offer Setup! §r§a(.*)§r§7x (.*) §r§7for §r§6(.*) coins§r§7.".toPattern(), - "§cCancelled! §r§7Refunded §r§6(.*) coins §r§7from cancelling buy order!".toPattern(), - "§cCancelled! §r§7Refunded §r§a(.*)§r§7x (.*) §r§7from cancelling sell offer!".toPattern(), + private val bazaarPattern by patternGroup.list( + "bazaar", + "§eBuy Order Setup! §r§a(.*)§r§7x (.*) §r§7for §r§6(.*) coins§r§7.", + "§eSell Offer Setup! §r§a(.*)§r§7x (.*) §r§7for §r§6(.*) coins§r§7.", + "§cCancelled! §r§7Refunded §r§6(.*) coins §r§7from cancelling buy order!", + "§cCancelled! §r§7Refunded §r§a(.*)§r§7x (.*) §r§7from cancelling sell offer!", ) // Winter Island - private val winterIslandPatterns = listOf( - "§r§f☃ §r§7§r(.*) §r§7mounted a §r§fSnow Cannon§r§7!".toPattern(), + private val winterIslandPattern by patternGroup.list( + "winterisland", + "§r§f☃ §r§7§r(.*) §r§7mounted a §r§fSnow Cannon§r§7!", ) // Useless Warning - private val uselessWarningMessages = listOf( + private val uselessWarningMessagesPattern by patternGroup.list( + "uselesswarningmessages", "§cYou are sending commands too fast! Please slow down.", // TODO prevent in the future "§cYou can't use this while in combat!", "§cYou can not modify your equipped armor set!", @@ -250,12 +283,15 @@ class ChatFilter { ) // Annoying Spam - private val annoyingSpamPatterns = listOf( - "§7Your Implosion hit (.*) for §r§c(.*) §r§7damage.".toPattern(), - "§7Your Molten Wave hit (.*) for §r§c(.*) §r§7damage.".toPattern(), - "§cYou need a tool with a §r§aBreaking Power §r§cof §r§6(\\d)§r§c to mine (.*)§r§c! Speak to §r§dFragilis §r§cby the entrance to the Crystal Hollows to learn more!".toPattern() + private val annoyingSpamPattern by patternGroup.list( + "annoyingspam", + "§7Your Implosion hit (.*) for §r§c(.*) §r§7damage.", + "§7Your Molten Wave hit (.*) for §r§c(.*) §r§7damage.", + "§cYou need a tool with a §r§aBreaking Power §r§cof §r§6(\\d)§r§c to mine (.*)§r§c! Speak to §r§dFragilis §r§cby the entrance to the Crystal Hollows to learn more!", ) - private val annoyingSpamMessages = listOf( + + private val annoyingSpamMessagesPattern by patternGroup.list( + "annoyingspammessages", "§cThere are blocks in the way!", "§aYour Blessing enchant got you double drops!", "§cYou can't use the wardrobe in combat!", @@ -286,76 +322,86 @@ class ChatFilter { ) // Winter Gift - private val winterGiftPatterns = listOf( + private val winterGiftPattern by patternGroup.list( + "wintergift", // winter gifts useless - "§f§lCOMMON! §r§3.* XP §r§egift with §r.*§r§e!".toPattern(), - "(§f§lCOMMON|§9§lRARE)! §r.* XP Boost .* Potion §r.*§r§e!".toPattern(), - "(§f§lCOMMON|§9§lRARE)! §r§6.* coins §r§egift with §r.*§r§e!".toPattern(), + "§f§lCOMMON! §r§3.* XP §r§egift with §r.*§r§e!", + "(§f§lCOMMON|§9§lRARE)! §r.* XP Boost .* Potion §r.*§r§e!", + "(§f§lCOMMON|§9§lRARE)! §r§6.* coins §r§egift with §r.*§r§e!", // enchanted book - "§9§lRARE! §r§9Scavenger IV §r§egift with §r.*§r§e!".toPattern(), - "§9§lRARE! §r§9Looting IV §r§egift with §r.*§r§e!".toPattern(), - "§9§lRARE! §r§9Luck VI §r§egift with §r.*§r§e!".toPattern(), + "§9§lRARE! §r§9Scavenger IV §r§egift with §r.*§r§e!", + "§9§lRARE! §r§9Looting IV §r§egift with §r.*§r§e!", + "§9§lRARE! §r§9Luck VI §r§egift with §r.*§r§e!", // minion skin - "§e§lSWEET! §r§f(Grinch|Santa|Gingerbread Man) Minion Skin §r§egift with §r.*§r§e!".toPattern(), + "§e§lSWEET! §r§f(Grinch|Santa|Gingerbread Man) Minion Skin §r§egift with §r.*§r§e!", // rune - "§9§lRARE! §r§f◆ Ice Rune §r§egift with §r.*§r§e!".toPattern(), + "§9§lRARE! §r§f◆ Ice Rune §r§egift with §r.*§r§e!", // furniture - "§e§lSWEET! §r§fTall Holiday Tree §r§egift with §r.*§r§e!".toPattern(), - "§e§lSWEET! §r§fNutcracker §r§egift with §r.*§r§e!".toPattern(), - "§e§lSWEET! §r§fPresent Stack §r§egift with §r.*§r§e!".toPattern(), + "§e§lSWEET! §r§fTall Holiday Tree §r§egift with §r.*§r§e!", + "§e§lSWEET! §r§fNutcracker §r§egift with §r.*§r§e!", + "§e§lSWEET! §r§fPresent Stack §r§egift with §r.*§r§e!", - "§e§lSWEET! §r§9(Winter|Battle) Disc §r§egift with §r.*§r§e!".toPattern(), + "§e§lSWEET! §r§9(Winter|Battle) Disc §r§egift with §r.*§r§e!", // winter gifts a bit useful - "§e§lSWEET! §r§9Winter Sack §r§egift with §r.*§r§e!".toPattern(), - "§e§lSWEET! §r§5Snow Suit .* §r§egift with §r.*§r§e!".toPattern(), + "§e§lSWEET! §r§9Winter Sack §r§egift with §r.*§r§e!", + "§e§lSWEET! §r§5Snow Suit .* §r§egift with §r.*§r§e!", // winter gifts not your gifts - "§cThis gift is for §r.*§r§c, sorry!".toPattern(), + "§cThis gift is for §r.*§r§c, sorry!", ) // Powder Mining - private val powderMiningPatterns = listOf( - "§cYou need a stronger tool to mine (Amethyst|Ruby|Jade|Amber|Sapphire|Topaz) Gemstone Block§r§c.".toPattern(), - "§aYou received §r§f\\d* §r§f[❤❈☘⸕✎✧] Rough (Ruby|Amethyst|Jade|Amber|Sapphire|Topaz) Gemstone§r§a\\.".toPattern(), - "§aYou received §r§f\\d §r§a[❤❈☘⸕✎✧] Flawed (Ruby|Amethyst|Jade|Amber|Sapphire|Topaz) Gemstone§r§a\\.".toPattern(), + private val powderMiningPattern by patternGroup.list( + "powdermining", + "§cYou need a stronger tool to mine (Amethyst|Ruby|Jade|Amber|Sapphire|Topaz) Gemstone Block§r§c.", + "§aYou received §r§f\\d* §r§f[❤❈☘⸕✎✧] Rough (Ruby|Amethyst|Jade|Amber|Sapphire|Topaz) Gemstone§r§a\\.", + "§aYou received §r§f\\d §r§a[❤❈☘⸕✎✧] Flawed (Ruby|Amethyst|Jade|Amber|Sapphire|Topaz) Gemstone§r§a\\.", // Jungle - "§aYou received §r§f\\d* §r§aSludge Juice§r§a\\.".toPattern(), + "§aYou received §r§f\\d* §r§aSludge Juice§r§a\\.", // Useful, maybe in another chat - "§aYou received §r§b\\+\\d{1,3} §r§a(Mithril|Gemstone) Powder.".toPattern(), - "§aYou received §r(§6|§b)\\+[1-2] (Diamond|Gold) Essence§r§a.".toPattern(), + "§aYou received §r§b\\+\\d{1,3} §r§a(Mithril|Gemstone) Powder.", + "§aYou received §r(§6|§b)\\+[1-2] (Diamond|Gold) Essence§r§a.", ) private val fireSalePattern by RepoPattern.pattern( "chat.firesale", "§6§k§lA§r §c§lFIRE SALE §r§6§k§lA(?:\\n|.)*" ) - private val fireSalePatterns = listOf( - "§c♨ §eFire Sales for .* §eare starting soon!".toPattern(), - "§c\\s*♨ .* (?:Skin|Rune|Dye) §e(?:for a limited time )?\\(.* §eleft\\)(?:§c|!)".toPattern(), - "§c♨ §eVisit the Community Shop in the next §c.* §eto grab yours! §a§l\\[WARP]".toPattern(), - "§c♨ §eA Fire Sale for .* §eis starting soon!".toPattern(), - "§c♨ §r§eFire Sales? for .* §r§eended!".toPattern(), - "§c {3}♨ §eAnd \\d+ more!".toPattern(), - ) - private val eventPatterns = listOf( - "§f +§r§7You are now §r§.Event Level §r§.*§r§7!".toPattern(), - "§f +§r§7You earned §r§.* Event Silver§r§7!".toPattern(), - "§f +§r§.§k#§r§. LEVEL UP! §r§.§k#".toPattern(), - ) - private val factoryUpgradePatterns = listOf( - "§.* §r§7has been promoted to §r§7\\[.*§r§7] §r§.*§r§7!".toPattern(), - "§7Your §r§aRabbit Barn §r§7capacity has been increased to §r§a.* Rabbits§r§7!".toPattern(), - "§7You will now produce §r§6.* Chocolate §r§7per click!".toPattern(), - "§7You upgraded to §r§d.*?§r§7!".toPattern(), - ) - private val powderMiningMessages = listOf( + + private val fireSaleMessagesPattern by patternGroup.list( + "firesalemessages", + "§c♨ §eFire Sales for .* §eare starting soon!", + "§c\\s*♨ .* (?:Skin|Rune|Dye) §e(?:for a limited time )?\\(.* §eleft\\)(?:§c|!)", + "§c♨ §eVisit the Community Shop in the next §c.* §eto grab yours! §a§l\\[WARP]", + "§c♨ §eA Fire Sale for .* §eis starting soon!", + "§c♨ §r§eFire Sales? for .* §r§eended!", + "§c {3}♨ §eAnd \\d+ more!", + ) + + private val eventPattern by patternGroup.list( + "event", + "§f +§r§7You are now §r§.Event Level §r§.*§r§7!", + "§f +§r§7You earned §r§.* Event Silver§r§7!", + "§f +§r§.§k#§r§. LEVEL UP! §r§.§k#", + ) + + private val factoryUpgradePattern by patternGroup.list( + "factoryupgrade", + "§.* §r§7has been promoted to §r§7\\[.*§r§7] §r§.*§r§7!", + "§7Your §r§aRabbit Barn §r§7capacity has been increased to §r§a.* Rabbits§r§7!", + "§7You will now produce §r§6.* Chocolate §r§7per click!", + "§7You upgraded to §r§d.*?§r§7!", + ) + + private val powderMiningMessagesPattern by patternGroup.list( + "powderminingmessages", "§aYou uncovered a treasure chest!", "§aYou received §r§f1 §r§aWishing Compass§r§a.", "§aYou received §r§f1 §r§9Ascension Rope§r§a.", @@ -364,75 +410,83 @@ class ChatFilter { // Useful, maybe in another chat "§6You have successfully picked the lock on this chest!", ) - private val fireSaleMessages = listOf( + + private val fireSaleActiveMessagesPattern by patternGroup.list( + "firesaleactivemessages", "§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 eventMessagePattern by patternGroup.list( + "eventmessage", "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬", ) // &r&6Your &r&aMage &r&6stats are doubled because you are the only player using this class!&r - private val soloClassPatterns = listOf( - "§6Your §r§a(Healer|Mage|Berserk|Archer|Tank) §r§6stats are doubled because you are the only player using this class!".toPattern() + private val soloClassPattern by patternGroup.list( + "soloclass", + "§6Your §r§a(Healer|Mage|Berserk|Archer|Tank) §r§6stats are doubled because you are the only player using this class!", ) - private val soloStatsPatterns = listOf( - "§a\\[(Healer|Mage|Berserk|Archer|Tank)].*".toPattern() + private val soloStatsPattern by patternGroup.list( + "solostats", + "§a\\[(Healer|Mage|Berserk|Archer|Tank)].*", ) // &r&dGenevieve the Fairy&r&f: You killed me! Take this &r&6Revive Stone &r&fso that my death is not in vain!&r - private val fairyPatterns = listOf( - "§d[\\w']+ the Fairy§r§f: You killed me! Take this §r§6Revive Stone §r§fso that my death is not in vain!".toPattern(), - "§d[\\w']+ the Fairy§r§f: You killed me! I'll revive you so that my death is not in vain!".toPattern(), - "§d[\\w']+ the Fairy§r§f: Have a great life!".toPattern() + private val fairyPattern by patternGroup.list( + "fairy", + "§d[\\w']+ the Fairy§r§f: You killed me! Take this §r§6Revive Stone §r§fso that my death is not in vain!", + "§d[\\w']+ the Fairy§r§f: You killed me! I'll revive you so that my death is not in vain!", + "§d[\\w']+ the Fairy§r§f: Have a great life!", ) private val patternsMap: Map> = mapOf( - "lobby" to lobbyPatterns, - "warping" to warpingPatterns, - "guild_exp" to guildExpPatterns, - "kill_combo" to killComboPatterns, - "slayer" to slayerPatterns, - "slayer_drop" to slayerDropPatterns, - "useless_drop" to uselessDropPatterns, - "useless_notification" to uselessNotificationPatterns, - "money" to bazaarPatterns, - "winter_island" to winterIslandPatterns, - "annoying_spam" to annoyingSpamPatterns, - "winter_gift" to winterGiftPatterns, - "powder_mining" to powderMiningPatterns, - "fire_sale" to fireSalePatterns, - "event" to eventPatterns, - "factory_upgrade" to factoryUpgradePatterns, - "solo_class" to soloClassPatterns, - "solo_stats" to soloStatsPatterns, - "fairy" to fairyPatterns, - ) - + "lobby" to lobbyPattern, + "warping" to warpingPattern, + "guild_exp" to guildExpPattern, + "kill_combo" to killComboPattern, + "slayer" to slayerPattern, + "slayer_drop" to slayerDropPattern, + "useless_drop" to uselessDropPattern, + "useless_notification" to uselessNotificationPattern, + "money" to bazaarPattern, + "winter_island" to winterIslandPattern, + "annoying_spam" to annoyingSpamPattern, + "winter_gift" to winterGiftPattern, + "powder_mining" to powderMiningPattern, + "fire_sale" to fireSaleMessagesPattern, + "event" to eventPattern, + "factory_upgrade" to factoryUpgradePattern, + "solo_class" to soloClassPattern, + "solo_stats" to soloStatsPattern, + "fairy" to fairyPattern, + ) + + //TODO seraid private val messagesMap: Map> = mapOf( - "lobby" to lobbyMessages, - "warping" to warpingMessages, - "welcome" to welcomeMessages, - "kill_combo" to killComboMessages, - "bz_ah_minis" to miniBazaarAndAHMessages, - "slayer" to slayerMessages, - "useless_drop" to uselessDropMessages, - "useless_notification" to uselessNotificationMessages, - "party" to partyMessages, - "money" to auctionHouseMessages, - "useless_warning" to uselessWarningMessages, - "annoying_spam" to annoyingSpamMessages, - "powder_mining" to powderMiningMessages, - "fire_sale" to fireSaleMessages, - "event" to eventMessage, + "lobby" to this.lobbyMessagesPattern, + "warping" to warpingMessagesPattern, + "welcome" to welcomeMessagesPattern, + "kill_combo" to killComboMessagesPattern, + "bz_ah_minis" to miniBazaarAndAHMessagesPattern, + "slayer" to slayerMessagesPattern, + "useless_drop" to uselessDropMessagesPattern, + "useless_notification" to uselessNotificationMessagesPattern, + "party" to partyMessagesPattern, + "money" to auctionHouseMessagesPattern, + "useless_warning" to uselessWarningMessagesPattern, + "annoying_spam" to annoyingSpamMessagesPattern, + "powder_mining" to powderMiningMessagesPattern, + "fire_sale" to fireSaleActiveMessagesPattern, + "event" to eventMessagePattern, ) private val messagesContainsMap: Map> = mapOf( - "lobby" to lobbyMessagesContains, + "lobby" to lobbyMessagesContainsPattern, ) private val messagesStartsWithMap: Map> = mapOf( - "slayer" to slayerMessageStartWith, - "profile_join" to profileJoinMessageStartsWith, + "slayer" to slayerMessageStartWithPattern, + "profile_join" to profileJoinMessageStartsWithPattern, ) /// diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt index 52e95b3a12fa..54598772b382 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt @@ -5,20 +5,30 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent -import net.minecraft.util.ChatComponentText import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PlayerChatModifier { private val config get() = SkyHanniMod.feature.chat.playerMessage - private val patterns = mutableListOf() + + + //TODO seraid + private val patternGroup = RepoPattern.group("chat.modifier") + private val playerPattern by patternGroup.list( + "patterns", + "§[ab6]\\[(?:VIP|MVP)(?:§.|\\+)*] {1,2}(?:§[7ab6])?(\\w{2,16})",// ranked player with prefix everywhere + "§[7ab6](\\w{2,16})§r(?!§7x)(?!\$)",//all players without rank prefix in notification messages + ) + + private val playerPattern = mutableListOf() init { - patterns.add("§[ab6]\\[(?:VIP|MVP)(?:§.|\\+)*] {1,2}(?:§[7ab6])?(\\w{2,16})".toRegex()) // ranked player with prefix everywhere - patterns.add("§[7ab6](\\w{2,16})§r(?!§7x)(?!\$)".toRegex()) // all players without rank prefix in notification messages + playerPattern.add("§[ab6]\\[(?:VIP|MVP)(?:§.|\\+)*] {1,2}(?:§[7ab6])?(\\w{2,16})".toRegex()) // ranked player with prefix everywhere + playerPattern.add("§[7ab6](\\w{2,16})§r(?!§7x)(?!\$)".toRegex()) // all players without rank prefix in notification messages } @SubscribeEvent @@ -50,9 +60,10 @@ class PlayerChatModifier { var string = input if (config.playerRankHider) { - for (pattern in patterns) { + for (pattern in playerPattern) { string = string.replace(pattern, "§b$1") } + //TODO seraid string = string.replace("§[7ab6]((?:\\w+){2,16})'s", "§b$1's") string = string.replace("§[7ab6]((?:\\w+){2,16}) (§.)", "§b$1 $2") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index 22f60e1ff387..b19f3802298f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -65,6 +65,50 @@ object BestiaryData { "title", "^(?:\\(\\d+/\\d+\\) )?(Bestiary|.+) ➜ (.+)\$" ) + private val lorePattern by patternGroup.pattern( + "lore", + "§7(?:Overall Progress: §b100% §7(§c§lMAX!§7)|Families Completed: §a100%)" + ) + private val loreProgressHiddenPattern by patternGroup.pattern( + "loreprogresshidden", + "§7Overall Progress: §cHIDDEN" + ) + private val loreProgressShownPattern by patternGroup.pattern( + "loreprogressshown", + "§7Overall Progress: §aSHOWN" + ) + private val familiesFoundContainsPattern by patternGroup.pattern( + "familiesfoundcontains", + ".*Families Found.*" + ) + private val familiesFoundStartsPattern by patternGroup.pattern( + "familiesfoundstart", + "Families Found.*" + ) + private val familiesCompletedPattern by patternGroup.pattern( + "familiescompleted", + ".*Families Completed.*" + ) + private val killsPattern by patternGroup.pattern( + "kills", + "Kills:.*" + ) + private val progressTierPattern by patternGroup.pattern( + "progresstier", + ".*Progress to Tier.*" + ) + private val progressOverallPattern by patternGroup.pattern( + "progressoverall", + ".*Overall Progress.*" + ) + private val queryPattern by patternGroup.pattern( + "query", + "§7Query: §a.*" + ) + private val resultsPattern by patternGroup.pattern( + "results", + "§7Results: §a.*" + ) private var display = emptyList>() private val mobList = mutableListOf() @@ -97,10 +141,10 @@ object BestiaryData { for (slot in InventoryUtils.getItemsInOpenChest()) { val stack = slot.stack val lore = stack.getLore() - if (lore.any { it == "§7Overall Progress: §b100% §7(§c§lMAX!§7)" || it == "§7Families Completed: §a100%" }) { + if (lore.any { lorePattern.matches(it) }) { slot highlight LorenzColor.GREEN } - if (!overallProgressEnabled && lore.any { it == "§7Overall Progress: §cHIDDEN" }) { + if (!overallProgressEnabled && lore.any { loreProgressHiddenPattern.matches(it) }) { slot highlight LorenzColor.RED } } @@ -169,12 +213,13 @@ object BestiaryData { if (!line.startsWith(" ")) continue val previousLine = stack.getLore()[lineIndex - 1] val progress = line.substring(line.lastIndexOf(' ') + 1) - if (previousLine.contains("Families Found")) { + if (familiesFoundContainsPattern.matches(previousLine)) { progressPattern.matchMatcher(progress) { familiesFound = group("current").formatLong() totalFamilies = group("needed").formatLong() } - } else if (previousLine.contains("Families Completed")) { + + } else if (familiesCompletedPattern.matches(previousLine)) { progressPattern.matchMatcher(progress) { familiesCompleted = group("current").formatLong() } @@ -198,19 +243,20 @@ object BestiaryData { var actualRealTotalKill: Long = 0 for ((lineIndex, line) in stack.getLore().withIndex()) { val loreLine = line.removeColor() - if (loreLine.startsWith("Kills: ")) { + if (killsPattern.matches(loreLine)) { actualRealTotalKill = "([0-9,.]+)".toRegex().find(loreLine)?.groupValues?.get(1)?.formatLong() ?: 0 } if (!loreLine.startsWith(" ")) continue val previousLine = stack.getLore()[lineIndex - 1] val progress = loreLine.substring(loreLine.lastIndexOf(' ') + 1) - if (previousLine.contains("Progress to Tier")) { + if (progressTierPattern.matches(previousLine)) { progressPattern.matchMatcher(progress) { totalKillToTier = group("needed").formatLong() currentKillToTier = group("current").formatLong() } - } else if (previousLine.contains("Overall Progress")) { + + } else if (progressOverallPattern.matches(previousLine)) { progressPattern.matchMatcher(progress) { totalKillToMax = group("needed").formatLong() currentTotalKill = group("current").formatLong() @@ -407,7 +453,7 @@ object BestiaryData { private fun isOverallProgressEnabled(inventoryItems: Map): Boolean { if (inventoryItems[52]?.item == Items.ender_eye) { - return inventoryItems[52]?.getLore()?.any { it == "§7Overall Progress: §aSHOWN" } == true + return inventoryItems[52]?.getLore()?.any { loreProgressShownPattern.matches(it) } == true } indexes.forEach { index -> @@ -427,7 +473,7 @@ object BestiaryData { if ("Bestiary" != bestiaryGuiTitleMatcher.group(1)) { var loreContainsFamiliesFound = false for (line in stack.getLore()) { - if (line.removeColor().startsWith("Families Found")) { + if (familiesFoundStartsPattern.matches(line.removeColor())) { loreContainsFamiliesFound = true break } @@ -439,8 +485,8 @@ object BestiaryData { return true } else if (name == "Search Results") { val loreList = stack.getLore() - if (loreList.size >= 2 && loreList[0].startsWith("§7Query: §a") - && loreList[1].startsWith("§7Results: §a") + if (loreList.size >= 2 && queryPattern.matches(loreList[0]) + && resultsPattern.matches(loreList[1]) ) { return true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 57096d6de79a..0da47926fa0c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -43,6 +43,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.TimeUtils.ticks import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonArray import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP @@ -68,12 +69,20 @@ class DamageIndicatorManager { private val maxHealth = mutableMapOf() private val config get() = SkyHanniMod.feature.combat.damageIndicator - private val enderSlayerHitsNumberPattern = ".* §[5fd]§l(?\\d+) Hits?".toPattern() + private val patternGroup = RepoPattern.group("damageindicator") + private val enderSlayerHitsNumberPattern by patternGroup.pattern( + "enderslayer", + ".* §[5fd]§l(?\\d+) Hits?" + ) companion object { private var data = mapOf() - private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() + private val patternGroup = RepoPattern.group("damageindicator") + private val damagePattern by patternGroup.pattern( + "damage", + "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)" + ) fun isBoss(entity: EntityLivingBase) = data.values.any { it.entity == entity } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index a6bc5e10ec62..9b6ff93eb9e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -32,18 +32,6 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object DungeonAPI { - - private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?.*)\\)".toPattern() - private val uniqueClassBonus = - "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$".toRegex() - - private val bossPattern = - "View all your (?\\w+) Collection".toPattern() - private val levelPattern = - " +(?\\d+).*".toPattern() - private val killPattern = " +☠ Defeated (?\\w+).*".toPattern() - private val totalKillsPattern = "§7Total Kills: §e(?.*)".toPattern() - var dungeonFloor: String? = null var started = false var inBossRoom = false @@ -52,18 +40,14 @@ object DungeonAPI { var isUniqueClass = false val bossStorage: MutableMap? get() = ProfileStorageData.profileSpecific?.dungeons?.bosses - private val timePattern = - "Time Elapsed:( )?(?:(?\\d+)m)? (?\\d+)s".toPattern() // Examples: Time Elapsed: 10m 10s, Time Elapsed: 2s - private val patternGroup = RepoPattern.group("dungeon") - private val dungeonComplete by patternGroup.pattern( "complete", "§.\\s+§.§.(?:The|Master Mode) Catacombs §.§.- §.§.(?:Floor )?(?M?[IV]{1,3}|Entrance)" ) private val dungeonRoomPattern by patternGroup.pattern( "room", - "§7\\d+\\/\\d+\\/\\d+ §\\w+ (?[\\w,-]+)" + "§7\\d+/\\d+/\\d+ §\\w+ (?[\\w,-]+)" ) private val blessingPattern by patternGroup.pattern( "blessings", @@ -73,6 +57,51 @@ object DungeonAPI { "noblessings", "§r§r§7No Buffs active. Find them by exploring the Dungeon!§r" ) + private val startMessagePattern by patternGroup.pattern( + "startmessage", + "§e\\[NPC] §bMort§f: §rHere, I found this map when I first entered the dungeon." + ) + private val goBackPattern by patternGroup.pattern( + "goback", + "§aGo Back" + ) + private val toBossCollectionsPattern by patternGroup.pattern( + "tobosscollections", + "§7To Boss Collections" + ) + private val totalKillsLorePattern by patternGroup.pattern( + "totalkillslore", + ".*Total Kills:.*" + ) + private val floorPattern by patternGroup.pattern( + "floorpattern", + " §7⏣ §cThe Catacombs §7\\((?.*)\\)", + ) + private val uniqueClassBonusPattern by patternGroup.pattern( + "uniqueclassbonus", + "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$", + ) + private val bossPattern by patternGroup.pattern( + "boss", + "View all your (?\\w+) Collection", + ) + private val levelPattern by patternGroup.pattern( + "level", + " +(?\\d+).*", + ) + private val killPattern by patternGroup.pattern( + "kill", + " +☠ Defeated (?\\w+).*", + ) + private val totalKillsPattern by patternGroup.pattern( + "totalkills", + "§7Total Kills: §e(?.*)", + ) + private val timePattern by patternGroup.pattern( + "time", + "Time Elapsed:( )?(?:(?\\d+)m)? (?\\d+)s", // Examples: Time Elapsed: 10m 10s, Time Elapsed: 2s + ) + enum class DungeonBlessings(var power: Int) { LIFE(0), @@ -212,11 +241,11 @@ object DungeonAPI { @SubscribeEvent fun onChat(event: LorenzChatEvent) { val floor = dungeonFloor ?: return - if (event.message == "§e[NPC] §bMort§f: §rHere, I found this map when I first entered the dungeon.") { + if (startMessagePattern.matches(event.message)) { started = true DungeonStartEvent(floor).postAndCatch() } - if (event.message.removeColor().matches(uniqueClassBonus)) { + if (event.message.removeColor().matches(uniqueClassBonusPattern.toRegex())) { isUniqueClass = true } @@ -253,13 +282,13 @@ object DungeonAPI { inventoryName: String, ) { inventoryItems[48]?.let { item -> - if (item.name == "§aGo Back") { + if (goBackPattern.matches(item.name)) { item.getLore().getOrNull(0)?.let { firstLine -> - if (firstLine == "§7To Boss Collections") { + if (toBossCollectionsPattern.matches(firstLine)) { val name = inventoryName.split(" ").dropLast(1).joinToString(" ") val floor = DungeonFloor.byBossName(name) ?: return val lore = inventoryItems[4]?.getLore() ?: return - val line = lore.find { it.contains("Total Kills:") } ?: return + val line = lore.find { totalKillsLorePattern.matches(it) } ?: return val kills = totalKillsPattern.matchMatcher(line) { group("kills").formatInt() } ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt index 4e8bc060c86f..82d0c85200f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt @@ -11,8 +11,10 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyBlockTime import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -30,9 +32,15 @@ object Year300RaffleEvent { private var overlay: List? = null + private val patternGroup = RepoPattern.group("year300raffle") + private val messagePattern by patternGroup.pattern( + "message", + "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!" + ) + @SubscribeEvent fun onChat(event: LorenzChatEvent) { - if (event.message == "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!") { + if (messagePattern.matches(event.message)) { lastTimerReceived = SimpleTimeMark.now() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt index d8ff05378984..dd5322daddf1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt @@ -7,7 +7,9 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern class TheGreatSpook { @@ -18,14 +20,28 @@ class TheGreatSpook { private var displayTimeLeft = "" private var notificationSeconds = 0 + private val patternGroup = RepoPattern.group("thegreatspook") + private val primalPattern by patternGroup.pattern( + "primal", + " §r§cPrimal Fears§r§7: " + ) + private val fearPattern by patternGroup.pattern( + "fear", + " §r§5Fear: " + ) + private val endPattern by patternGroup.pattern( + "end", + " §r§dEnds In§r§7: " + ) + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (isAllDisabled()) return if (!event.repeatSeconds(1)) return - if (isTimerEnabled() || isNotificationEnabled()) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ") - if (isFearStatEnabled()) displayFearStat = checkTabList(" §r§5Fear: ") - if (isTimeLeftEnabled()) displayTimeLeft = checkTabList(" §r§dEnds In§r§7: ") + if (isTimerEnabled() || isNotificationEnabled()) displayTimer = checkTabList(primalPattern) + if (isFearStatEnabled()) displayFearStat = checkTabList(fearPattern) + if (isTimeLeftEnabled()) displayTimeLeft = checkTabList(endPattern) if (isNotificationEnabled()) { if (displayTimer.endsWith("READY!!")) { if (notificationSeconds > 0) { @@ -38,8 +54,8 @@ class TheGreatSpook { } } - private fun checkTabList(matchString: String): String { - return (TabListData.getTabList().find { it.contains(matchString) } ?: "").trim() + private fun checkTabList(pattern: Pattern): String { + return (TabListData.getTabList().find { pattern.matcher(it).find() } ?: "").trim() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt index 4ba88f1cd8fc..a97bb84c9e90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt @@ -7,8 +7,10 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.TimeLimitedSet import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -20,6 +22,20 @@ class ChumBucketHider { private val titleEntity = TimeLimitedSet(5.seconds) private val hiddenEntities = TimeLimitedSet(5.seconds) + private val patternGroup = RepoPattern.group("chumbucket") + private val isBucketPattern by patternGroup.pattern( + "isbucket", + ".*('s Chum(?:cap)? Bucket)$" + ) + private val chumAmountPattern by patternGroup.pattern( + "chumamount", + ".*/10 §aChums.*" + ) + private val emptyPattern by patternGroup.pattern( + "empty", + "^§[fa]Empty Chum(?:cap)? Bucket$" + ) + @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { reset() @@ -41,7 +57,8 @@ class ChumBucketHider { val name = entity.name // First text line - if (name.endsWith("'s Chum Bucket") || name.endsWith("'s Chumcap Bucket")) { + + if (isBucketPattern.matches(name)) { if (name.contains(LorenzUtils.getPlayerName()) && !config.hideOwn.get()) return titleEntity.add(entity) hiddenEntities.add(entity) @@ -50,7 +67,7 @@ class ChumBucketHider { } // Second text line - if (name.contains("/10 §aChums")) { + if (chumAmountPattern.matches(name)) { val entityLocation = entity.getLorenzVec() for (title in titleEntity.toSet()) { if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { @@ -62,7 +79,8 @@ class ChumBucketHider { } // Chum Bucket - if (config.hideBucket.get() && entity.inventory.any { it != null && (it.name == "§fEmpty Chum Bucket" || it.name == "§aEmpty Chumcap Bucket") }) { + + if (config.hideBucket.get() && entity.inventory.any { emptyPattern.matches(it.name) }) { val entityLocation = entity.getLorenzVec() for (title in titleEntity.toSet()) { if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt index 9acb9c5009f9..b3c110bef197 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.matchFirst +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -31,6 +32,14 @@ object AuctionsHighlighter { "auction", "§7(?:Starting bid|Top bid): §6(?.*) coins" ) + private val soldPattern by patternGroup.pattern( + "sold", + "§7Status: §aSold!" + ) + private val expiredPattern by patternGroup.pattern( + "expired", + "§7Status: §cExpired!" + ) @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { @@ -44,11 +53,12 @@ object AuctionsHighlighter { for ((slot, stack) in chest.getUpperItems()) { val lore = stack.getLore() - if (lore.any { it == "§7Status: §aSold!" }) { + if (lore.any { soldPattern.matches(it) }) { slot highlight LorenzColor.GREEN continue } - if (lore.any { it == "§7Status: §cExpired!" }) { + + if (lore.any { expiredPattern.matches(it) }) { slot highlight LorenzColor.RED continue } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt index 23702719f4e8..e64e003c29d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.interpolate import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color @@ -31,14 +32,21 @@ class HighlightBonzoMasks { // Technically this timer is overestimating since mage level affects the cooldown, however I don't care. private val bonzoMaskCooldown = 360.seconds - private val bonzoMaskMessage = "^Your (.*Bonzo's Mask) saved your life!$".toRegex() - private val spiritMaskCooldown = 30.seconds - private val spiritMaskMessage = "^Second Wind Activated! Your Spirit Mask saved your life!$".toRegex() private val greenHue = Color.RGBtoHSB(0, 255, 0, null)[0].toDouble() private val redHue = Color.RGBtoHSB(255, 0, 0, null)[0].toDouble() + private val patternGroup = RepoPattern.group("highlightbonzomask") + private val spiritMaskMessage by patternGroup.pattern( + "spiritmask", + "^Second Wind Activated! Your Spirit Mask saved your life!$" + ) + private val bonzoMaskMessage by patternGroup.pattern( + "bonzomask", + "^Your (.*Bonzo's Mask) saved your life!$" + ) + @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!config.depletedBonzosMasks) return @@ -66,9 +74,9 @@ class HighlightBonzoMasks { @SubscribeEvent fun onChat(event: LorenzChatEvent) { val message = event.message.removeColor() - if (bonzoMaskMessage.matches(message)) { + if (bonzoMaskMessage.toRegex().matches(message)) { maskTimers["BONZO_MASK"] = CooldownTimer(TimeSource.Monotonic.markNow(), bonzoMaskCooldown) - } else if (spiritMaskMessage.matches(message)) { + } else if (spiritMaskMessage.toRegex().matches(message)) { maskTimers["SPIRIT_MASK"] = CooldownTimer(TimeSource.Monotonic.markNow(), spiritMaskCooldown) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt index baeb1df046af..82720f81b7f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt @@ -163,6 +163,7 @@ object DiscordLocationKey { "Glacite Mineshafts" to "glacite-tunnels", ) // maps sublocations to their broader image + // list of nether locations because there are sooo many (truncated some according to scoreboard) private val specialNetherRPC = arrayOf( "Aura's Lab", "Barbarian Outpost", @@ -206,7 +207,6 @@ object DiscordLocationKey { "The Wasteland", "Throne Room" ) - // list of nether locations because there are sooo many (truncated some according to scoreboard) private val specialRiftRPC = mapOf( "Enigma's Crib" to "wyld-woods", diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt index 0944ca9ad2fa..2937ac3151ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt @@ -27,22 +27,34 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.TimeUtils.formatted +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay.getCurrentPet import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound -import java.util.regex.Pattern import kotlin.time.Duration.Companion.minutes var lastKnownDisplayStrings: MutableMap = mutableMapOf() // if the displayMessageSupplier is ever a placeholder, return from this instead -val purseRegex = Regex("""(?:Purse|Piggy): ([\d,]+)[\d.]*""") +//TODO seraid +val pursePattern = Regex("""(?:Purse|Piggy): ([\d,]+)[\d.]*""") val motesRegex = Regex("""Motes: ([\d,]+)""") val bitsRegex = Regex("""Bits: ([\d|,]+)[\d|.]*""") +val ownerRegex = Regex(".*Owner: (\\w+).*") + +private val patternGroup = RepoPattern.group("discordstatus") + +// Samples: Revenant Horror I; Tarantula Broodfather IV +private val slayerRegex by patternGroup.pattern( + "slayer", + "(?(?:\\w| )*) (?[IV]+)" +) + + private fun getVisitingName(): String { val tabData = TabListData.getTabList() - val ownerRegex = Regex(".*Owner: (\\w+).*") + for (line in tabData) { val colorlessLine = line.removeColor() if (ownerRegex.matches(colorlessLine)) { @@ -119,8 +131,8 @@ enum class DiscordStatus(private val displayMessageSupplier: (() -> String?)) { PURSE({ val scoreboard = ScoreboardData.sidebarLinesFormatted // Matches coins amount in purse or piggy, with optional decimal points - val coins = scoreboard.firstOrNull { purseRegex.matches(it.removeColor()) }?.let { - purseRegex.find(it.removeColor())?.groupValues?.get(1) ?: "" + val coins = scoreboard.firstOrNull { pursePattern.matches(it.removeColor()) }?.let { + pursePattern.find(it.removeColor())?.groupValues?.get(1) ?: "" } val motes = scoreboard.firstOrNull { motesRegex.matches(it.removeColor()) }?.let { motesRegex.find(it.removeColor())?.groupValues?.get(1) ?: "" @@ -196,8 +208,7 @@ enum class DiscordStatus(private val displayMessageSupplier: (() -> String?)) { var slayerName = "" var slayerLevel = "" var bossAlive = "spawning" - val slayerRegex = - Pattern.compile("(?(?:\\w| )*) (?[IV]+)") // Samples: Revenant Horror I; Tarantula Broodfather IV + for (line in ScoreboardData.sidebarLinesFormatted) { val noColorLine = line.removeColor() diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt index fb876278ccd2..182b82eabc71 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatchers import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes @@ -19,17 +20,20 @@ class PabloHelper { private val config get() = SkyHanniMod.feature.crimsonIsle - private val patterns = listOf( - "\\[NPC] Pablo: Could you bring me an (?[\\w ]+).*".toPattern(), - "\\[NPC] Pablo: Bring me that (?[\\w ]+) as soon as you can!".toPattern() + private val patternGroup = RepoPattern.group("pablohelper") + private val messagePattern by patternGroup.list( + "message", + "\\[NPC] Pablo: Could you bring me an (?[\\w ]+).*", + "\\[NPC] Pablo: Bring me that (?[\\w ]+) as soon as you can!", ) + private var lastSentMessage = SimpleTimeMark.farPast() @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return if (lastSentMessage.passedSince() < 5.minutes) return - val itemName = patterns.matchMatchers(event.message.removeColor()) { + val itemName = messagePattern.matchMatchers(event.message.removeColor()) { group("flower") } ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 73b45aa9438b..a9236e5c0850 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -23,6 +23,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -49,10 +50,23 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { * e - Accepted * a - Completed */ - val tabListQuestPattern by RepoPattern.pattern( - "crimson.reputation.tablist", + private val patternGroup = RepoPattern.group("crimson.reputation") + val tabListQuestPattern by patternGroup.pattern( + "tablist", " §r§[cdea].*" ) + private val reputationPattern by patternGroup.pattern( + "reputation", + ".*Reputation.*" + ) + private val magePattern by patternGroup.pattern( + "mage", + ".*Mage.*" + ) + private val barbarianPattern by patternGroup.pattern( + "barbarian", + ".*Barbarian.*" + ) init { skyHanniMod.loadModule(questHelper) @@ -98,11 +112,11 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { if (event.repeatSeconds(3)) { TabListData.getTabList() - .filter { it.contains("Reputation:") } + .filter { reputationPattern.matches(it) } .forEach { - factionType = if (it.contains("Mage")) { + factionType = if (magePattern.matches(it)) { FactionType.MAGE - } else if (it.contains("Barbarian")) { + } else if (barbarianPattern.matches(it)) { FactionType.BARBARIAN } else { FactionType.NONE diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index deb4c64dde27..4695f130c6d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -101,6 +101,7 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel miniBosses.clear() for ((displayName, quest) in data) { val displayItem = quest.item + //TODO seraid val pattern = "§f *§r§6§l${displayName.uppercase()} DOWN!".toPattern() val location = reputationHelper.readLocationData(quest.location) miniBosses.add(CrimsonMiniBoss(displayName, displayItem, location, pattern)) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt index 2c60dbce7ef2..b746125bccf6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt @@ -11,6 +11,8 @@ import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.ParkourHelper +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class RiftUpsideDownParkour { @@ -18,6 +20,12 @@ class RiftUpsideDownParkour { private val config get() = RiftAPI.config.area.mirrorverse.upsideDownParkour private var parkourHelper: ParkourHelper? = null + private val patternGroup = RepoPattern.group("parkour.rift") + private val healthPattern by patternGroup.pattern( + "message", + "§c§lOH NO! THE LAVA OOFED YOU BACK TO THE START!" + ) + @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("RiftUpsideDownParkour") @@ -46,7 +54,7 @@ class RiftUpsideDownParkour { fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return - if (event.message == "§c§lOH NO! THE LAVA OOFED YOU BACK TO THE START!") { + if (healthPattern.matches(event.message)) { parkourHelper?.reset() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt index 844fca7fcfc5..08cbecc42fcf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt @@ -163,6 +163,5 @@ object RiftBloodEffigies { @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(9, "rift.area.stillgoreChateauConfig", "rift.area.stillgoreChateau") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt index c037d5cfc836..a2ac99587389 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt @@ -12,6 +12,8 @@ import kotlin.time.Duration.Companion.milliseconds class ShyCruxWarnings { private val config get() = RiftAPI.config.area.wyldWoods + + //TODO seraid private val shyNames = arrayOf("I'm ugly! :(", "Eek!", "Don't look at me!", "Look away!") @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt index 7ba556680d1b..0fb6d25639f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -21,10 +22,15 @@ object CruxTalismanDisplay { private val config get() = RiftAPI.config.cruxTalisman - private val progressPattern by RepoPattern.pattern( - "rift.everywhere.crux.progress", + private val patternGroup = RepoPattern.group("rift.everywhere.crux") + private val progressPattern by patternGroup.pattern( + "progress", ".*(?§[0-9a-z][IV1-4-]+)\\s+(?§[0-9a-z]\\w+)§[0-9a-z]:\\s*(?§[0-9a-z](?:§[0-9a-z])?MAXED|§[0-9a-z]\\d+§[0-9a-z]/§[0-9a-z]\\d+).*" ) + private val totalBonusesPattern by patternGroup.pattern( + "bonuses", + "§7Total Bonuses.*" + ) private val partialName = "CRUX_TALISMAN" private var display = emptyList>() @@ -105,7 +111,7 @@ object CruxTalismanDisplay { val crux = Crux(name, tier, progress, progress.contains("MAXED")) displayLine.add(crux) } - if (line.startsWith("§7Total Bonuses")) { + if (totalBonusesPattern.matches(line)) { bonusFound = true continue@line } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 01a16b6df4da..72db5d632781 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -19,7 +19,9 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.gui.inventory.GuiChest @@ -37,6 +39,16 @@ object EnigmaSoulWaypoints { private val inventoryUnfound = mutableListOf() private var adding = true + private val patternGroup = RepoPattern.group("enigmasoulwaypoints") + private val messagePatterns by patternGroup.pattern( + "message", + "^(You have already found that Enigma Soul!|SOUL! You unlocked an Enigma Soul!)$", + ) + private val lorePatterns by patternGroup.pattern( + "lore", + "§8✖ Not completed yet!", + ) + private val item by lazy { val neuItem = "SKYBLOCK_ENIGMA_SOUL".asInternalName().getItemStack() Utils.createItemStack( @@ -66,7 +78,7 @@ object EnigmaSoulWaypoints { for (stack in event.inventoryItems.values) { val split = stack.displayName.split("Enigma: ") - if (split.size == 2 && stack.getLore().last() == "§8✖ Not completed yet!") { + if (split.size == 2 && lorePatterns.matches(stack.getLore().last())) { inventoryUnfound.add(split.last()) } } @@ -159,7 +171,8 @@ object EnigmaSoulWaypoints { fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return val message = event.message.removeColor().trim() - if (message == "You have already found that Enigma Soul!" || message == "SOUL! You unlocked an Enigma Soul!") { + + if (messagePatterns.matches(message)) { hideClosestSoul() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt index 0ce2d0cb55bd..1d5e35ac73af 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt @@ -19,10 +19,15 @@ class HighlightPlaceableNpcs { private val config get() = SkyHanniMod.feature.misc.stranded + private val patternGroup = RepoPattern.group("stranded.highlightplacement") private val locationPattern by RepoPattern.pattern( - "stranded.highlightplacement.location", + "location", "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]" ) + private val lorePattern by patternGroup.pattern( + "lore", + "§e(this NPC!|your location!)$" + ) private var inInventory = false private var highlightedItems = emptyList() @@ -67,7 +72,7 @@ class HighlightPlaceableNpcs { private fun isPlaceableNpc(lore: List): Boolean { // Checking if NPC & placeable - if (lore.isEmpty() || !(lore.last() == "§ethis NPC!" || lore.last() == "§eyour location!")) { + if (lorePattern.matches(lore.last())) { return false }