From 5aa31512519c1b0d8a5db49b5a35273ac42bd4df Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 17 May 2024 00:48:59 +0200 Subject: Fix: Error in AllBurrowsList (#1809) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/event/diana/AllBurrowsList.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/main/java/at') 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() 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() 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.") } } -- cgit