aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsayomaki <sayomayomaki@gmail.com>2024-06-09 18:07:10 +0800
committerGitHub <noreply@github.com>2024-06-09 12:07:10 +0200
commita7ecc57e896693632a65fa341760ebca1ed309c5 (patch)
tree929d57ed155489df2229e41daa27b8bc4f4f4cd9 /src
parent0b7d5ba223657f0a5de33862871a2355e7235c18 (diff)
downloadskyhanni-a7ecc57e896693632a65fa341760ebca1ed309c5.tar.gz
skyhanni-a7ecc57e896693632a65fa341760ebca1ed309c5.tar.bz2
skyhanni-a7ecc57e896693632a65fa341760ebca1ed309c5.zip
Feature: Add chocolate production time for stray rabbits (#1978)
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt38
2 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
index cbd43b214..ae36b2a51 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
@@ -99,6 +99,12 @@ public class ChocolateFactoryConfig {
public boolean showDuplicateTime = false;
@Expose
+ @ConfigOption(name = "Stray Rabbit Time", desc = "Show the production time of chocolate gained from stray rabbits.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean showStrayTime = false;
+
+ @Expose
@ConfigOption(name = "Time Tower Usage Warning", desc = "Notification when you have a new time tower usage available and " +
"continuously warn when your time tower is full.")
@ConfigEditorBoolean
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt
new file mode 100644
index 000000000..0c785c761
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt
@@ -0,0 +1,38 @@
+package at.hannibal2.skyhanni.features.inventory.chocolatefactory
+
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
+import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
+import at.hannibal2.skyhanni.utils.TimeUtils.format
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+@SkyHanniModule
+object ChocolateFactoryTooltipStray {
+ private val config get() = ChocolateFactoryAPI.config
+
+ /**
+ * REGEX-TEST: §7You gained §6+2,465,018 Chocolate§7!
+ * REGEX-TEST: §7gained §6+30,292 Chocolate§7!
+ * REGEX-TEST: §7§6+36,330 Chocolate§7!
+ */
+ private val chocolateGainedPattern by ChocolateFactoryAPI.patternGroup.pattern(
+ "rabbit.stray",
+ "(?:§.)+(?:You )?(?:gained )?§6\\+(?<amount>[\\d,]+) Chocolate§7!"
+ )
+
+ @SubscribeEvent(priority = EventPriority.HIGH)
+ fun onTooltip(event: LorenzToolTipEvent) {
+ if (!ChocolateFactoryAPI.inChocolateFactory) return
+ if (!config.showStrayTime) return
+ if (event.slot.slotNumber > 26 || event.slot.slotNumber == ChocolateFactoryAPI.infoIndex) return
+
+ val tooltip = event.toolTip
+ tooltip.matchFirst(chocolateGainedPattern) {
+ val amount = group("amount").formatLong()
+ val format = ChocolateFactoryAPI.timeUntilNeed(amount + 1).format(maxUnits = 2)
+ tooltip[tooltip.lastIndex] += " §7(§a+§b$format §aof production§7)"
+ }
+ }
+}