diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-09-07 07:05:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 07:05:45 +0200 |
commit | 02c9ce15e053d5d0751c32ea3ef481c9eef7a904 (patch) | |
tree | ee7f200d2e4ba2555aaa54b336d3d0ecbc47558f /src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt | |
parent | 78ce109b8fe6291340067771217b6965d82d76c2 (diff) | |
download | skyhanni-02c9ce15e053d5d0751c32ea3ef481c9eef7a904.tar.gz skyhanni-02c9ce15e053d5d0751c32ea3ef481c9eef7a904.tar.bz2 skyhanni-02c9ce15e053d5d0751c32ea3ef481c9eef7a904.zip |
Feature: /shedittracker (#2448)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt index 18568869a..6d0eb33e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull + class NEUInternalName private constructor(private val internalName: String) { companion object { @@ -20,7 +22,25 @@ class NEUInternalName private constructor(private val internalName: String) { } fun fromItemNameOrNull(itemName: String): NEUInternalName? = - ItemNameResolver.getInternalNameOrNull(itemName.removeSuffix(" Pet")) + ItemNameResolver.getInternalNameOrNull(itemName.removeSuffix(" Pet")) ?: getCoins(itemName) + + fun fromItemNameOrInternalName(itemName: String): NEUInternalName = + fromItemNameOrNull(itemName) ?: itemName.asInternalName() + + private fun getCoins(itemName: String): NEUInternalName? = if (isCoins(itemName)) SKYBLOCK_COIN else null + + private fun isCoins(itemName: String): Boolean = + itemName.lowercase().let { + when (it) { + "coin", "coins", + "skyblock coin", "skyblock coins", + "skyblock_coin", "skyblock_coins", + -> true + + else -> false + } + } + fun fromItemName(itemName: String): NEUInternalName = fromItemNameOrNull(itemName) ?: run { val name = "itemName:$itemName" @@ -52,4 +72,6 @@ class NEUInternalName private constructor(private val internalName: String) { fun replace(oldValue: String, newValue: String) = internalName.replace(oldValue.uppercase(), newValue.uppercase()).asInternalName() + + fun isKnownItem(): Boolean = getItemStackOrNull() != null || this == SKYBLOCK_COIN } |