aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt2
3 files changed, 31 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
index 8f68c2fa0..1193cae1c 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
@@ -29,6 +29,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchFirst
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.StringUtils.removeNonAscii
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.annotations.Expose
import net.minecraft.item.ItemStack
@@ -278,7 +279,7 @@ object SackAPI {
}
sackListInternalNames = uniqueSackItems.map { it.asString() }.toSet()
- sackListNames = uniqueSackItems.map { it.itemNameWithoutColor.uppercase() }.toSet()
+ sackListNames = uniqueSackItems.map { it.itemNameWithoutColor.removeNonAscii().trim().uppercase() }.toSet()
}
private fun updateSacks(changes: SackChangeEvent) {
@@ -352,21 +353,21 @@ object SackAPI {
var roughPrice: Long = 0,
var flawedPrice: Long = 0,
var finePrice: Long = 0,
- ): AbstractSackItem()
+ ) : AbstractSackItem()
data class SackRune(
var stack: ItemStack? = null,
var lvl1: Int = 0,
var lvl2: Int = 0,
var lvl3: Int = 0,
- ): AbstractSackItem()
+ ) : AbstractSackItem()
data class SackOtherItem(
var internalName: NEUInternalName = NEUInternalName.NONE,
var colorCode: String = "",
var total: Int = 0,
var magmaFish: Int = 0,
- ): AbstractSackItem()
+ ) : AbstractSackItem()
abstract class AbstractSackItem(
var stored: Int = 0,
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt
index 53d9c5519..9c8f0f389 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemNameResolver.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
+import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery
@@ -22,6 +23,29 @@ object ItemNameResolver {
resolveEnchantmentByName(itemName)?.let {
return itemNameCache.getOrPut(lowercase) { fixEnchantmentName(it) }
}
+ if (itemName.endsWith("gemstone", ignoreCase = true)) {
+ val split = lowercase.split(" ")
+ if (split.size == 3) {
+ val gemstoneQuery = "${
+ when (split[1]) {
+ "jade", "peridot", "citrine" -> '☘'
+ "amethyst" -> '❈'
+ "ruby" -> '❤'
+ "amber" -> '⸕'
+ "opal" -> '❂'
+ "topaz" -> '✧'
+ "onyx" -> '☠'
+ "sapphire" -> '✎'
+ "aquamarine" -> 'α'
+ "jasper" -> '❁'
+ else -> ' '
+ }
+ }_${split.joinToString("_")}".allLettersFirstUppercase()
+ ItemResolutionQuery.findInternalNameByDisplayName(gemstoneQuery, true)?.let {
+ return itemNameCache.getOrPut(lowercase) { it.asInternalName() }
+ }
+ }
+ }
val internalName = when (itemName) {
"SUPERBOOM TNT" -> "SUPERBOOM_TNT".asInternalName()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index 1057b5c0a..59b82cd8c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -20,11 +20,13 @@ object StringUtils {
private val resetPattern = "(?i)§R".toPattern()
private val sFormattingPattern = "(?i)§S".toPattern()
private val stringColourPattern = "§[0123456789abcdef].*".toPattern()
+ private val asciiPattern = "[^\\x00-\\x7F]".toPattern()
fun String.trimWhiteSpaceAndResets(): String = whiteSpaceResetPattern.matcher(this).replaceAll("")
fun String.trimWhiteSpace(): String = whiteSpacePattern.matcher(this).replaceAll("")
fun String.removeResets(): String = resetPattern.matcher(this).replaceAll("")
fun String.removeSFormattingCode(): String = sFormattingPattern.matcher(this).replaceAll("")
+ fun String.removeNonAscii(): String = asciiPattern.matcher(this).replaceAll("")
fun String.firstLetterUppercase(): String {
if (isEmpty()) return this