Browse Source

box check

lakebane-new
FatBoy-DOTC 5 months ago
parent
commit
6375b4431c
  1. 28
      src/engine/objects/PlayerCharacter.java

28
src/engine/objects/PlayerCharacter.java

@ -4818,7 +4818,7 @@ public class PlayerCharacter extends AbstractCharacter {
if(!this.timestamps.containsKey("nextBoxCheck")) if(!this.timestamps.containsKey("nextBoxCheck"))
this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000); 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.isBoxed = checkIfBoxed(this);
this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000); this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000);
} }
@ -4853,20 +4853,24 @@ public class PlayerCharacter extends AbstractCharacter {
} }
public static boolean checkIfBoxed(PlayerCharacter player){ public static boolean checkIfBoxed(PlayerCharacter player){
String machineID = player.getClientConnection().machineID; try {
ArrayList<PlayerCharacter> sameMachine = new ArrayList<>(); String machineID = player.getClientConnection().machineID;
for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){ ArrayList<PlayerCharacter> sameMachine = new ArrayList<>();
if(!pc.equals(player) && pc. isActive && pc.isEnteredWorld() && pc.getClientConnection().machineID.equals(machineID)){ for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) {
sameMachine.add(pc); if (!pc.equals(player) && pc.isActive && pc.isEnteredWorld() && pc.getClientConnection().machineID.equals(machineID)) {
sameMachine.add(pc);
}
} }
}
boolean boxed = false; boolean boxed = false;
for(PlayerCharacter pc : sameMachine) for (PlayerCharacter pc : sameMachine)
if(!pc.isBoxed) if (!pc.isBoxed)
boxed = true; boxed = true;
return boxed; return boxed;
}catch(Exception e){
return false;
}
} }
@Override @Override
public void updateFlight() { public void updateFlight() {

Loading…
Cancel
Save