From 256a7aebcf47838abccb48f1a275fda9e306e9fd Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 5 May 2023 09:46:21 +0200 Subject: Better name editCopy --- .../skyhanni/features/event/diana/GriffinBurrowHelper.kt | 10 +++++----- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (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 3458bd2a3..65ce760aa 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,7 +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.editThreadSave +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawColor @@ -51,7 +51,7 @@ class GriffinBurrowHelper { @SubscribeEvent fun onBurrowDetect(event: BurrowDetectEvent) { EntityMovementData.addToTrack(Minecraft.getMinecraft().thePlayer) - particleBurrows = particleBurrows.editThreadSave { this[event.burrowLocation] = event.type } + particleBurrows = particleBurrows.editCopy { this[event.burrowLocation] = event.type } if (SkyHanniMod.feature.diana.burrowsNearbyDetection) { checkRemoveGuess(true) @@ -73,7 +73,7 @@ class GriffinBurrowHelper { @SubscribeEvent fun onBurrowDug(event: BurrowDugEvent) { val location = event.burrowLocation - particleBurrows = particleBurrows.editThreadSave { remove(location) } + particleBurrows = particleBurrows.editCopy { remove(location) } if (particleBurrows.isNotEmpty()) { animationLocation = location } @@ -92,7 +92,7 @@ class GriffinBurrowHelper { @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { if (event.message.startsWith("§c ☠ §r§7You were killed by §r")) { - particleBurrows = particleBurrows.editThreadSave { keys.removeIf { this[it] == BurrowType.MOB } } + particleBurrows = particleBurrows.editCopy { keys.removeIf { this[it] == BurrowType.MOB } } } } @@ -101,7 +101,7 @@ class GriffinBurrowHelper { guessLocation = null animationLocation = null lastDug = null - particleBurrows = particleBurrows.editThreadSave { clear() } + particleBurrows = particleBurrows.editCopy { clear() } } private fun findBlock(point: LorenzVec): LorenzVec { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 043cfe45f..cdd3af5d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -263,6 +263,6 @@ object LorenzUtils { whenChanged { _, _ -> observer.run() } } - fun Map.editThreadSave(function: MutableMap.() -> Unit) = + fun Map.editCopy(function: MutableMap.() -> Unit) = toMutableMap().also { function(it) }.toMap() } \ No newline at end of file -- cgit