aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-14 14:07:56 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-14 14:07:56 +0200
commit5f220707f4b0a12addaef0ec80cc389f07d9ffcc (patch)
treeb81533637c810c25bd5ccff54b9bc88dd967aec7 /src/main
parentd1a9b5b3ea2a4a140fc1aa34db3ad8a79822391c (diff)
downloadskyhanni-5f220707f4b0a12addaef0ec80cc389f07d9ffcc.tar.gz
skyhanni-5f220707f4b0a12addaef0ec80cc389f07d9ffcc.tar.bz2
skyhanni-5f220707f4b0a12addaef0ec80cc389f07d9ffcc.zip
code cleanup
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt12
4 files changed, 47 insertions, 33 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
index 9403ebfc2..d7fd4625d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
@@ -94,23 +94,39 @@ public class GUIConfig {
@Expose
public Position realTimePosition = new Position(10, 10, false, true);
- @Expose
- @ConfigOption(name = "In-game Date", desc = "Show the in-game date of SkyBlock (like in Apec, §ebut with mild delays§7).\n(Though this one includes the SkyBlock year!)")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean inGameDateDisplay = true;
@Expose
- public Position inGameDateDisplayPosition = new Position(10, 10, false, true);
+ @ConfigOption(name = "In-Game Date", desc = "")
+ @Accordion
+ public InGameDateConfig inGameDateConfig = new InGameDateConfig();
- @Expose
- @ConfigOption(name = "In-game Date Refresh Rate", desc = "Change the amount of time in seconds you would like to refresh the in-game time display.")
- @ConfigEditorSlider(
- minValue = 1,
- maxValue = 60,
- minStep = 1
- )
- public int inGameDateDisplayRefreshSeconds = 10;
+ public static class InGameDateConfig {
+
+ @Expose
+ @ConfigOption(
+ name = "Enabled",
+ desc = "Show the in-game date of SkyBlock (like in Apec, §ebut with mild delays§7).\n" +
+ "(Though this one includes the SkyBlock year!)"
+ )
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ public Position position = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(
+ name = "Refresh Rate",
+ desc = "Change the time in seconds you would like to refresh the In-Game Date Display."
+ )
+ @ConfigEditorSlider(
+ minValue = 1,
+ maxValue = 60,
+ minStep = 1
+ )
+ public int RefreshSeconds = 10;
+ }
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
index 8c33566d8..24ccef545 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
@@ -1,42 +1,36 @@
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.LorenzTickEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.getFormattedSkyblockTime
+import at.hannibal2.skyhanni.utils.LorenzUtils.formatted
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
-import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordStatus
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
-import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import kotlin.concurrent.fixedRateTimer
class InGameDateDisplay {
- private val config get() = SkyHanniMod.feature.gui
+ private val config get() = SkyHanniMod.feature.gui.inGameDateConfig
private var display = ""
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return
- if (!event.repeatSeconds(config.inGameDateDisplayRefreshSeconds)) return
+ if (!event.repeatSeconds(config.RefreshSeconds)) return
checkDate()
}
private fun checkDate() {
- if (!isEnabled()) return
-
- display = SkyBlockTime.now().getFormattedSkyblockTime()
+ display = SkyBlockTime.now().formatted()
}
@SubscribeEvent
- fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!isEnabled()) return
- config.inGameDateDisplayPosition.renderString(display, posLabel = "In-game Date Display")
+ config.position.renderString(display, posLabel = "In-game Date Display")
}
- fun isEnabled() = LorenzUtils.inSkyBlock && config.inGameDateDisplay
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index fed77fd39..d459200e0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -18,7 +18,7 @@ import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity
-import at.hannibal2.skyhanni.utils.LorenzUtils.getFormattedSkyblockTime
+import at.hannibal2.skyhanni.utils.LorenzUtils.formatted
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -180,7 +180,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
TIME({
- SkyBlockTime.now().getFormattedSkyblockTime()
+ SkyBlockTime.now().formatted()
}),
PROFILE({
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 5dc578856..04881c2b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -108,16 +108,20 @@ object LorenzUtils {
fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis())
- fun SkyBlockTime.getFormattedSkyblockTime(): String {
- val date: SkyBlockTime = SkyBlockTime.now()
+ fun SkyBlockTime.formatted(): String {
+ val date = SkyBlockTime.now()
val hour = if (date.hour > 12) date.hour - 12 else date.hour
val timeOfDay = if (date.hour > 11) "pm" else "am" // hooray for 12-hour clocks
var minute = date.minute.toString()
if (minute.length != 2) {
- minute = minute.padStart(2,'0')
+ minute = minute.padStart(2, '0')
}
- return "${SkyBlockTime.monthName(date.month)} ${date.day}${SkyBlockTime.daySuffix(date.day)}, Year ${date.year} $hour:${minute}$timeOfDay" // Early Winter 1st Year 300, 12:03pm
+ val month = SkyBlockTime.monthName(date.month)
+ val day = date.day
+ val daySuffix = SkyBlockTime.daySuffix(day)
+ val year = date.year
+ return "$month $day$daySuffix, Year $year $hour:${minute}$timeOfDay" // Early Winter 1st Year 300, 12:03pm
}
fun stripVanillaMessage(originalMessage: String): String {