summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-04-12 19:11:02 +0200
committerGitHub <noreply@github.com>2024-04-12 19:11:02 +0200
commit5ff579652ef80207a780a80399be376c345342b0 (patch)
tree6f80311a35d8fd6bb41d63b8ce2758891146d128 /src/main/java/at/hannibal2/skyhanni/features/misc
parent7960d2ad27ac68ea9dcfaf848bd611b13db0af87 (diff)
downloadskyhanni-5ff579652ef80207a780a80399be376c345342b0.tar.gz
skyhanni-5ff579652ef80207a780a80399be376c345342b0.tar.bz2
skyhanni-5ff579652ef80207a780a80399be376c345342b0.zip
Backend: Remove Neu Constant (#1191)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt44
2 files changed, 21 insertions, 39 deletions
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 6106e4c1b..c79c1f8a4 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
@@ -1,9 +1,9 @@
package at.hannibal2.skyhanni.features.misc.items
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
+import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuReforgeStoneJson
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
@@ -28,7 +28,6 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
-import com.google.gson.reflect.TypeToken
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer
import net.minecraft.client.Minecraft
import net.minecraft.init.Items
@@ -43,6 +42,7 @@ object EstimatedItemValue {
private val cache = mutableMapOf<ItemStack, List<List<Any>>>()
private var lastToolTipTime = 0L
var gemstoneUnlockCosts = HashMap<NEUInternalName, HashMap<String, List<String>>>()
+ var reforges = mapOf<NEUInternalName, NeuReforgeStoneJson>()
var bookBundleAmount = mapOf<String, Int>()
private var currentlyShowing = false
@@ -50,14 +50,10 @@ object EstimatedItemValue {
@SubscribeEvent
fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
- val data = event.getConstant("gemstonecosts") ?: run {
- ErrorManager.skyHanniError("Gemstone Slot Unlock Costs failed to load from neu repo!")
- }
-
- gemstoneUnlockCosts = ConfigManager.gson.fromJson(
- data,
- object : TypeToken<HashMap<NEUInternalName, HashMap<String, List<String>>>>() {}.type
- )
+ gemstoneUnlockCosts =
+ event.readConstant<HashMap<NEUInternalName, HashMap<String, List<String>>>>("gemstonecosts")
+ reforges =
+ event.readConstant<Map<NEUInternalName, NeuReforgeStoneJson>>("reforgestones")
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
index 14812cd74..8602eece8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt
@@ -47,9 +47,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasJalapenoBook
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasWoodSingularity
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase
-import com.google.gson.JsonObject
import io.github.moulberry.notenoughupdates.recipes.Ingredient
-import io.github.moulberry.notenoughupdates.util.Constants
import net.minecraft.item.ItemStack
import java.util.Locale
@@ -166,30 +164,23 @@ object EstimatedItemValueCalculator {
private fun addReforgeStone(stack: ItemStack, list: MutableList<String>): Double {
val rawReforgeName = stack.getReforgeName() ?: return 0.0
- for ((rawInternalName, values) in Constants.REFORGESTONES.entrySet()) {
- val stoneJson = values.asJsonObject
- val reforgeName = stoneJson.get("reforgeName").asString
- if (rawReforgeName == reforgeName.lowercase() || rawReforgeName == rawInternalName.lowercase()) {
- val internalName = rawInternalName.asInternalName()
- val reforgeStonePrice = internalName.getPrice()
- val reforgeStoneName = internalName.itemName
-
- val reforgeCosts = stoneJson.get("reforgeCosts").asJsonObject
- val applyCost = getReforgeStoneApplyCost(stack, reforgeCosts, internalName) ?: return 0.0
-
- list.add("§7Reforge: §9$reforgeName")
- list.add(" §7Stone $reforgeStoneName §7(§6" + NumberUtil.format(reforgeStonePrice) + "§7)")
- list.add(" §7Apply cost: (§6" + NumberUtil.format(applyCost) + "§7)")
- return reforgeStonePrice + applyCost
- }
- }
+ val reforge = EstimatedItemValue.reforges.values.firstOrNull {
+ rawReforgeName == it.reforgeName.lowercase() || rawReforgeName == it.internalName.asString().lowercase()
+ } ?: return 0.0
+ val internalName = reforge.internalName.asString().asInternalName()
+ val reforgeStonePrice = internalName.getPrice()
+ val reforgeStoneName = internalName.itemName
+ val applyCost = getReforgeStoneApplyCost(stack, reforge.reforgeCosts, internalName) ?: return 0.0
- return 0.0
+ list.add("§7Reforge: §9${reforge.reforgeName}")
+ list.add(" §7Stone $reforgeStoneName §7(§6" + NumberUtil.format(reforgeStonePrice) + "§7)")
+ list.add(" §7Apply cost: (§6" + NumberUtil.format(applyCost) + "§7)")
+ return reforgeStonePrice + applyCost
}
private fun getReforgeStoneApplyCost(
stack: ItemStack,
- reforgeCosts: JsonObject,
+ reforgeCosts: Map<LorenzRarity, Long>,
reforgeStone: NEUInternalName,
): Int? {
var itemRarity = stack.getItemRarityOrNull() ?: return null
@@ -213,24 +204,19 @@ object EstimatedItemValueCalculator {
itemRarity = oneBelow
}
}
- val rarityName = itemRarity.name
- if (!reforgeCosts.has(rarityName)) {
- val reforgesFound = reforgeCosts.entrySet().map { it.key }
+
+ return reforgeCosts[itemRarity]?.toInt() ?: run {
ErrorManager.logErrorStateWithData(
"Could not calculate reforge cost for item ${stack.name}",
"Item not in NEU repo reforge cost",
- "rarityName" to rarityName,
"reforgeCosts" to reforgeCosts,
"itemRarity" to itemRarity,
- "reforgesFound" to reforgesFound,
"internal name" to stack.getInternalName(),
"item name" to stack.name,
"reforgeStone" to reforgeStone,
)
- return null
+ null
}
-
- return reforgeCosts[rarityName].asInt
}
private fun addRecomb(stack: ItemStack, list: MutableList<String>): Double {