From 8c0b62efe09c0a18e0d83cad670b2d19a22b6838 Mon Sep 17 00:00:00 2001 From: Iru21 <33987046+Iru21@users.noreply.github.com> Date: Thu, 19 Jan 2023 12:57:01 +0100 Subject: [PATCH] Do not save location when leaving while dead (#29) --- gradle.properties | 2 +- src/main/kotlin/me/iru/process/PreLoginDataStore.kt | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0a7ecfe..cfda120 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ kotlin.code.style = official minecraftVersion = 1.17 pluginName = Authy -pluginVersion = 3.2.1 +pluginVersion = 3.2.2 diff --git a/src/main/kotlin/me/iru/process/PreLoginDataStore.kt b/src/main/kotlin/me/iru/process/PreLoginDataStore.kt index dcef756..f9621b9 100644 --- a/src/main/kotlin/me/iru/process/PreLoginDataStore.kt +++ b/src/main/kotlin/me/iru/process/PreLoginDataStore.kt @@ -17,7 +17,7 @@ object PreLoginDataStore { fun save(p: Player) { saveEffects(p) - if(shouldConceal()) { + if(shouldConceal() && !p.isDead) { locations[p.uniqueId] = p.location } saveFireTicks(p) @@ -30,7 +30,9 @@ object PreLoginDataStore { restoreLocation(p) } p.fireTicks = fireTicks[p.uniqueId] ?: 0 + fireTicks.remove(p.uniqueId) p.isFlying = flyingState[p.uniqueId] ?: false + flyingState.remove(p.uniqueId) } private fun saveFireTicks(p: Player) { @@ -42,7 +44,10 @@ object PreLoginDataStore { private fun restoreLocation(p: Player) { val loc = locations[p.uniqueId] - if(loc != null) p.teleport(loc) + if(loc != null) { + p.teleport(loc) + locations.remove(p.uniqueId) + } } private fun restoreEffects(p: Player) { @@ -53,6 +58,8 @@ object PreLoginDataStore { for(e in es) { p.addPotionEffect(e) } + + effects.remove(p.uniqueId) } private fun saveEffects(p: Player) {