Skip to content

Commit

Permalink
ignore some stats always
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Jan 11, 2025
1 parent 37f7945 commit 0ee20ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,23 @@ object CollectionUtils {
fun <K, V> MutableMap<K, V>.add(pair: Pair<K, V>) {
this[pair.first] = pair.second
}

fun <T> MutableList<T>.removeIf(predicate: (T) -> Boolean) {
val iterator = this.iterator()
while (iterator.hasNext()) {
if (predicate(iterator.next())) {
iterator.remove()
}
}
}

fun <K, V> MutableMap<K, V>.removeIfKey(predicate: (K) -> Boolean) {
val iterator = this.entries.iterator()
while (iterator.hasNext()) {
if (predicate(iterator.next().key)) {
iterator.remove()
}
}
}

}
8 changes: 8 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator.ge
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.removeIfKey
import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPrice
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
Expand Down Expand Up @@ -46,6 +47,8 @@ import kotlin.time.Duration.Companion.seconds
object ItemUtils {

private val itemNameCache = mutableMapOf<NEUInternalName, String>() // internal name -> item name

// This map might not contain all stats the item has, compare with itemBaseStatsRaw if unclear
private var itemBaseStats = mapOf<NEUInternalName, Map<SkyblockStat, Int>>()
private var itemBaseStatsRaw = mapOf<NEUInternalName, Map<String, Int>>()

Expand All @@ -72,6 +75,11 @@ object ItemUtils {
}
allItems[internalName] = stats
}

// TODO maybe create a new enum for item stats?
unknownStats.remove("WEAPON_ABILITY_DAMAGE") // stat exists only on items, not as player stat
unknownStats.removeIfKey { it.startsWith("RIFT_") } // rift stats are not in SkyblockStat enum

if (unknownStats.isNotEmpty()) {
val name = StringUtils.pluralize(unknownStats.size, "stat", withNumber = true)
ErrorManager.logErrorStateWithData(
Expand Down

0 comments on commit 0ee20ec

Please sign in to comment.