Skip to content

Commit

Permalink
Improvement: Stop Time Tower Usage Warning spam (#2730)
Browse files Browse the repository at this point in the history
  • Loading branch information
MTOnline69 authored Oct 16, 2024
1 parent 1d79bb1 commit 9e97dff
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit 9e97dff

Please sign in to comment.