aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/CompactBingoChat.kt112
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/CompactSplashPotionMessage.kt35
2 files changed, 147 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/CompactBingoChat.kt
new file mode 100644
index 000000000..236236bb6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/CompactBingoChat.kt
@@ -0,0 +1,112 @@
+package at.hannibal2.skyhanni.features
+
+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/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/CompactSplashPotionMessage.kt
new file mode 100644
index 000000000..04740bbbd
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/CompactSplashPotionMessage.kt
@@ -0,0 +1,35 @@
+package at.hannibal2.skyhanni.features
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.util.ChatComponentText
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class CompactSplashPotionMessage {
+
+ private val POTION_EFFECT_PATTERN =
+ Pattern.compile("§a§lBUFF! §fYou have gained §r(.*)§r§f! Press TAB or type /effects to view your active effects!")
+
+ private val POTION_EFFECT_OTHERS_PATTERN =
+ Pattern.compile("§a§lBUFF! §fYou were splashed by (.*) §fwith §r(.*)§r§f! Press TAB or type /effects to view your active effects!")
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.inSkyblock || !SkyHanniMod.feature.chat.compactPotionMessage) return
+
+ var matcher = POTION_EFFECT_PATTERN.matcher(event.message)
+ if (matcher.matches()) {
+ val name = matcher.group(1)
+ event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$name")
+ }
+
+ matcher = POTION_EFFECT_OTHERS_PATTERN.matcher(event.message)
+ if (matcher.matches()) {
+ val playerName = matcher.group(1)
+ val effectName = matcher.group(2)
+ event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$effectName §7(by $playerName§7)")
+ }
+ }
+} \ No newline at end of file