From 6ac1fba772a35fb55cd639f8b592968adfbf153b Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Mon, 1 Apr 2024 21:10:57 +0200 Subject: [PATCH] Backend: Removed Old TimeMark (#1322) --- .../event/anniversary/Year300RaffleEvent.kt | 14 +++++++------- .../java/at/hannibal2/skyhanni/utils/TimeMark.kt | 16 ---------------- 2 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt index 0123e94d1aa6..8e22d2a76e72 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt @@ -7,9 +7,9 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.SoundUtils.playSound -import at.hannibal2.skyhanni.utils.TimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.renderables.Renderable import io.github.moulberry.notenoughupdates.util.SkyBlockTime @@ -25,15 +25,15 @@ object Year300RaffleEvent { private val config get() = SkyHanniMod.feature.event.century val displayItem by lazy { NEUItems.getItemStackOrNull("EPOCH_CAKE_ORANGE") ?: ItemStack(Items.clock) } - private var lastTimerReceived = TimeMark.never() - private var lastTimeAlerted = TimeMark.never() + private var lastTimerReceived = SimpleTimeMark.farPast() + private var lastTimeAlerted = SimpleTimeMark.farPast() private var overlay: List? = null @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (event.message == "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!") { - lastTimerReceived = TimeMark.now() + lastTimerReceived = SimpleTimeMark.now() } } @@ -54,15 +54,15 @@ object Year300RaffleEvent { overlay = null return } - val p = lastTimerReceived.passedTime() + val p = lastTimerReceived.passedSince() val timeLeft = if (p > 20.minutes) { 0.seconds } else { 20.minutes - p } - if (p.isFinite() && timeLeft < 1.seconds && lastTimeAlerted.passedTime() > 5.minutes && config.enableActiveAlert) { + if (p.isFinite() && timeLeft < 1.seconds && lastTimeAlerted.passedSince() > 5.minutes && config.enableActiveAlert) { SoundUtils.centuryActiveTimerAlert.playSound() - lastTimeAlerted = TimeMark.now() + lastTimeAlerted = SimpleTimeMark.now() } overlay = listOf( Renderable.itemStack(displayItem), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt deleted file mode 100644 index be5f59322423..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt +++ /dev/null @@ -1,16 +0,0 @@ -package at.hannibal2.skyhanni.utils - -import kotlin.time.Duration -import kotlin.time.Duration.Companion.milliseconds - -data class TimeMark(val long: Long) { - - fun hasNeverHappened() = long == 0L - fun passedTime() = if (long == 0L) Duration.Companion.INFINITE else (System.currentTimeMillis() - long).milliseconds - - companion object { - - fun never() = TimeMark(0) - fun now() = TimeMark(System.currentTimeMillis()) - } -}