From 9e97dff77ac15011d42c6db684e3f686b2efa926 Mon Sep 17 00:00:00 2001 From: MTOnline69 <97001154+MTOnline69@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:42:44 +0100 Subject: Improvement: Stop Time Tower Usage Warning spam (#2730) --- .../ChocolateFactoryTimeTowerManager.kt | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt index 30af77ac8..39e0df3da 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration -import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds @@ -23,6 +22,7 @@ object ChocolateFactoryTimeTowerManager { private val profileStorage get() = ChocolateFactoryAPI.profileStorage private var lastTimeTowerWarning = SimpleTimeMark.farPast() + private var warnedAboutLatestCharge = false private var wasTimeTowerRecentlyActive = false @SubscribeEvent @@ -45,24 +45,30 @@ object ChocolateFactoryTimeTowerManager { if (ChocolateFactoryAPI.inChocolateFactory) return - val nextCharge = profileStorage.nextTimeTower - - if (nextCharge.isInPast() && !nextCharge.isFarPast() && currentCharges() < maxCharges()) { - profileStorage.currentTimeTowerUses++ - - val nextTimeTower = profileStorage.nextTimeTower + profileStorage.timeTowerCooldown.hours - profileStorage.nextTimeTower = nextTimeTower + if (timeTowerFullTimeMark().isInPast()) { + profileStorage.currentTimeTowerUses = maxCharges() + } else { + var nextCharge = profileStorage.nextTimeTower + while (nextCharge.isInPast() && !nextCharge.isFarPast()) { + profileStorage.currentTimeTowerUses++ + nextCharge += ChocolateFactoryAPI.timeTowerChargeDuration() + profileStorage.nextTimeTower = nextCharge + warnedAboutLatestCharge = false + } + } + if (currentCharges() < maxCharges()) { if (!config.timeTowerWarning || timeTowerActive()) return + if (warnedAboutLatestCharge) return ChatUtils.clickableChat( - "Your Time Tower has another charge available §7(${timeTowerCharges()})§e, " + + "Your Time Tower has an available charge §7(${timeTowerCharges()})§e. " + "Click here to use one.", onClick = { HypixelCommands.chocolateFactory() }, HOVER_TEXT, ) SoundUtils.playBeepSound() lastTimeTowerWarning = SimpleTimeMark.now() - return + warnedAboutLatestCharge = true } checkTimeTowerWarning(false) } -- cgit