From dc337e273420fbc987fabdfb07f42a78116da164 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 17 Sep 2023 10:54:24 +0200 Subject: migrate city project config into event and real time, tps display, and custom text box config into gui --- .../hannibal2/skyhanni/features/misc/CustomTextBox.kt | 8 +++++++- .../hannibal2/skyhanni/features/misc/TimeFeatures.kt | 7 +++++-- .../at/hannibal2/skyhanni/features/misc/TpsCounter.kt | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt index 7c05c6af1..eb78def01 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.utils.LorenzUtils @@ -9,7 +10,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class CustomTextBox { - private val config get() = SkyHanniMod.feature.misc.textBox + private val config get() = SkyHanniMod.feature.gui.customTextBox private var display = listOf() @SubscribeEvent @@ -30,4 +31,9 @@ class CustomTextBox { config.position.renderStrings(display, posLabel = "Custom Text Box") } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "misc.textBox", "gui.customTextBox") + } } \ 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 index 0ec010924..4f23411a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt @@ -17,7 +17,7 @@ import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.seconds class TimeFeatures { - private val config get() = SkyHanniMod.feature.misc.timeConfigs + private val config get() = SkyHanniMod.feature.gui private val winterConfig get() = SkyHanniMod.feature.event.winter private val format = SimpleDateFormat("HH:mm:ss") @@ -31,7 +31,7 @@ class TimeFeatures { if (!LorenzUtils.inSkyBlock) return if (config.realTime) { - config.realTimePos.renderString(format.format(System.currentTimeMillis()), posLabel = "Real Time") + config.realTimePosition.renderString(format.format(System.currentTimeMillis()), posLabel = "Real Time") } if (winterConfig.islandCloseTime && IslandType.WINTER.isInIsland()) { @@ -50,5 +50,8 @@ class TimeFeatures { fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "misc.timeConfigs.winterTime", "event.winter.islandCloseTime") event.move(2, "misc.timeConfigs.winterTimePos", "event.winter.islandCloseTimePosition") + + event.move(2, "misc.timeConfigs.realTime", "gui.realTime") + event.move(2, "misc.timeConfigs.realTimePos", "gui.realTimePosition") } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt index 864bdde72..726771f8c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PacketEvent @@ -12,6 +13,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer class TpsCounter { + private val config get() = SkyHanniMod.feature.gui + companion object { private const val minDataAmount = 5 private const val waitAfterWorldSwitch = 6 @@ -27,7 +30,7 @@ class TpsCounter { init { fixedRateTimer(name = "skyhanni-tps-counter-seconds", period = 1000L) { if (!LorenzUtils.inSkyBlock) return@fixedRateTimer - if (!SkyHanniMod.feature.misc.tpsDisplayEnabled) return@fixedRateTimer + if (!config.tpsDisplay) return@fixedRateTimer if (packetsFromLastSecond == 0) return@fixedRateTimer if (ignoreFirstTicks > 0) { @@ -57,7 +60,7 @@ class TpsCounter { } fixedRateTimer(name = "skyhanni-tps-counter-ticks", period = 50L) { if (!LorenzUtils.inSkyBlock) return@fixedRateTimer - if (!SkyHanniMod.feature.misc.tpsDisplayEnabled) return@fixedRateTimer + if (!config.tpsDisplay) return@fixedRateTimer if (hasPacketReceived) { hasPacketReceived = false @@ -76,16 +79,22 @@ class TpsCounter { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { - if (!SkyHanniMod.feature.misc.tpsDisplayEnabled) return + if (!config.tpsDisplay) return hasPacketReceived = true } @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.misc.tpsDisplayEnabled) return + if (!config.tpsDisplay) return + + config.tpsDisplayPosition.renderString(display, posLabel = "Tps Display") + } - SkyHanniMod.feature.misc.tpsDisplayPosition.renderString(display, posLabel = "Tps Display") + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "misc.tpsDisplayEnabled", "gui.tpsDisplay") + event.move(2, "misc.tpsDisplayPosition", "gui.tpsDisplayPosition") } private fun getColor(tps: Double): String { -- cgit