aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/CompactExperimentRewards.kt103
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt2
3 files changed, 110 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java
index 6a1d129a2..53f7aac94 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java
@@ -90,6 +90,12 @@ public class ChatConfig {
public boolean compactBestiaryMessage = true;
@Expose
+ @ConfigOption(name = "Compact Enchanting Rewards", desc = "Compact the rewards gained from Add-ons and Experiments in Experimentation Table, only showing additional information when hovering.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean compactExperimentationTable = false;
+
+ @Expose
@ConfigOption(name = "Arachne Hider", desc = "Hide chat messages about the Arachne Fight while outside of §eArachne's Sanctuary§7.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactExperimentRewards.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactExperimentRewards.kt
new file mode 100644
index 000000000..d1c2d2c46
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactExperimentRewards.kt
@@ -0,0 +1,103 @@
+package at.hannibal2.skyhanni.features.chat
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.milliseconds
+import kotlin.time.Duration.Companion.seconds
+
+@SkyHanniModule
+object CompactExperimentRewards {
+
+ private val config get() = SkyHanniMod.feature.chat
+
+ private var gainedRewards = mutableListOf<String>()
+ private var lastTimeTableOpened = SimpleTimeMark.farPast()
+ private var currentMessage = ""
+
+ private val patternGroup = RepoPattern.group("chat.experiments.compact")
+
+ /**
+ * REGEX-TEST: Superpairs (Metaphysical)
+ * REGEX-TEST: Superpairs Rewards
+ */
+ private val experimentInventoriesPattern by patternGroup.pattern(
+ "inventories",
+ "(?:Superpairs|Chronomatron|Ultrasequencer) (?:\\(.+\\)|➜ Stakes|Rewards)|Experimentation Table",
+ )
+
+ /**
+ * REGEX-TEST: §eYou claimed the §r§dUltrasequencer §r§erewards!
+ * REGEX-TEST: §eYou claimed the §r§cUltrasequencer §r§erewards!
+ */
+ private val claimMessagePattern by patternGroup.pattern(
+ "message",
+ "(?<message>§eYou claimed the §r§.\\S+ §r§erewards!)",
+ )
+
+ /**
+ * REGEX-TEST: §8 +§r§3600k Enchanting Exp
+ * REGEX-TEST: §r§8+§r§3132k Enchanting Exp
+ * REGEX-TEST: §r§8+§r§aThunderlord V
+ * REGEX-TEST: §r§8+§r§3143k Enchanting Exp
+ * REGEX-TEST: §r§8+§r§aGrand Experience Bottle
+ * REGEX-TEST: §r§8+§r§aCaster V
+ */
+ private val experimentsDropPattern by patternGroup.pattern(
+ "drop",
+ "^(?:§8 \\+| §r§8\\+)(?<reward>.*)\$",
+ )
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ if (isEnabled() && experimentInventoriesPattern.matches(InventoryUtils.openInventoryName())) {
+ lastTimeTableOpened = SimpleTimeMark.now()
+ }
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled() || lastTimeTableOpened.passedSince() >= 3.seconds || event.blockedReason != "") return
+
+ val message = event.message
+ claimMessagePattern.matchMatcher(message) {
+ currentMessage = group("message")
+ event.blockedReason = "COMPACT_REWARDS"
+ return
+ }
+ experimentsDropPattern.matchMatcher(message) {
+ val reward = group("reward")
+
+ gainedRewards.add(reward)
+ event.blockedReason = "COMPACT_REWARDS"
+
+ DelayedRun.runDelayed(100.milliseconds) {
+ sendMessage(reward)
+ }
+ }
+ }
+
+ private fun sendMessage(reward: String?) {
+ if (gainedRewards.last() != reward || currentMessage == "") return
+
+ val expList = mutableListOf<String>().apply {
+ gainedRewards.forEach { add("§8+$it") }
+ }
+
+ ChatUtils.hoverableChat(currentMessage, expList, null, false)
+ gainedRewards.clear()
+ currentMessage = ""
+ }
+
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.compactExperimentationTable
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt
index 5c5011c85..8e3c12679 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt
@@ -19,7 +19,7 @@ object SuperpairsClicksAlert {
private var roundsNeeded = -1
private val roundsNeededRegex = Regex("""(?:Chain|Series) of (\d+):""")
private val currentRoundRegex = Regex("""Round: (\d+)""")
- private val targetInventoryNames = arrayOf("Chronomatron", "Ultrasequencer")
+ private val targetInventoryNames = arrayOf("Chronomatron", "c")
@SubscribeEvent
fun onInventoryOpen(event: InventoryOpenEvent) {