aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-07 21:41:05 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-07 21:41:05 +0100
commitc0bb4192a531827aafada9df875f7165266cee59 (patch)
tree71da21852dea21e2860b94cdb81f7b56588c15cc
parentaab187a1fd095cb4f7244ad3c41dfb46c832b215 (diff)
downloadskyhanni-c0bb4192a531827aafada9df875f7165266cee59.tar.gz
skyhanni-c0bb4192a531827aafada9df875f7165266cee59.tar.bz2
skyhanni-c0bb4192a531827aafada9df875f7165266cee59.zip
Fixed performance issues with Bingo Minion Craft Helper.
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt31
2 files changed, 31 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index e73f63813..f9a94e1d0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
@@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {
val logger = LorenzLogger("ConfigMigration")
- const val CONFIG_VERSION = 18
+ const val CONFIG_VERSION = 19
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/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
index bfcb24501..e3fe529fc 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
@@ -18,6 +19,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import com.google.gson.JsonArray
+import com.google.gson.JsonObject
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
@@ -117,7 +120,7 @@ class MinionCraftHelper {
}
}
- FirstMinionTier.firstMinionTier(otherItems, minions, tierOneMinions, tierOneMinionsDone)
+ FirstMinionTier.firstMinionTier(otherItems, minions, tierOneMinions, tierOneMinionsDone)
return Pair(minions, otherItems)
}
@@ -265,4 +268,30 @@ class MinionCraftHelper {
}
}
}
+
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.transform(19, "#player.bingoSessions") { element ->
+ for ((_, data) in element.asJsonObject.entrySet()) {
+ fixTierOneMinions(data.asJsonObject)
+ }
+ element
+ }
+ }
+
+ private fun fixTierOneMinions(data: JsonObject) {
+ val newList = JsonArray()
+ var i = 0
+ for (entry in data["tierOneMinionsDone"].asJsonArray) {
+ val name = entry.asString
+ if (!name.startsWith("INTERNALNAME:")) {
+ newList.add(entry)
+ } else {
+ i++
+ }
+ }
+ println("fixTierOneMinions: removed $i wrong entries.")
+ data.add("tierOneMinionsDone", newList)
+ }
+
}