From c8cb6e0267c935cf4c74761d2254e7c12dbc7f68 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 15:33:57 +0100 Subject: Moved bingo feature into own package. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../skyhanni/features/bingo/CompactBingoChat.kt | 112 +++++++++++++++++++++ .../skyhanni/features/misc/CompactBingoChat.kt | 112 --------------------- 3 files changed, 113 insertions(+), 112 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index f6190fb10..71cde563c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarApi; import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod; import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard; import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper; +import at.hannibal2.skyhanni.features.bingo.CompactBingoChat; import at.hannibal2.skyhanni.features.chat.ChatFilter; import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages; import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter; diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt new file mode 100644 index 000000000..db4989621 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt @@ -0,0 +1,112 @@ +package at.hannibal2.skyhanni.features.bingo + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class CompactBingoChat { + + private var blockedSkillLevelUp = false + private var blockedCollectionLevelUp = false + private var collectionLevelUpLastLine: String? = null + private var newArea = 0//0 = nothing, 1 = after first message, 2 = after second message + private var blockedBestiarity = false + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.isBingoProfile) return + if (!SkyHanniMod.feature.bingo.compactChatMessages) return + + onSkillLevelUp(event) + onCollectionLevelUp(event) + onNewAreaDiscovered(event) + onBestiarityUpgrade(event) + } + + private fun onSkillLevelUp(event: LorenzChatEvent) { + val message = event.message + if (message.startsWith(" §r§b§lSKILL LEVEL UP ")) { + blockedSkillLevelUp = true + return + } + if (message == "§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") { + blockedSkillLevelUp = false + return + } + + if (blockedSkillLevelUp) { + if (!message.contains("Access to") && !message.endsWith(" Enchantment")) { + event.blockedReason = "compact skill level up" + } + } + } + + private fun onCollectionLevelUp(event: LorenzChatEvent) { + val message = event.message + if (message.startsWith(" §r§6§lCOLLECTION LEVEL UP ")) { + blockedCollectionLevelUp = true + return + } + if (message == "§e§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") { + blockedCollectionLevelUp = false + return + } + + if (blockedCollectionLevelUp) { + if (message.contains("Trade") || message.contains("Recipe")) { + var text = message.removeColor().replace(" ", "") + if (text == "Trade" || text == "Recipe") { + collectionLevelUpLastLine?.let { LorenzUtils.chat(it) } + } + } else { + event.blockedReason = "compact collection level up" + collectionLevelUpLastLine = message + } + } + } + + private fun onNewAreaDiscovered(event: LorenzChatEvent) { + var message = event.message + + if (message == " §r§6§lNEW AREA DISCOVERED!") { + newArea = 1 + println("new area $newArea $message") + return + } + + if (message != "") { + if (newArea == 1) { + newArea = 2 + println("new area $newArea $message") + return + } + + if (newArea == 2) { + if (message.startsWith("§7 ■ §r") || message.startsWith(" §r")) { + event.blockedReason = "compact new area discovered" + } else { + newArea = 0 + println("new area $newArea $message") + } + } + } + } + + private fun onBestiarityUpgrade(event: LorenzChatEvent) { + val message = event.message + if (message.startsWith(" §r§3§lBESTIARY §b§l")) { + blockedBestiarity = true + return + } + if (message == "§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") { + blockedBestiarity = false + return + } + + if (blockedBestiarity) { + event.blockedReason = "compact bestiarity upgrade" + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt deleted file mode 100644 index a4becd8c4..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt +++ /dev/null @@ -1,112 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class CompactBingoChat { - - private var blockedSkillLevelUp = false - private var blockedCollectionLevelUp = false - private var collectionLevelUpLastLine: String? = null - private var newArea = 0//0 = nothing, 1 = after first message, 2 = after second message - private var blockedBestiarity = false - - @SubscribeEvent - fun onChatMessage(event: LorenzChatEvent) { - if (!LorenzUtils.isBingoProfile) return - if (!SkyHanniMod.feature.bingo.compactChatMessages) return - - onSkillLevelUp(event) - onCollectionLevelUp(event) - onNewAreaDiscovered(event) - onBestiarityUpgrade(event) - } - - private fun onSkillLevelUp(event: LorenzChatEvent) { - val message = event.message - if (message.startsWith(" §r§b§lSKILL LEVEL UP ")) { - blockedSkillLevelUp = true - return - } - if (message == "§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") { - blockedSkillLevelUp = false - return - } - - if (blockedSkillLevelUp) { - if (!message.contains("Access to") && !message.endsWith(" Enchantment")) { - event.blockedReason = "compact skill level up" - } - } - } - - private fun onCollectionLevelUp(event: LorenzChatEvent) { - val message = event.message - if (message.startsWith(" §r§6§lCOLLECTION LEVEL UP ")) { - blockedCollectionLevelUp = true - return - } - if (message == "§e§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") { - blockedCollectionLevelUp = false - return - } - - if (blockedCollectionLevelUp) { - if (message.contains("Trade") || message.contains("Recipe")) { - var text = message.removeColor().replace(" ", "") - if (text == "Trade" || text == "Recipe") { - collectionLevelUpLastLine?.let { LorenzUtils.chat(it) } - } - } else { - event.blockedReason = "compact collection level up" - collectionLevelUpLastLine = message - } - } - } - - private fun onNewAreaDiscovered(event: LorenzChatEvent) { - var message = event.message - - if (message == " §r§6§lNEW AREA DISCOVERED!") { - newArea = 1 - println("new area $newArea $message") - return - } - - if (message != "") { - if (newArea == 1) { - newArea = 2 - println("new area $newArea $message") - return - } - - if (newArea == 2) { - if (message.startsWith("§7 ■ §r") || message.startsWith(" §r")) { - event.blockedReason = "compact new area discovered" - } else { - newArea = 0 - println("new area $newArea $message") - } - } - } - } - - private fun onBestiarityUpgrade(event: LorenzChatEvent) { - val message = event.message - if (message.startsWith(" §r§3§lBESTIARY §b§l")) { - blockedBestiarity = true - return - } - if (message == "§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬") { - blockedBestiarity = false - return - } - - if (blockedBestiarity) { - event.blockedReason = "compact bestiarity upgrade" - } - } -} \ No newline at end of file -- cgit