aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-17 00:48:59 +0200
committerGitHub <noreply@github.com>2024-05-17 00:48:59 +0200
commit5aa31512519c1b0d8a5db49b5a35273ac42bd4df (patch)
tree0ee578db3f1918dc4958636fc4a8830cbdff1941
parentc85ef72490105eced9cbe73e661f77255768015d (diff)
downloadskyhanni-5aa31512519c1b0d8a5db49b5a35273ac42bd4df.tar.gz
skyhanni-5aa31512519c1b0d8a5db49b5a35273ac42bd4df.tar.bz2
skyhanni-5aa31512519c1b0d8a5db49b5a35273ac42bd4df.zip
Fix: Error in AllBurrowsList (#1809)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt
index 3ff3fa59f..005d9b8f1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.BurrowDetectEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
@@ -16,12 +17,18 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object AllBurrowsList {
private var list = listOf<LorenzVec>()
private val config get() = SkyHanniMod.feature.event.diana.allBurrowsList
- private val burrowLocations get() = SkyHanniMod.feature.storage?.foundDianaBurrowLocations
+ private var burrowLocations
+ get() = SkyHanniMod.feature.storage?.foundDianaBurrowLocations
+ set(value) {
+ SkyHanniMod.feature.storage?.foundDianaBurrowLocations = value
+ }
@SubscribeEvent
fun onBurrowDetect(event: BurrowDetectEvent) {
if (!isEnabled()) return
- burrowLocations?.add(event.burrowLocation)
+ burrowLocations = burrowLocations?.editCopy {
+ add(event.burrowLocation)
+ }
}
@SubscribeEvent
@@ -52,15 +59,20 @@ object AllBurrowsList {
var new = 0
var duplicate = 0
+ val newEntries = mutableListOf<LorenzVec>()
for (raw in text.split(";")) {
val location = LorenzVec.decodeFromString(raw)
if (location !in burrowLocations) {
- burrowLocations.add(location)
+ newEntries.add(location)
new++
} else {
duplicate++
}
}
+ AllBurrowsList.burrowLocations = burrowLocations.editCopy {
+ addAll(newEntries)
+ }
+
ChatUtils.chat("Added $new new burrow locations, $duplicate are duplicate.")
}
}