From 422cf10eea9a4fd029c24b07a4f5ea8d60edbe2d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 17 May 2024 23:56:46 -0500 Subject: [PATCH] box check only every 10 seconds --- .../InterestManagement/InterestManager.java | 2 +- src/engine/objects/PlayerCharacter.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index e9be2587..e1438824 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -530,7 +530,7 @@ public enum InterestManager implements Runnable { player.setDirtyLoad(true); updateStaticList(player, origin); updateMobileList(player, origin); - player.isBoxed = PlayerCharacter.checkIfBoxed(player); + PlayerCharacter.checkIfBoxed(player); } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 50f8e64e..d3d0b54b 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -180,7 +180,7 @@ public class PlayerCharacter extends AbstractCharacter { public long lastAction = 0; - public long lastBoxCheck = System.currentTimeMillis(); + public long nextBoxCheck = System.currentTimeMillis(); /** * No Id Constructor */ @@ -4865,11 +4865,13 @@ public class PlayerCharacter extends AbstractCharacter { ItemFactory.fillInventory(this, 980066, 1); } } - this.isBoxed = checkIfBoxed(this); + if(!this.isBoxed) { + checkIfBoxed(this); + } if(this.isBoxed) { if(!this.title.equals(CharacterTitle.BOX)) { this.title = CharacterTitle.BOX; - InterestManager.reloadCharacter(this); + //InterestManager.reloadCharacter(this); } if (!this.containsEffect(1672601862)) {//Deathshroud @@ -4881,7 +4883,7 @@ public class PlayerCharacter extends AbstractCharacter { }else{ if(!this.title.equals(CharacterTitle.NONE)) { this.title = CharacterTitle.NONE; - InterestManager.reloadCharacter(this); + //InterestManager.reloadCharacter(this); } } } @@ -4894,11 +4896,11 @@ public class PlayerCharacter extends AbstractCharacter { } } - public static boolean checkIfBoxed(PlayerCharacter player){ - if(System.currentTimeMillis() < player.lastBoxCheck + 5000) - return false; + public static void checkIfBoxed(PlayerCharacter player){ + if(System.currentTimeMillis() > player.nextBoxCheck) + return; - player.lastBoxCheck = System.currentTimeMillis(); + player.nextBoxCheck = System.currentTimeMillis() + 10000; try { for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) { if(pc.getClientConnection().machineID.equals(player.getClientConnection().machineID) == false) @@ -4910,13 +4912,14 @@ public class PlayerCharacter extends AbstractCharacter { if (pc.equals(player)) continue; if (pc.isBoxed == false) { - return true; + player.isBoxed = true; + return; } } - return false; + player.isBoxed = false; }catch(Exception e){ - return false; + player.isBoxed = false; } }