diff options
Diffstat (limited to 'src/main/java/at')
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)" + } + } +} |