aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/bingo
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-03-04 08:34:58 +1100
committerGitHub <noreply@github.com>2024-03-03 22:34:58 +0100
commitb04df2e342b47f1b8b8d7dfb36d6e4c003c6a71f (patch)
tree5b77972da96b239d2b554e10e91365da027ae380 /src/main/java/at/hannibal2/skyhanni/features/bingo
parent0d1867cfb62a8f13345518d4b26de9bf0fecd1a4 (diff)
downloadskyhanni-b04df2e342b47f1b8b8d7dfb36d6e4c003c6a71f.tar.gz
skyhanni-b04df2e342b47f1b8b8d7dfb36d6e4c003c6a71f.tar.bz2
skyhanni-b04df2e342b47f1b8b8d7dfb36d6e4c003c6a71f.zip
Fixed Bingo Minion Craft Helper sometimes causing performance problems. #1091
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/bingo')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/FirstMinionTier.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt9
2 files changed, 18 insertions, 9 deletions
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++