aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt63
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt (renamed from src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt)3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt17
-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
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillUtil.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt22
13 files changed, 181 insertions, 114 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
index 3e128292e..025b4cead 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
@@ -1,21 +1,18 @@
package at.hannibal2.skyhanni.api
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.config.ConfigManager
-import at.hannibal2.skyhanni.data.jsonobjects.other.NeuSacksJson
+import at.hannibal2.skyhanni.data.SackAPI
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
-import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ChatUtils.isCommand
import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni
-import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -25,9 +22,7 @@ import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveSta
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import at.hannibal2.skyhanni.utils.fromJson
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.Deque
@@ -75,11 +70,11 @@ object GetFromSackAPI {
private var lastItemStack: PrimitiveItemStack? = null
- var sackListInternalNames = emptySet<String>()
- private set
+ @Deprecated("", ReplaceWith("SackAPI.sackListInternalNames"))
+ val sackListInternalNames get() = SackAPI.sackListInternalNames
- var sackListNames = emptySet<String>()
- private set
+ @Deprecated("", ReplaceWith("SackAPI.sackListNames"))
+ val sackListNames get() = SackAPI.sackListNames
private fun addToQueue(items: List<PrimitiveItemStack>) = queue.addAll(items)
@@ -222,29 +217,4 @@ object GetFromSackAPI {
WRONG_AMOUNT,
INTERNAL_ERROR
}
-
- @SubscribeEvent
- fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
- val data = event.getConstant("sacks") ?: ErrorManager.skyHanniError("NEU sacks data is null.")
- try {
- val sacksData = ConfigManager.gson.fromJson<NeuSacksJson>(data).sacks
- val uniqueSackItems = mutableSetOf<NEUInternalName>()
-
- sacksData.values.forEach { sackInfo ->
- sackInfo.contents.forEach { content ->
- uniqueSackItems.add(content)
- }
- }
-
- sackListInternalNames = uniqueSackItems.map { it.asString() }.toSet()
- sackListNames = uniqueSackItems.map { it.itemNameWithoutColor.uppercase() }.toSet()
-
- } catch (e: Exception) {
- ErrorManager.logErrorWithData(
- e, "Error getting NEU sacks data, make sure your neu repo is updated.",
- "sacksJson" to data
- )
- Utils.showOutdatedRepoNotification()
- }
- }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
index 55384443f..bcbee1cad 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
@@ -1,10 +1,11 @@
package at.hannibal2.skyhanni.api
import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuSkillLevelJson
import at.hannibal2.skyhanni.events.ActionBarUpdateEvent
-import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.events.SkillOverflowLevelupEvent
import at.hannibal2.skyhanni.features.skillprogress.SkillProgress
@@ -16,7 +17,6 @@ import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.calculateOverFlow
import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getLevel
import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getLevelExact
import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getSkillInfo
-import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.levelArray
import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.xpRequiredForLevel
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
@@ -30,11 +30,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import com.google.gson.GsonBuilder
import com.google.gson.annotations.Expose
-import com.google.gson.reflect.TypeToken
-import io.github.moulberry.notenoughupdates.util.Constants
-import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.command.CommandBase
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.LinkedList
@@ -69,6 +65,7 @@ object SkillAPI {
val storage get() = ProfileStorageData.profileSpecific?.skillData
var exactLevelingMap = mapOf<Int, Int>()
var levelingMap = mapOf<Int, Int>()
+ var levelArray = listOf<Int>()
var activeSkill: SkillType? = null
// TODO Use a map maxSkillLevel and move it into the repo
@@ -135,14 +132,10 @@ object SkillAPI {
}
@SubscribeEvent
- fun onConfigLoad(event: ConfigLoadEvent) {
- val gson = GsonBuilder().create()
- val xpList: List<Int> = gson.fromJson(
- Utils.getElement(Constants.LEVELING, "leveling_xp").asJsonArray.toString(),
- object : TypeToken<List<Int>>() {}.type
- )
- levelingMap = xpList.withIndex().associate { (index, xp) -> index to xp }
- exactLevelingMap = xpList.withIndex().associate { (index, xp) -> xp to index }
+ fun onNEURepoReload(event: NeuRepositoryReloadEvent) {
+ levelArray = event.readConstant<NeuSkillLevelJson>("leveling").levelingXp
+ levelingMap = levelArray.withIndex().associate { (index, xp) -> index to xp }
+ exactLevelingMap = levelArray.withIndex().associate { (index, xp) -> xp to index }
}
@SubscribeEvent
@@ -190,8 +183,7 @@ object SkillAPI {
val splitProgress = progress.split("/")
val currentXp = splitProgress.first().formatLong()
val neededXp = splitProgress.last().formatLong()
- val levelingArray = levelArray()
- val levelXp = calculateLevelXp(levelingArray, skillLevel - 1).toLong()
+ val levelXp = calculateLevelXp(skillLevel - 1).toLong()
skillInfo?.apply {
this.currentXp = currentXp
@@ -310,9 +302,8 @@ object SkillAPI {
}
val existingLevel = getSkillInfo(skillType) ?: SkillInfo()
val xpPercentage = matcher.group("progress").formatDouble()
- val levelingArray = levelArray()
- val levelXp = calculateLevelXp(levelingArray, existingLevel.level - 1)
- val nextLevelDiff = levelingArray[tablistLevel]?.asDouble ?: 7_600_000.0
+ val levelXp = calculateLevelXp(existingLevel.level - 1)
+ val nextLevelDiff = levelArray.getOrNull(tablistLevel)?.toDouble() ?: 7_600_000.0
val nextLevelProgress = nextLevelDiff * xpPercentage / 100
val totalXp = levelXp + nextLevelProgress
val (_, currentOverflow, currentMaxOverflow, totalOverflow) = getSkillInfo(
@@ -341,8 +332,7 @@ object SkillAPI {
val currentXp = matcher.group("current").formatLong()
val maxXp = matcher.group("needed").formatLong()
val level = getLevelExact(maxXp)
- val levelingArray = levelArray()
- val levelXp = calculateLevelXp(levelingArray, level - 1).toLong() + currentXp
+ val levelXp = calculateLevelXp(level - 1).toLong() + currentXp
val (currentLevel, currentOverflow, currentMaxOverflow, totalOverflow) = getSkillInfo(
level,
currentXp,
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
index b0d5bf9c9..adc56c596 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
@@ -118,7 +118,7 @@ class ConfigManager {
}
override fun read(reader: JsonReader): LorenzRarity {
- return LorenzRarity.valueOf(reader.nextString().uppercase())
+ return LorenzRarity.valueOf(reader.nextString().uppercase().replace(" ", "_"))
}
}.nullSafe())
.registerTypeAdapter(IslandType::class.java, object : TypeAdapter<IslandType>() {
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
index fe7c388f4..328031478 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
@@ -3,9 +3,11 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigFileType
import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.PriceFrom
+import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuSacksJson
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.SackChangeEvent
import at.hannibal2.skyhanni.events.SackDataUpdateEvent
import at.hannibal2.skyhanni.features.fishing.FishingAPI
@@ -14,6 +16,7 @@ import at.hannibal2.skyhanni.features.inventory.SackDisplay
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
@@ -62,6 +65,12 @@ object SackAPI {
val gemstoneItem = mutableMapOf<String, SackGemstone>()
private val stackList = mutableMapOf<Int, ItemStack>()
+ var sackListInternalNames = emptySet<String>()
+ private set
+
+ var sackListNames = emptySet<String>()
+ private set
+
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
inSackInventory = false
@@ -235,6 +244,21 @@ object SackAPI {
}
}
+ @SubscribeEvent
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
+ val sacksData = event.readConstant<NeuSacksJson>("sacks").sacks
+ val uniqueSackItems = mutableSetOf<NEUInternalName>()
+
+ sacksData.values.forEach { sackInfo ->
+ sackInfo.contents.forEach { content ->
+ uniqueSackItems.add(content)
+ }
+ }
+
+ sackListInternalNames = uniqueSackItems.map { it.asString() }.toSet()
+ sackListNames = uniqueSackItems.map { it.itemNameWithoutColor.uppercase() }.toSet()
+ }
+
private fun updateSacks(changes: SackChangeEvent) {
sackData = ProfileStorageData.sackProfiles?.sackContents ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt
new file mode 100644
index 000000000..d63a9ae79
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt
@@ -0,0 +1,9 @@
+package at.hannibal2.skyhanni.data.jsonobjects.repo.neu
+
+import at.hannibal2.skyhanni.utils.NEUInternalName
+import com.google.gson.annotations.Expose
+
+data class NeuRNGScore(
+ @Expose val catacombs: Map<String, Map<NEUInternalName, Long>>,
+ @Expose val slayer: Map<String, Map<NEUInternalName, Long>>
+)
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt
new file mode 100644
index 000000000..c450e3910
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt
@@ -0,0 +1,63 @@
+package at.hannibal2.skyhanni.data.jsonobjects.repo.neu;
+
+import at.hannibal2.skyhanni.utils.LorenzRarity
+import at.hannibal2.skyhanni.utils.NEUInternalName
+import com.google.gson.annotations.Expose
+import com.google.gson.annotations.SerializedName
+
+data class NeuReforgeStoneJson(
+ @Expose val internalName: NEUInternalName,
+ @Expose val reforgeName: String,
+ @Expose @SerializedName("itemTypes") val rawItemTypes: Any,
+ @Expose val requiredRarities: List<LorenzRarity>,
+ @Expose val reforgeCosts: Map<LorenzRarity, Long>,
+ @Expose val reforgeStats: Map<LorenzRarity, Map<String, Double>>,
+ @Expose @SerializedName("reforgeAbility") val rawReforgeAbility: Any?,
+) {
+
+ private lateinit var reforgeAbilityField: Map<LorenzRarity, String>
+
+ val reforgeAbility
+ get() = if (this::reforgeAbilityField.isInitialized) reforgeAbilityField
+ else {
+ reforgeAbilityField = when (this.rawReforgeAbility) {
+ is String -> {
+ this.requiredRarities.associateWith { this.rawReforgeAbility }
+ }
+
+ is Map<*, *> -> (this.rawReforgeAbility as? Map<String, String>)?.mapKeys {
+ LorenzRarity.valueOf(
+ it.key.uppercase().replace(" ", "_")
+ )
+ } ?: emptyMap()
+
+ else -> emptyMap()
+ }
+ reforgeAbilityField
+ }
+
+ /* used in ReforgeAPI which isn't in beta yet
+ val itemType: Pair<String, List<NEUInternalName>> by lazy {
+ val any = this.rawItemTypes
+ return@lazy when (any) {
+ is String -> {
+ any.replace("/", "_AND_").uppercase() to emptyList()
+ }
+
+ is Map<*, *> -> {
+ val type = "SPECIAL_ITEMS"
+ val map = any as? Map<String, List<String>> ?: return@lazy type to emptyList()
+ val internalNames = map["internalName"]?.map { it.asInternalName() } ?: emptyList()
+ val itemType = map["itemid"]?.map {
+ NEUItems.getInternalNamesForItemId(Item.getByNameOrId(it))
+ }?.flatten()
+ ?: emptyList()
+ type to (internalNames + itemType)
+ }
+
+ else -> throw IllegalStateException()
+ }
+ }
+*/
+}
+
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt
index c323211fb..fe0ae5b49 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt
@@ -1,9 +1,8 @@
-package at.hannibal2.skyhanni.data.jsonobjects.other
+package at.hannibal2.skyhanni.data.jsonobjects.repo.neu
import at.hannibal2.skyhanni.utils.NEUInternalName
import com.google.gson.annotations.Expose
-
data class NeuSacksJson(
@Expose val sacks: Map<String, SackInfo>
)
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt
new file mode 100644
index 000000000..d8ac8c838
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.data.jsonobjects.repo.neu
+
+import com.google.gson.annotations.Expose
+import com.google.gson.annotations.SerializedName
+
+data class NeuSkillLevelJson(
+ @Expose @SerializedName("leveling_xp") val levelingXp: List<Int>
+)
diff --git a/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt
index a162a8973..bb741ae80 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt
@@ -1,11 +1,28 @@
package at.hannibal2.skyhanni.events
+import at.hannibal2.skyhanni.config.ConfigManager
+import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.NEUItems.manager
+import at.hannibal2.skyhanni.utils.fromJson
import com.google.gson.JsonObject
+import com.google.gson.JsonSyntaxException
import java.io.File
class NeuRepositoryReloadEvent : LorenzEvent() {
fun getConstant(file: String): JsonObject? {
return manager.getJsonFromFile(File(manager.repoLocation, "constants/$file.json"))
}
+
+ inline fun <reified T : Any> readConstant(file: String): T {
+ val data = getConstant(file) ?: ErrorManager.skyHanniError("$file failed to load from neu repo!")
+ return try {
+ ConfigManager.gson.fromJson<T>(data)
+ } catch (e: JsonSyntaxException) {
+ ErrorManager.logErrorWithData(
+ e, "$file failed to read from neu repo!",
+ "data" to data
+ )
+ throw e
+ }
+ }
}
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 {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillUtil.kt
index 127f9459d..b4af74d13 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillUtil.kt
@@ -7,9 +7,6 @@ import at.hannibal2.skyhanni.api.SkillAPI.excludedSkills
import at.hannibal2.skyhanni.api.SkillAPI.levelingMap
import at.hannibal2.skyhanni.utils.Quad
import com.google.common.base.Splitter
-import com.google.gson.JsonArray
-import io.github.moulberry.notenoughupdates.util.Constants
-import io.github.moulberry.notenoughupdates.util.Utils
object SkillUtil {
@@ -125,16 +122,8 @@ object SkillUtil {
return level
}
- fun calculateLevelXp(levelingArray: JsonArray, level: Int): Double {
- var totalXp = 0.0
- for (i in 0 until level + 1) {
- val xp = levelingArray[i].asDouble
- totalXp += xp
- }
- return totalXp
+ fun calculateLevelXp(level: Int): Double {
+ return SkillAPI.levelArray.asSequence().take(level + 1).sumOf { it.toDouble() }
}
- fun levelArray(): JsonArray =
- Utils.getElement(Constants.LEVELING, "leveling_xp").asJsonArray
-
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt
index 386fbf98a..ccbe7282e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt
@@ -4,16 +4,20 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.SlayerAPI
+import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuRNGScore
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.events.SlayerChangeEvent
+import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
@@ -21,7 +25,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
-import io.github.moulberry.notenoughupdates.util.Constants
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.ceil
import kotlin.time.Duration.Companion.seconds
@@ -47,6 +50,8 @@ class SlayerRngMeterDisplay {
private var display = ""
private var lastItemDroppedTime = 0L
+ var rngScore = mapOf<String, Map<NEUInternalName, Long>>()
+
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!isEnabled()) return
@@ -137,12 +142,23 @@ class SlayerRngMeterDisplay {
storage.goalNeeded = -1
} else {
storage.itemGoal = selectedItem.itemName
- val jsonObject = Constants.RNGSCORE["slayer"].asJsonObject.get(getCurrentSlayer()).asJsonObject
- storage.goalNeeded = jsonObject.get(selectedItem.getInternalName().asString()).asLong
+ storage.goalNeeded = rngScore[getCurrentSlayer()]?.get(selectedItem.getInternalName())
+ ?: ErrorManager.skyHanniError(
+ "RNG Meter goal setting failed",
+ "selectedItem" to selectedItem,
+ "selectedItemInternalName" to selectedItem.getInternalName(),
+ "currentSlayer" to getCurrentSlayer(),
+ "repo" to rngScore
+ )
}
update()
}
+ @SubscribeEvent
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
+ rngScore = event.readConstant<NeuRNGScore>("rngscore").slayer
+ }
+
private fun update() {
display = drawDisplay()
}