aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt12
5 files changed, 77 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index c2cf5a25d..92eba8fb7 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -178,6 +178,7 @@ import at.hannibal2.skyhanni.features.misc.FrozenTreasureTracker
import at.hannibal2.skyhanni.features.misc.HarpFeatures
import at.hannibal2.skyhanni.features.misc.HideArmor
import at.hannibal2.skyhanni.features.misc.HideDamageSplash
+import at.hannibal2.skyhanni.features.misc.InGameDateDisplay
import at.hannibal2.skyhanni.features.misc.JoinCrystalHollows
import at.hannibal2.skyhanni.features.misc.LimboTimeTracker
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
@@ -429,6 +430,7 @@ class SkyHanniMod {
loadModule(FireVeilWandParticles())
loadModule(HideMobNames())
loadModule(HideDamageSplash())
+ loadModule(InGameDateDisplay())
loadModule(ThunderSparksHighlight())
loadModule(BlazeSlayerDaggerHelper())
loadModule(HellionShieldHelper())
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 47b62e9e5..9403ebfc2 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
@@ -95,6 +95,25 @@ public class GUIConfig {
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);
+
+ @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;
+
+
+ @Expose
@ConfigOption(name = "TPS Display", desc = "Show the TPS of the current server, like in Soopy.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
new file mode 100644
index 000000000..8c33566d8
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt
@@ -0,0 +1,42 @@
+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.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 var display = ""
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (!event.repeatSeconds(config.inGameDateDisplayRefreshSeconds)) return
+
+ checkDate()
+ }
+
+ private fun checkDate() {
+ if (!isEnabled()) return
+
+ display = SkyBlockTime.now().getFormattedSkyblockTime()
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!isEnabled()) return
+
+ config.inGameDateDisplayPosition.renderString(display, posLabel = "In-game Date Display")
+ }
+
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.inGameDateDisplay
+}
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 433f468cb..fed77fd39 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,6 +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.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -179,23 +180,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
TIME({
- fun formatNum(num: Int): Int {
- val rem = num % 10
- var returnNum = num - rem // floor()
- if (returnNum == 0) {
- returnNum = "0$num".toInt()
- /**
- * and this is so that if the minute value is ever
- * a single digit (0 after being floored), it displays as 00 because 12:0pm looks bad
- */
- }
- return returnNum
- }
-
- val date: SkyBlockTime = 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
- "${SkyBlockTime.monthName(date.month)} ${date.day}${SkyBlockTime.daySuffix(date.day)}, $hour:${formatNum(date.minute)}$timeOfDay" // Early Winter 1st, 12:00pm
+ SkyBlockTime.now().getFormattedSkyblockTime()
}),
PROFILE({
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 2559e31dd..5dc578856 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -108,6 +108,18 @@ object LorenzUtils {
fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis())
+ fun SkyBlockTime.getFormattedSkyblockTime(): String {
+ val date: SkyBlockTime = 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')
+ }
+
+ return "${SkyBlockTime.monthName(date.month)} ${date.day}${SkyBlockTime.daySuffix(date.day)}, Year ${date.year} $hour:${minute}$timeOfDay" // Early Winter 1st Year 300, 12:03pm
+ }
+
fun stripVanillaMessage(originalMessage: String): String {
var message = originalMessage