From 89c06f714f899ce08be70d391f329aa67f72f162 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 29 Jan 2025 17:36:56 -0600 Subject: [PATCH] player lock fix --- src/engine/objects/PlayerCharacter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index c4228dff..59f1e8c4 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -5039,9 +5039,11 @@ public class PlayerCharacter extends AbstractCharacter { //if(!newSystem) // return; + ReentrantReadWriteLock reentrantLock = (ReentrantReadWriteLock) updateLock; - if (((ReentrantReadWriteLock) this.updateLock).isWriteLockedByCurrentThread()) { - this.updateLock.writeLock().unlock(); + // Check if the lock is currently held by another thread (either for reading or writing) + if (reentrantLock.isWriteLocked() || reentrantLock.getReadLockCount() > 0) { + return; // Or throw an exception if needed } if (this.updateLock.writeLock().tryLock()) {