From 54af9243d1d98e165e06c3db304649154e843132 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 4 May 2023 20:40:27 +0200 Subject: concurrency fix like a pro (#91) --- .../at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt | 3 ++- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index 5440c2af8..55b893938 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.makeSyncMap import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawColor @@ -22,7 +23,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class GriffinBurrowHelper { private var guessLocation: LorenzVec? = null - private var particleBurrows = mutableMapOf() + private val particleBurrows = makeSyncMap(mutableMapOf()) private var animationLocation: LorenzVec? = null private var lastDug: LorenzVec? = null private var teleportedLocation: LorenzVec? = null diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 84807dcca..fbb0272f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -262,4 +262,6 @@ object LorenzUtils { fun Property.onToggle(observer: Runnable) { whenChanged { _, _ -> observer.run() } } + + fun makeSyncMap(originalMap: MutableMap) = Collections.synchronizedMap(originalMap) } \ No newline at end of file -- cgit