aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-18 21:50:55 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-18 21:50:55 +0100
commit869d7a10cb1bf3d471655e96217325a767f7d943 (patch)
treebbab08516ae3351b883404944226a5d0a726b811 /src/main/java/at/hannibal2/skyhanni
parente3a83c160bebdc06b7597b9a19d406468d4b1305 (diff)
downloadskyhanni-869d7a10cb1bf3d471655e96217325a767f7d943.tar.gz
skyhanni-869d7a10cb1bf3d471655e96217325a767f7d943.tar.bz2
skyhanni-869d7a10cb1bf3d471655e96217325a767f7d943.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt21
2 files changed, 14 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
index 3e5072fac..24edae9cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
@@ -47,18 +47,12 @@ object TestCopyBestiaryValues {
if (!SkyHanniMod.feature.dev.debug.copyBestiaryData) return
SkyHanniDebugsAndTests.displayLine = ""
- val backItem = event.inventoryItems[3 + 9 * 5 + 3]
- if (backItem == null) {
- return
- }
+ val backItem = event.inventoryItems[3 + 9 * 5 + 3] ?: return
if (backItem.getLore().none { it.contains("Bestiary Milestone") }) {
return
}
- val rankingItem = event.inventoryItems[3 + 9 * 5 + 2]
- if (rankingItem == null) {
- return
- }
+ val rankingItem = event.inventoryItems[3 + 9 * 5 + 2] ?: return
if (rankingItem.getLore().none { it.contains("Ranking") }) {
return
}
@@ -71,7 +65,7 @@ object TestCopyBestiaryValues {
val name = titleItem.name ?: return
val titleName = name.split(" ").dropLast(1).joinToString(" ")
- val obj: BestiarityObject = BestiarityObject()
+ val obj = BestiarityObject()
obj.name = titleName
obj.texture = titleItem.getSkullTexture() ?: "no texture found"
obj.skullOwner = titleItem.getSkullOwner() ?: "no skullOwner found"
@@ -116,4 +110,4 @@ object TestCopyBestiaryValues {
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(3, "dev.copyBestiaryData", "dev.debug.copyBestiaryData")
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index bccf92e62..d03455ac9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -163,12 +163,10 @@ object NumberUtil {
} else romanSymbols[l] + (this - l).toRoman()
}
- private fun processDecimal(decimal: Int, lastNumber: Int, lastDecimal: Int): Int {
- return if (lastNumber > decimal) {
- lastDecimal - decimal
- } else {
- lastDecimal + decimal
- }
+ private fun processDecimal(decimal: Int, lastNumber: Int, lastDecimal: Int) = if (lastNumber > decimal) {
+ lastDecimal - decimal
+ } else {
+ lastDecimal + decimal
}
val pattern = "^[0-9]*$".toPattern()
@@ -193,18 +191,19 @@ object NumberUtil {
val multiplier = if (text.endsWith("k")) {
text = text.substring(0, text.length - 1)
- 1_000
+ 1_000.0
} else if (text.endsWith("m")) {
text = text.substring(0, text.length - 1)
- 1_000_000
- }else if (text.endsWith("b")) {
+ 1.milion
+ } else if (text.endsWith("b")) {
text = text.substring(0, text.length - 1)
- 1_000_000_000
- }else 1
+ 1.bilion
+ } else 1.0
val d = text.toDouble()
return (d * multiplier).toLong()
}
val Int.milion get() = this * 1_000_000.0
+ val Int.bilion get() = this * 1_000_000_000.0
val Double.milion get() = (this * 1_000_000.0).toLong()
}