aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyBlockTime.kt8
2 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt
index 100d93b19..cc0e20efe 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt
@@ -27,7 +27,7 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) {
ErrorManager.logErrorStateWithData(
"Problem with item rarity detected.",
"Trying to get an item rarity below common",
- "ordinal" to ordinal
+ "ordinal" to ordinal,
)
}
return rarityBelow
@@ -39,7 +39,7 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) {
ErrorManager.logErrorStateWithData(
"Problem with item rarity detected.",
"Trying to get an item rarity above special",
- "ordinal" to ordinal
+ "ordinal" to ordinal,
)
}
return rarityBelow
@@ -50,6 +50,7 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) {
companion object {
fun getById(id: Int) = if (entries.size > id) entries[id] else null
- fun getByName(name: String) = entries.firstOrNull { it.name == name }
+
+ fun getByName(name: String): LorenzRarity? = entries.find { it.name.equals(name, ignoreCase = true) }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockTime.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockTime.kt
index 1fc21df52..6d52de55c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockTime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockTime.kt
@@ -28,15 +28,19 @@ data class SkyBlockTime(
companion object {
private const val SKYBLOCK_EPOCH_START_MILLIS = 1559829300000L // Day 1, Year 1
const val SKYBLOCK_YEAR_MILLIS = 124 * 60 * 60 * 1000L
+ const val SKYBLOCK_SEASON_MILLIS = SKYBLOCK_YEAR_MILLIS / 4
private const val SKYBLOCK_MONTH_MILLIS = SKYBLOCK_YEAR_MILLIS / 12
- private const val SKYBLOCK_DAY_MILLIS = SKYBLOCK_MONTH_MILLIS / 31
- private const val SKYBLOCK_HOUR_MILLIS = SKYBLOCK_DAY_MILLIS / 24
+ const val SKYBLOCK_DAY_MILLIS = SKYBLOCK_MONTH_MILLIS / 31
+ const val SKYBLOCK_HOUR_MILLIS = SKYBLOCK_DAY_MILLIS / 24
private const val SKYBLOCK_MINUTE_MILLIS = SKYBLOCK_HOUR_MILLIS / 60
private const val SKYBLOCK_SECOND_MILLIS = SKYBLOCK_MINUTE_MILLIS / 60
fun fromInstant(instant: Instant): SkyBlockTime =
calculateSkyBlockTime(instant.toEpochMilli() - SKYBLOCK_EPOCH_START_MILLIS)
+ fun fromSbYear(year: Int): SkyBlockTime =
+ fromInstant(Instant.ofEpochMilli(SKYBLOCK_EPOCH_START_MILLIS + (SKYBLOCK_YEAR_MILLIS * year)))
+
fun now(): SkyBlockTime = fromInstant(Instant.now())
private fun calculateSkyBlockTime(realMillis: Long): SkyBlockTime {