diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt | 14 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt | 16 |
2 files changed, 7 insertions, 23 deletions
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 0123e94d1..8e22d2a76 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<Any>? = 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 be5f59322..000000000 --- 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()) - } -} |