From 6375b4431c4b329c8818c4fac65e2251e0627440 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jun 2024 18:50:40 -0500 Subject: [PATCH] box check --- src/engine/objects/PlayerCharacter.java | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 345153eb..dd994fe1 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4818,7 +4818,7 @@ public class PlayerCharacter extends AbstractCharacter { if(!this.timestamps.containsKey("nextBoxCheck")) this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000); - if(!this.isBoxed && this.timestamps.get("nextBoxCheck") > System.currentTimeMillis()) { + if(!this.isBoxed && this.timestamps.get("nextBoxCheck") < System.currentTimeMillis()) { this.isBoxed = checkIfBoxed(this); this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000); } @@ -4853,20 +4853,24 @@ 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); + try { + 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; + boolean boxed = false; + for (PlayerCharacter pc : sameMachine) + if (!pc.isBoxed) + boxed = true; - return boxed; + return boxed; + }catch(Exception e){ + return false; + } } @Override public void updateFlight() {