diff options
4 files changed, 20 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 2984dcf02..824cb4e9f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -10,7 +10,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 25 + const val CONFIG_VERSION = 26 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index fe303a17e..fd6f5da69 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -114,7 +114,7 @@ public class Storage { public static class BingoSession { @Expose - public List<NEUInternalName> tierOneMinionsDone = new ArrayList<>(); + public Set<NEUInternalName> tierOneMinionsDone = new HashSet<>(); @Expose public Map<Integer, BingoGoal> goals = new HashMap<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt index ab5e2f3bf..e6d339979 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.bingo +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -14,7 +15,7 @@ object FirstMinionTier { otherItems: Map<NEUInternalName, Int>, minions: MutableMap<String, NEUInternalName>, tierOneMinions: MutableList<NEUInternalName>, - tierOneMinionsDone: MutableList<NEUInternalName>, + tierOneMinionsDone: MutableSet<NEUInternalName>, ) { val help = helpMap(otherItems) val tierOneMinionsFiltered = getTierOneMinionsFiltered(tierOneMinions, tierOneMinionsDone) @@ -51,19 +52,28 @@ object FirstMinionTier { private fun addMinion( tierOneMinionsFiltered: List<NEUInternalName>, minions: MutableMap<String, NEUInternalName>, - tierOneMinionsDone: MutableList<NEUInternalName>, + tierOneMinionsDone: MutableSet<NEUInternalName>, ) { for (minionId in tierOneMinionsFiltered) { val prefix = minionId.asString().dropLast(1) if (minions.any { it.value.startsWith(prefix) }) { - tierOneMinionsDone.add(minionId) + val successful = tierOneMinionsDone.add(minionId) + if (!successful) { + ErrorManager.logErrorWithData( + IllegalStateException("Attempted to add $minionId to tierOneMinionsDone when it already exists"), + "Attempted to add $minionId to tierOneMinionsDone when it already exists", + "tierOneMinionsFiltered" to tierOneMinionsFiltered, + "minions" to minions, + "tierOneMinionsDone" to tierOneMinionsDone + ) + } } } } private fun getTierOneMinionsFiltered( tierOneMinions: MutableList<NEUInternalName>, - tierOneMinionsDone: MutableList<NEUInternalName>, + tierOneMinionsDone: MutableSet<NEUInternalName>, ) = tierOneMinions.filter { it !in tierOneMinionsDone } private fun helpMap(otherItems: Map<NEUInternalName, Int>) = diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index c3ef465f2..a6f81c588 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -269,15 +269,13 @@ class MinionCraftHelper { if (!name.startsWith("§e")) continue val internalName = NEUInternalName.fromItemName("$name I") .replace("MINION", "GENERATOR").replace(";", "_").replace("CAVE_SPIDER", "CAVESPIDER") - if (!tierOneMinionsDone.contains(internalName)) { - tierOneMinionsDone.add(internalName) - } + tierOneMinionsDone.add(internalName) } } @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.transform(19, "#player.bingoSessions") { element -> + event.transform(26, "#player.bingoSessions") { element -> for ((_, data) in element.asJsonObject.entrySet()) { fixTierOneMinions(data.asJsonObject) } @@ -286,11 +284,12 @@ class MinionCraftHelper { } private fun fixTierOneMinions(data: JsonObject) { + val uniqueEntries = mutableSetOf<String>() val newList = JsonArray() var counter = 0 for (entry in data["tierOneMinionsDone"].asJsonArray) { val name = entry.asString - if (!name.startsWith("INTERNALNAME:")) { + if (!name.startsWith("INTERNALNAME:") && uniqueEntries.add(name)) { newList.add(entry) } else { counter++ |