From 461fa9c4ece3a85b9cac7f7247fcc0c71a4a31e3 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 4 Sep 2024 11:19:12 +0200 Subject: Improvement: Allow turning off exact minutes on custom scoreboard (#2443) --- .../config/features/gui/customscoreboard/DisplayConfig.java | 5 +++++ .../skyhanni/features/gui/customscoreboard/ScoreboardElements.kt | 7 ++++++- src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java index e2c6dd6fa..0d61401ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java @@ -129,6 +129,11 @@ public class DisplayConfig { @ConfigEditorBoolean public boolean skyblockTime24hFormat = false; + @Expose + @ConfigOption(name = "SkyBlock Time Exact Minutes", desc = "Display the exact minutes in the SkyBlock time, rather than only 10 minute increments.") + @ConfigEditorBoolean + public boolean skyblockTimeExactMinutes = true; + @Expose @ConfigOption(name = "Line Spacing", desc = "The amount of space between each line.") @ConfigEditorSlider(minValue = 0, maxValue = 20, minStep = 1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 5753a6fd6..a58a7efc4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -577,7 +577,12 @@ private fun getTimeDisplayPair(): List { getGroupFromPattern(CustomScoreboard.activeLines, ScoreboardPattern.timePattern, "symbol") ?: "" return listOf( "ยง7" + SkyBlockTime.now() - .formatted(dayAndMonthElement = false, yearElement = false, timeFormat24h = config.display.skyblockTime24hFormat) + + .formatted( + dayAndMonthElement = false, + yearElement = false, + timeFormat24h = config.display.skyblockTime24hFormat, + exactMinutes = config.display.skyblockTimeExactMinutes, + ) + " $symbol" to HorizontalAlignment.LEFT, ) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index 201c294e5..b31bb828b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -105,12 +105,15 @@ object TimeUtils { yearElement: Boolean = true, hoursAndMinutesElement: Boolean = true, timeFormat24h: Boolean = false, + exactMinutes: Boolean = true, ): String { val hour = if (timeFormat24h) this.hour else (this.hour + 11) % 12 + 1 val timeOfDay = if (!timeFormat24h) { if (this.hour > 11) "pm" else "am" } else "" - val minute = this.minute.toString().padStart(2, '0') + val minute = this.minute.let { + if (exactMinutes) it else it - (it % 10) + }.toString().padStart(2, '0') val month = SkyBlockTime.monthName(this.month) val day = this.day val daySuffix = SkyBlockTime.daySuffix(day) -- cgit