Browse Source

optimized regen client sync

lakebane
FatBoy-DOTC 14 hours ago
parent
commit
29736f9c8f
  1. 8
      src/engine/objects/PlayerCharacter.java

8
src/engine/objects/PlayerCharacter.java

@ -5469,6 +5469,8 @@ public class PlayerCharacter extends AbstractCharacter {
} }
public void doRegen(){ public void doRegen(){
if(!this.timestamps.contains("SyncClient"))
this.timestamps.put("SyncClient",System.currentTimeMillis());
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) {
@ -5480,15 +5482,15 @@ public class PlayerCharacter extends AbstractCharacter {
boolean updateMana = this.regenerateMana(); boolean updateMana = this.regenerateMana();
boolean updateStamina = this.regenerateStamina(); boolean updateStamina = this.regenerateStamina();
boolean consumeStamina = this.consumeStamina(); boolean consumeStamina = this.consumeStamina();
if(updateHealth || updateMana || updateStamina || consumeStamina) if(this.timestamps.get("SyncClient") + 5000L > System.currentTimeMillis())
this.syncClient(); if(updateHealth || updateMana || updateStamina || consumeStamina)
this.syncClient();
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} finally { } finally {
this.updateLock.writeLock().unlock(); this.updateLock.writeLock().unlock();
} }
} }
//ChatManager.chatSystemInfo(this,"HEALTH: " + this.health.get() + " MANA: " + this.mana.get() + " STAM: " + this.stamina.get());
} }
public boolean regenerateHealth(){ public boolean regenerateHealth(){

Loading…
Cancel
Save