aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-06 23:51:02 +0100
committerGitHub <noreply@github.com>2024-03-06 23:51:02 +0100
commit0a95a791eb57a546fb5421594abae740faf1dfdb (patch)
tree82bfc13c544a60d496bab081b66ddd73e07d62a3 /src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
parent28430fe85115334fb06fb7e3cc36da819f08dace (diff)
downloadskyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.gz
skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.bz2
skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.zip
Internal Changes: Many small code cleanups (#1101)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
index 1e991605e..0077a6e83 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
+import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -46,10 +47,9 @@ object CollectionAPI {
val stack = event.inventoryItems[4] ?: return
loop@ for (line in stack.getLore()) {
singleCounterPattern.matchMatcher(line) {
- val counter = group("amount").replace(",", "").toLong()
+ val counter = group("amount").formatLong()
val name = inventoryName.split(" ").dropLast(1).joinToString(" ")
- val internalName = NEUItems.getInternalNameOrNull(name) ?: continue@loop
- collectionValue[internalName] = counter
+ collectionValue[NEUInternalName.fromItemName(name)] = counter
}
}
CollectionUpdateEvent().postAndCatch()
@@ -59,7 +59,7 @@ object CollectionAPI {
if (inventoryName == "Boss Collections") return
for ((_, stack) in event.inventoryItems) {
- var name = stack.name?.removeColor() ?: continue
+ var name = stack.name.removeColor()
if (name.contains("Collections")) continue
val lore = stack.getLore()
@@ -71,9 +71,8 @@ object CollectionAPI {
loop@ for (line in lore) {
counterPattern.matchMatcher(line) {
- val counter = group("amount").replace(",", "").toLong()
- val internalName = NEUItems.getInternalNameOrNull(name) ?: continue@loop
- collectionValue[internalName] = counter
+ val counter = group("amount").formatLong()
+ collectionValue[NEUInternalName.fromItemName(name)] = counter
}
}
}