aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt60
3 files changed, 66 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index e508cdf0e..7628a2bfb 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -388,6 +388,7 @@ class SkyHanniMod {
loadModule(Translator())
loadModule(GardenPlotBorders())
loadModule(CosmeticFollowingLine())
+ loadModule(SuperpairsClicksAlert())
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
index 9a4d7565a..6a8bc4576 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
@@ -952,6 +952,11 @@ public class MiscConfig {
public boolean accountUpgradeReminder = true;
@Expose
+ @ConfigOption(name = "Superpairs Clicks Alert", desc = "Display an alert when you reach the maximum clicks gained from Chronomatron or Ultrasequencer.")
+ @ConfigEditorBoolean
+ public boolean superpairsClicksAlert = false;
+
+ @Expose
@ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt
new file mode 100644
index 000000000..7bb1acb3a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt
@@ -0,0 +1,60 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.InventoryOpenEvent
+import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class SuperpairsClicksAlert {
+ private val config get() = SkyHanniMod.feature.misc
+
+ private var roundsNeeded = -1
+ private var roundsNeededRegex = Regex("""(?:Chain|Series) of (\d+):""")
+ private var currentRoundRegex = Regex("""Round: (\d+)""")
+ private val targetInventoryNames = arrayOf("Chronomatron", "Ultrasequencer")
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryOpenEvent) {
+ if (!config.superpairsClicksAlert) return
+ if (!targetInventoryNames.any { event.inventoryName.contains(it) }) return
+
+ // player may have drank Metaphysical Serum which reduces clicks needed by up to 3, so need to parse it
+ for (i in 24 downTo 20) {
+ val lore = event.inventoryItems[i]?.getLore() ?: continue
+ if (lore.any { it.contains("Practice mode has no rewards") }) {
+ roundsNeeded = -1
+ break
+ }
+ val match = lore.asReversed().firstNotNullOfOrNull { roundsNeededRegex.find(it.removeColor()) } ?: continue
+ roundsNeeded = match.groups[1]!!.value.toInt()
+ break
+ }
+ }
+
+ @SubscribeEvent
+ fun onInventoryUpdate(event: InventoryUpdatedEvent) {
+ if (!config.superpairsClicksAlert) return
+ if (roundsNeeded == -1) return
+ if (!targetInventoryNames.any { event.inventoryName.contains(it) }) return
+
+ if ( // checks if we have succeeded in either minigame
+ (event.inventoryName.contains("Chronomatron")
+ && ((event.inventoryItems[4]?.displayName?.removeColor()
+ ?.let { currentRoundRegex.find(it) }
+ ?.groups?.get(1)?.value?.toInt() ?: -1) > roundsNeeded))
+
+ || (event.inventoryName.contains("Ultrasequencer")
+ && event.inventoryItems.entries
+ .filter { it.key < 45 }
+ .any { it.value.stackSize > roundsNeeded })
+ ) {
+ SoundUtils.playBeepSound()
+ LorenzUtils.chat("§e[SkyHanni] You have reached the maximum possible clicks!")
+ roundsNeeded = -1
+ }
+ }
+}