From 29736f9c8f78b7eba7d0d5abd8d7f588c5e541bd Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 18 Jan 2025 03:24:16 -0600 Subject: [PATCH] optimized regen client sync --- src/engine/objects/PlayerCharacter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 86687f48..088603fa 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -5469,6 +5469,8 @@ public class PlayerCharacter extends AbstractCharacter { } public void doRegen(){ + if(!this.timestamps.contains("SyncClient")) + this.timestamps.put("SyncClient",System.currentTimeMillis()); if (this.updateLock.writeLock().tryLock()) { try { if(!this.isAlive() || !this.enteredWorld || !this.isActive) { @@ -5480,15 +5482,15 @@ public class PlayerCharacter extends AbstractCharacter { boolean updateMana = this.regenerateMana(); boolean updateStamina = this.regenerateStamina(); boolean consumeStamina = this.consumeStamina(); - if(updateHealth || updateMana || updateStamina || consumeStamina) - this.syncClient(); + if(this.timestamps.get("SyncClient") + 5000L > System.currentTimeMillis()) + if(updateHealth || updateMana || updateStamina || consumeStamina) + this.syncClient(); } catch (Exception e) { Logger.error(e); } finally { this.updateLock.writeLock().unlock(); } } - //ChatManager.chatSystemInfo(this,"HEALTH: " + this.health.get() + " MANA: " + this.mana.get() + " STAM: " + this.stamina.get()); } public boolean regenerateHealth(){