aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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.")
}
}