aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-25 16:18:12 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-07-31 21:55:22 +0200
commitfa67b7f82011f8fc4b07c0f913e2c0a968ff7055 (patch)
tree400b2fc6c5b54f78d0501f66f4d78f42633e8a74
parent970687f94eb69fc04e8e03f06c90ddc5d6c179b2 (diff)
downloadskyhanni-fa67b7f82011f8fc4b07c0f913e2c0a968ff7055.tar.gz
skyhanni-fa67b7f82011f8fc4b07c0f913e2c0a968ff7055.tar.bz2
skyhanni-fa67b7f82011f8fc4b07c0f913e2c0a968ff7055.zip
Fixed ConcurrentModificationException at MinionFeatures
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index 1bdf8e90c..6180185d4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.LorenzUtils.formatInteger
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded
@@ -102,9 +103,11 @@ class MinionFeatures {
val openInventory = event.inventoryName
val name = getMinionName(openInventory)
if (!minions.contains(entity)) {
- minions[entity] = Storage.ProfileSpecific.MinionConfig().apply {
- displayName = name
- lastClicked = 0
+ MinionFeatures.minions = minions.editCopy {
+ this[entity] = Storage.ProfileSpecific.MinionConfig().apply {
+ displayName = name
+ lastClicked = 0
+ }
}
} else {
if (minions[entity]!!.displayName != name) {
@@ -120,7 +123,7 @@ class MinionFeatures {
@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
if (!minionInventoryOpen) return
- val minions = minions ?: return
+ var minions = minions ?: return
minionInventoryOpen = false
lastMinionOpened = System.currentTimeMillis()
@@ -134,7 +137,7 @@ class MinionFeatures {
}
if (System.currentTimeMillis() - lastMinionPickedUp < 2_000) {
- minions.remove(location)
+ MinionFeatures.minions = minions.editCopy { remove(location) }
}
}
@@ -284,10 +287,16 @@ class MinionFeatures {
}
companion object {
- private val minions get() = ProfileStorageData.profileSpecific?.minions
+ private var minions: Map<LorenzVec, Storage.ProfileSpecific.MinionConfig>?
+ get() {
+ return ProfileStorageData.profileSpecific?.minions
+ }
+ set(value) {
+ ProfileStorageData.profileSpecific?.minions = value
+ }
fun clearMinionData() {
- minions?.clear()
+ minions = mutableMapOf()
LorenzUtils.chat("§e[SkyHanni] Manually reset all private island minion location data!")
}
}