From 729ebe7cd0ec1a56dc09470183c61aed3f801075 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jun 2024 14:48:20 -0500 Subject: [PATCH] box checker --- src/engine/objects/PlayerCharacter.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 1236db3b..dbc023be 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4815,6 +4815,13 @@ public class PlayerCharacter extends AbstractCharacter { updateBlessingMessage(); this.safeZone = this.isInSafeZone(); + if(!this.timestamps.containsKey("nextBoxCheck")) + this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000); + + if(!this.isBoxed && this.timestamps.get("nextBoxCheck") > System.currentTimeMillis()) { + this.isBoxed = checkIfBoxed(this); + this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000); + } if(this.isBoxed && !this.containsEffect(1672601862)) { PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); @@ -4828,6 +4835,22 @@ public class PlayerCharacter extends AbstractCharacter { } } + public static boolean checkIfBoxed(PlayerCharacter player){ + String machineID = player.getClientConnection().machineID; + ArrayList sameMachine = new ArrayList<>(); + for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){ + if(!pc.equals(player) && pc. isActive && pc.isEnteredWorld() && pc.getClientConnection().machineID.equals(machineID)){ + sameMachine.add(pc); + } + } + + boolean boxed = false; + for(PlayerCharacter pc : sameMachine) + if(!pc.isBoxed) + boxed = true; + + return boxed; + } @Override public void updateFlight() {