Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add chocolate production time for stray rabbits #1978

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public class ChocolateFactoryConfig {
@FeatureToggle
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.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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.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
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).format(maxUnits = 2)
tooltip[tooltip.lastIndex] += " §7(§a+§b$format §aof production§7)"
}
}
}
Loading