aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-07-06 00:37:46 +0200
committerLinnea Gräf <nea@nea.moe>2025-07-06 00:37:46 +0200
commit44b817f7b9852f8974b652c126e1e9aacc5475ac (patch)
treec4f1f4df6ebd5f8a8bf16b6eb7c741da03db1ea3 /src/main/kotlin/util
parent4140a24a0b15b9d3a112ebe934ed7929ce5ffd04 (diff)
downloadFirmament-44b817f7b9852f8974b652c126e1e9aacc5475ac.tar.gz
Firmament-44b817f7b9852f8974b652c126e1e9aacc5475ac.tar.bz2
Firmament-44b817f7b9852f8974b652c126e1e9aacc5475ac.zip
fix: potion effects in exporter
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r--src/main/kotlin/util/SkyblockId.kt7
-rw-r--r--src/main/kotlin/util/StringUtil.kt6
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt
index b4d583a..051ca86 100644
--- a/src/main/kotlin/util/SkyblockId.kt
+++ b/src/main/kotlin/util/SkyblockId.kt
@@ -251,10 +251,11 @@ val ItemStack.skyBlockId: SkyblockId?
val potionName = extraAttributes.getString("potion_name").getOrNull()
val potionLevel = extraAttributes.getInt("potion_level").getOrNull()
val potionType = extraAttributes.getString("potion_type").getOrNull()
+ fun String.potionNormalize() = uppercase().replace(" ", "_")
when {
- potionName != null -> SkyblockId("POTION_${potionName.uppercase()};$potionLevel")
- potionData != null -> SkyblockId("POTION_${potionData.uppercase()};$potionLevel")
- potionType != null -> SkyblockId("POTION_${potionType.uppercase()}")
+ potionName != null -> SkyblockId("POTION_${potionName.potionNormalize()};$potionLevel")
+ potionData != null -> SkyblockId("POTION_${potionData.potionNormalize()};$potionLevel")
+ potionType != null -> SkyblockId("POTION_${potionType.potionNormalize()}")
else -> SkyblockId("WATER_BOTTLE")
}
}
diff --git a/src/main/kotlin/util/StringUtil.kt b/src/main/kotlin/util/StringUtil.kt
index dc98dc0..50c5367 100644
--- a/src/main/kotlin/util/StringUtil.kt
+++ b/src/main/kotlin/util/StringUtil.kt
@@ -5,6 +5,12 @@ object StringUtil {
return splitToSequence(" ") // TODO: better boundaries
}
+ fun String.camelWords(): Sequence<String> {
+ return splitToSequence(camelWordStart)
+ }
+
+ private val camelWordStart = Regex("((?<=[a-z])(?=[A-Z]))| ")
+
fun parseIntWithComma(string: String): Int {
return string.replace(",", "").toInt()
}