Skip to content

Commit

Permalink
Do not save location when leaving while dead (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru21 committed Jan 19, 2023
1 parent d0f4703 commit 8c0b62e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1,4 +1,4 @@
kotlin.code.style = official
minecraftVersion = 1.17
pluginName = Authy
pluginVersion = 3.2.1
pluginVersion = 3.2.2
11 changes: 9 additions & 2 deletions src/main/kotlin/me/iru/process/PreLoginDataStore.kt
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -53,6 +58,8 @@ object PreLoginDataStore {
for(e in es) {
p.addPotionEffect(e)
}

effects.remove(p.uniqueId)
}

private fun saveEffects(p: Player) {
Expand Down

0 comments on commit 8c0b62e

Please sign in to comment.