Browse Source

player lock fix

lakebane
FatBoy-DOTC 1 day ago
parent
commit
157d116626
  1. 13
      src/engine/objects/PlayerCharacter.java

13
src/engine/objects/PlayerCharacter.java

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

Loading…
Cancel
Save