diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-29 12:17:44 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-29 12:17:44 +0200 |
commit | cc59cccadf38cb263d5c035ac4f0b74d9adfe1ca (patch) | |
tree | c1873ef72fe65250482930be1a2e335377a8c0c7 /src/main/java/at/hannibal2/skyhanni/features/misc | |
parent | 5d51537458f15aba4c2471de4749a67ca9cbe044 (diff) | |
download | skyhanni-cc59cccadf38cb263d5c035ac4f0b74d9adfe1ca.tar.gz skyhanni-cc59cccadf38cb263d5c035ac4f0b74d9adfe1ca.tar.bz2 skyhanni-cc59cccadf38cb263d5c035ac4f0b74d9adfe1ca.zip |
Added Winter Time
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt | 24 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt | 46 |
2 files changed, 46 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt deleted file mode 100644 index c5bda78c8..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/RealTime.kt +++ /dev/null @@ -1,24 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.text.SimpleDateFormat - -class RealTime { - - private val format = SimpleDateFormat("HH:mm:ss") - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { - if (!isEnabled()) return - - SkyHanniMod.feature.misc.realTimePos.renderString(format.format(System.currentTimeMillis()), posLabel = "Real Time") - } - - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.realTime - } -}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt new file mode 100644 index 000000000..e956791bf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt @@ -0,0 +1,46 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RecalculatingValue +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils.format +import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.text.SimpleDateFormat +import kotlin.time.Duration.Companion.days +import kotlin.time.Duration.Companion.seconds + +class TimeFeatures { + private val config get() = SkyHanniMod.feature.misc.time + + private val format = SimpleDateFormat("HH:mm:ss") + + private val startOfNextYear = RecalculatingValue(1.seconds) { + SkyBlockTime(year = SkyBlockTime.now().year + 1).asTimeMark() + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!LorenzUtils.inSkyBlock) return + + if (config.realTime) { + config.realTimePos.renderString(format.format(System.currentTimeMillis()), posLabel = "Real Time") + } + + if (config.winterTime && IslandType.WINTER.isInIsland()) { + val timeTillNextYear = startOfNextYear.getValue().timeUntil() + val alreadyInNextYear = timeTillNextYear > 5.days + val text = if (alreadyInNextYear) { + "§fJerry's Workshop §cis closing!" + } else { + "§fJerry's Workshop §ecloses in §b${timeTillNextYear.format()}" + } + config.winterTimePos.renderString(text, posLabel = "Winter Time") + } + } +}
\ No newline at end of file |