diff options
author | martimavocado <39881008+martimavocado@users.noreply.github.com> | 2023-12-12 00:04:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 01:04:04 +0100 |
commit | 4a355aa7db28ed4db8dddc249b7a1915403be3ff (patch) | |
tree | c89413004450632157fa966fd6b7c8e8ef5323d4 /src/main/java/at/hannibal2/skyhanni | |
parent | 620a072467e5b00ee13f35012531b337c3cc56c7 (diff) | |
download | skyhanni-4a355aa7db28ed4db8dddc249b7a1915403be3ff.tar.gz skyhanni-4a355aa7db28ed4db8dddc249b7a1915403be3ff.tar.bz2 skyhanni-4a355aa7db28ed4db8dddc249b7a1915403be3ff.zip |
Feature: add limbo time PB (#730)
Add limbo time PB. #730
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java | 3 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt | 27 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 6322a3c91..47dcf1ed4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -219,4 +219,7 @@ public class MiscConfig { @Expose public Position inventoryLoadPos = new Position(394, 124, false, true); + + @Expose + public int limboTimePB = 0; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt index cc88ae4d1..dbd8f79b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LimboTimeTracker.kt @@ -3,18 +3,25 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.DurationUnit +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + class LimboTimeTracker { private val config get() = SkyHanniMod.feature.misc private var limboJoinTime = SimpleTimeMark.farPast() private var inLimbo = false + private var shownPB = false + private var oldPB: Duration = 0.seconds @SubscribeEvent fun onChat(event: LorenzChatEvent) { @@ -25,6 +32,15 @@ class LimboTimeTracker { } @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (config.limboTimePB == limboJoinTime.passedSince().toInt(DurationUnit.SECONDS) && !shownPB && inLimbo && config.limboTimePB != 0) { + shownPB = true + oldPB = config.limboTimePB.seconds + LorenzUtils.chat("§d§lPERSONAL BEST§f! You've surpassed your previous record of §e$oldPB§f!") + LorenzUtils.chat("§fKeep it up!") + } + } + @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { if (!inLimbo) return leaveLimbo() @@ -49,7 +65,16 @@ class LimboTimeTracker { if (!isEnabled()) return val passedSince = limboJoinTime.passedSince() val duration = passedSince.format() - LorenzUtils.run { chat("You left the limbo after §b$duration") } + val userLuckMultiplier = 0.000810185 + if (passedSince.toInt(DurationUnit.SECONDS) > config.limboTimePB ) { + oldPB = config.limboTimePB.seconds + config.limboTimePB = passedSince.toInt(DurationUnit.SECONDS) + LorenzUtils.chat("§fYou were AFK in Limbo for §e$duration§f! §d§lPERSONAL BEST§r§f!") + LorenzUtils.chat("§fYour previous Personal Best was §e$oldPB.") + val userLuck = config.limboTimePB * userLuckMultiplier + LorenzUtils.chat("§fYour §aPersonal Bests§f perk is now granting you §a+${String.format("%.2f", userLuck)}✴ SkyHanni User Luck§f!") + } else LorenzUtils.chat("§fYou were AFK in Limbo for §e$duration§f.") + shownPB = false } fun isEnabled() = config.showTimeInLimbo |