aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt34
7 files changed, 25 insertions, 29 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index 1e1ec683a..31c02efab 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.features.misc.update.UpdateManager
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import com.google.gson.GsonBuilder
import com.google.gson.TypeAdapter
@@ -72,7 +73,7 @@ class ConfigManager {
}
override fun read(reader: JsonReader): NEUInternalName {
- return NEUInternalName.from(reader.nextString())
+ return reader.nextString().asInternalName()
}
}.nullSafe())
.enableComplexMapKeySerialization()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
index b40bb81b2..a989d60d1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.gui.inventory.GuiChest
@@ -24,8 +25,7 @@ class BazaarApi {
fun getBazaarDataByName(name: String): BazaarData? =
NEUItems.getInternalNameOrNull(name)?.let { getBazaarDataByInternalName(it) }
- fun getBazaarDataByInternalName(internalName: String) =
- NEUInternalName.from(internalName).getBazaarData()
+ fun getBazaarDataByInternalName(internalName: String) = internalName.asInternalName().getBazaarData()
fun NEUInternalName.getBazaarData() = if (isBazaarItem()) {
holder.getData(this)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt
index dd316e63a..76e4b3f77 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt
@@ -69,7 +69,7 @@ class BazaarDataHolder {
val npcPrice = npcPrices[internalName].let {
if (it == null) {
if (!ignoreNoNpcPrice(internalName.asString())) {
- LorenzUtils.debug("NPC price not found for item '$internalName'")
+ LorenzUtils.debug("NPC price not found for '$internalName'")
}
0.0
} else it
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
index 7ff96d699..a7730e257 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
@@ -419,7 +419,7 @@ object EstimatedItemValue {
for ((prefix, number) in stars) {
if (masterStars >= number) {
- price += NEUInternalName.from("${prefix}_MASTER_STAR").getPrice()
+ price += "${prefix}_MASTER_STAR".asInternalName().getPrice()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 06fdf7f11..14bb25231 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
import at.hannibal2.skyhanni.utils.StringUtils.matchRegex
@@ -120,7 +121,7 @@ object ItemUtils {
fun ItemStack.getInternalNameOrNull_new() = getInternalName_new().takeIf { it.asString() != "" }
- fun ItemStack.getInternalName_new() = NEUInternalName.from(getInternalName())
+ fun ItemStack.getInternalName_new() = getInternalName().asInternalName()
fun ItemStack.getInternalName(): String {
if (name == "§fWisp's Ice-Flavored Water I Splash Potion") {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
index c2269e186..89741cbef 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
@@ -5,10 +5,8 @@ class NEUInternalName private constructor(private val internalName: String) {
companion object {
private val map = mutableMapOf<String, NEUInternalName>()
- fun String.asInternalName() = from(this)
-
- fun from(name: String): NEUInternalName {
- val internalName = name.uppercase()
+ fun String.asInternalName(): NEUInternalName {
+ val internalName = uppercase()
return map.getOrPut(internalName) { NEUInternalName(internalName) }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index e3674efd0..446eeffc0 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -73,9 +73,9 @@ object NEUItems {
fun readAllNeuItems(): Map<String, NEUInternalName> {
allInternalNames.clear()
val map = mutableMapOf<String, NEUInternalName>()
- for (internalNameRaw in manager.itemInformation.keys) {
- val name = manager.createItem(internalNameRaw).displayName.removeColor().lowercase()
- val internalName = NEUInternalName.from(internalNameRaw)
+ for (rawInternalName in manager.itemInformation.keys) {
+ val name = manager.createItem(rawInternalName).displayName.removeColor().lowercase()
+ val internalName = rawInternalName.asInternalName()
map[name] = internalName
allInternalNames.add(internalName)
}
@@ -91,7 +91,7 @@ object NEUItems {
}
if (itemName == "§cmissing repo item") {
- val name = NEUInternalName.from("MISSING_ITEM")
+ val name = "MISSING_ITEM".asInternalName()
itemNameCache[lowercase] = name
return name
}
@@ -101,15 +101,13 @@ object NEUItems {
itemNameCache[itemName] = enchantmentName
return enchantmentName
}
- val internalNameRaw = ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) ?: return null
+ var rawInternalName = ItemResolutionQuery.findInternalNameByDisplayName(itemName, false) ?: return null
// This fixes a NEU bug with §9Hay Bale (cosmetic item)
// TODO remove workaround when this is fixed in neu
- val internalName = if (internalNameRaw == "HAY_BALE") {
- NEUInternalName.from("HAY_BLOCK")
- } else {
- NEUInternalName.from(internalNameRaw)
- }
+ rawInternalName = if (rawInternalName == "HAY_BALE") "HAY_BLOCK" else rawInternalName
+
+ val internalName = rawInternalName.asInternalName()
itemNameCache[lowercase] = internalName
return internalName
@@ -119,10 +117,10 @@ object NEUItems {
// Workaround for duplex
"ULTIMATE_DUPLEX;(?<tier>.*)".toPattern().matchMatcher(originalName) {
val tier = group("tier")
- return NEUInternalName.from("ULTIMATE_REITERATE;$tier")
+ return "ULTIMATE_REITERATE;$tier".asInternalName()
}
- return NEUInternalName.from(originalName)
+ return originalName.asInternalName()
}
private fun turboCheck(text: String): String {
@@ -150,10 +148,8 @@ object NEUItems {
fun getPriceOrNull(internalName: String, useSellingPrice: Boolean = false) =
internalName.asInternalName().getPriceOrNull(useSellingPrice)
- fun transHypixelNameToInternalName(hypixelId: String): NEUInternalName {
- val name = manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId)
- return NEUInternalName.from(name)
- }
+ fun transHypixelNameToInternalName(hypixelId: String) =
+ manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId).asInternalName()
fun NEUInternalName.getPrice(useSellingPrice: Boolean = false): Double {
val string = asString()
@@ -174,16 +170,16 @@ object NEUItems {
}
fun getPrice(internalName: String, useSellingPrice: Boolean = false) =
- NEUInternalName.from(internalName).getPrice(useSellingPrice)
+ internalName.asInternalName().getPrice(useSellingPrice)
fun NEUInternalName.getItemStackOrNull() = ItemResolutionQuery(manager)
.withKnownInternalName(asString())
.resolveToItemStack()?.copy()
- fun getItemStackOrNull(internalName: String) = NEUInternalName.from(internalName).getItemStackOrNull()
+ fun getItemStackOrNull(internalName: String) = internalName.asInternalName().getItemStackOrNull()
fun getItemStack(internalName: String, definite: Boolean = false): ItemStack =
- NEUInternalName.from(internalName).getItemStack(definite)
+ internalName.asInternalName().getItemStack(definite)
fun NEUInternalName.getItemStack(definite: Boolean = false): ItemStack =
getItemStackOrNull() ?: run {