diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt | 26 |
1 files changed, 16 insertions, 10 deletions
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) } |