From 157d116626c6103bcea0997f6f7493797991f3a2 Mon Sep 17 00:00:00 2001
From: FatBoy-DOTC <justin.chucksinsulating@gmail.com>
Date: Wed, 29 Jan 2025 17:29:57 -0600
Subject: [PATCH] player lock fix

---
 src/engine/objects/PlayerCharacter.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java
index 42e254ab..c4228dff 100644
--- a/src/engine/objects/PlayerCharacter.java
+++ b/src/engine/objects/PlayerCharacter.java
@@ -5040,6 +5040,10 @@ public class PlayerCharacter extends AbstractCharacter {
         //if(!newSystem)
         //    return;
 
+        if (((ReentrantReadWriteLock) this.updateLock).isWriteLockedByCurrentThread()) {
+            this.updateLock.writeLock().unlock();
+        }
+
         if (this.updateLock.writeLock().tryLock()) {
             try {
 
@@ -5047,12 +5051,16 @@ public class PlayerCharacter extends AbstractCharacter {
                     if(!this.timestamps.containsKey("DeathTime")){
                         this.timestamps.put("DeathTime",System.currentTimeMillis());
                     }else if((System.currentTimeMillis() - this.timestamps.get("DeathTime")) > 600000)
-                        forceRespawn(this);
+                        try {
+                            forceRespawn(this);
+                        }catch(Exception e){
+                            this.updateLock.writeLock().unlock();
+                        }
                     return;
                 }
                 this.updateLocation();
-                this.updateMovementState();
-                this.updateRegen();
+                //this.updateMovementState();
+                //this.updateRegen();
 
                 if (this.getStamina() < 10) {
                     if (this.getAltitude() > 0 || this.getDesiredAltitude() > 0) {
@@ -5109,6 +5117,7 @@ public class PlayerCharacter extends AbstractCharacter {
                 }
 
             } catch (Exception e) {
+                this.updateLock.writeLock().unlock();
                 Logger.error(e);
             } finally {
                 this.updateLock.writeLock().unlock();