aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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!")
}
}