aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt8
6 files changed, 10 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
index 06007c80c..b611f77ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt
@@ -24,7 +24,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
-import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraft.client.Minecraft
import net.minecraft.init.Blocks
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -172,7 +172,7 @@ object GriffinBurrowHelper {
if (config.inquisitorSharing.showDespawnTime) {
val spawnTime = inquis.spawnTime
- val format = TimeUtils.formatDuration(75.seconds - spawnTime.passedSince())
+ val format = (75.seconds - spawnTime.passedSince()).format()
event.drawDynamicText(location.add(y = 1), "§eDespawns in §b$format", 1.6, yOff = 18f)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt
index bee0d1b09..91c892ca2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt
@@ -11,7 +11,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon
import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems
import at.hannibal2.skyhanni.utils.StringUtils.matches
-import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
@@ -82,7 +82,7 @@ class JyrreTimer {
if (duration <= 0.seconds && config.showInactive) {
add("§cInactive!")
} else {
- val format = TimeUtils.formatDuration(duration)
+ val format = duration.format()
add("§b$format")
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index 5097e4366..d62353f49 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -24,7 +24,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
-import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.TimeUtils.format
import com.google.gson.Gson
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import kotlinx.coroutines.Dispatchers
@@ -340,7 +340,7 @@ object GardenNextJacobContest {
list.addCropIcon(crop, highlight = (crop == boostedCrop))
nextContestCrops.add(crop)
}
- val format = TimeUtils.formatDuration(duration)
+ val format = duration.format()
list.add("§7(§b$format§7)")
return list
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
index 04e2bee61..39eddc488 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
@@ -10,11 +10,11 @@ import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.TimeUtils.format
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.Collections
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
-import kotlin.time.DurationUnit
class ComposterDisplay {
private val config get() = GardenAPI.config.composters
@@ -75,9 +75,8 @@ class ComposterDisplay {
private fun addComposterEmptyTime(emptyTime: Duration?): List<Any> {
return if (emptyTime != null) {
- val millis = emptyTime.toDouble(DurationUnit.MILLISECONDS).toLong()
- GardenAPI.storage?.composterEmptyTime = System.currentTimeMillis() + millis
- val format = TimeUtils.formatDuration(millis, maxUnits = 2)
+ GardenAPI.storage?.composterEmptyTime = System.currentTimeMillis() + emptyTime.inWholeMilliseconds
+ val format = emptyTime.format()
listOf(NEUItems.getItemStack("BUCKET"), "§b$format")
} else {
listOf("§cOpen Composter Upgrades!")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
index 4c5408573..67a450146 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt
@@ -169,7 +169,7 @@ class GardenVisitorTimer {
SoundUtils.playBeepSound()
}
- val formatDuration = TimeUtils.formatDuration(millis)
+ val formatDuration = millis.format()
val next = if (queueFull && (!isSixthVisitorEnabled() || millis.isNegative())) "§cQueue Full!" else {
"Next in §$formatColor$formatDuration$extraSpeed"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
index 6aa418f85..67463db18 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
@@ -15,14 +15,6 @@ object TimeUtils {
private val pattern =
"(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?".toPattern()
- fun formatDuration(
- duration: Duration,
- biggestUnit: TimeUnit = TimeUnit.YEAR,
- showMilliSeconds: Boolean = false,
- longName: Boolean = false,
- maxUnits: Int = -1
- ): String = duration.format(biggestUnit, showMilliSeconds, longName, maxUnits)
-
fun Duration.format(
biggestUnit: TimeUnit = TimeUnit.YEAR,
showMilliSeconds: Boolean = false,