player lock fix

This commit is contained in:
2025-01-29 19:15:20 -06:00
parent 1e26d7f38c
commit 0ec505e37f
+15
View File
@@ -5817,6 +5817,21 @@ public class PlayerCharacter extends AbstractCharacter {
public void doRegen(){ public void doRegen(){
if(!this.timestamps.containsKey("SyncClient")) if(!this.timestamps.containsKey("SyncClient"))
this.timestamps.put("SyncClient",System.currentTimeMillis()); this.timestamps.put("SyncClient",System.currentTimeMillis());
try {
ReentrantReadWriteLock reentrantLock = (ReentrantReadWriteLock) this.updateLock;
if(reentrantLock.writeLock().isHeldByCurrentThread()){
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
}
}catch(Exception e){
Logger.error(e);
}
if (this.updateLock.writeLock().tryLock()) { if (this.updateLock.writeLock().tryLock()) {
try { try {
if(!this.isAlive() || !this.enteredWorld || !this.isActive) { if(!this.isAlive() || !this.enteredWorld || !this.isActive) {