From 8545540e19a0f391afe1e0fe3d9be84bcedf846d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 25 Mar 2025 18:53:26 -0500 Subject: [PATCH] player update organisation --- src/engine/objects/PlayerCharacter.java | 89 +++++++++++++++---------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 69f463a3..e8b224ea 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -5182,49 +5182,18 @@ public class PlayerCharacter extends AbstractCharacter { this.safeZone = this.isInSafeZone(); if(this.isActive && this.enteredWorld) { - if (!this.timestamps.containsKey("nextBoxCheck")) - this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 3000); - if(this.timestamps.get("nextBoxCheck") < System.currentTimeMillis()) { - if (!this.isBoxed) { - this.isBoxed = checkIfBoxed(this); - } - this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 3000); - } if (this.level < 10 && this.enteredWorld) { while (this.level < 10) { grantXP(Experience.getBaseExperience(this.level + 1) - this.exp); } } - - if (this.isBoxed && !this.containsEffect(-654906771)) { - PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, -935138707, 40, false); - }else if(!this.isBoxed && this.containsEffect(-654906771)){ - this.effects.remove("PvE-Flagged"); - this.effects.remove("1258"); - WorldGrid.updateObject(this); - } } - if (this.isFlying()) { - if (this.effects.containsKey("MoveBuff")) { - GroundPlayer(this); - } - if (!this.timestamps.containsKey("StunGrounded")) - this.timestamps.put("StunGrounded", System.currentTimeMillis() - 1000L); - if (this.bonuses.getBool(ModType.Stunned, SourceType.None) && this.timestamps.get("StunGrounded") < System.currentTimeMillis()) { - boolean isFlyMoving = this.getDesiredAltitude() != this.altitude; - if (!isFlyMoving && this.bonuses.getBool(ModType.Stunned, SourceType.None)) { - this.setDesiredAltitude(this.altitude - 10); - this.setTakeOffTime(System.currentTimeMillis()); - - ChangeAltitudeMsg msg = new ChangeAltitudeMsg(this.getObjectType().ordinal(), this.getObjectUUID(), false, this.getAltitude(), this.getDesiredAltitude(), this.getAltitude()); - // force a landing - DispatchMessage.dispatchMsgToInterestArea(this, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - this.timestamps.put("StunGrounded", System.currentTimeMillis() + 1500L); - ChatManager.chatSystemInfo(this, "Applying 1 Tier Ground"); - } - } + this.auditBoxedStatus(); + + if (this.isFlying()) { + this.auditFlightStatus(); } } catch (Exception e) { @@ -5237,6 +5206,56 @@ public class PlayerCharacter extends AbstractCharacter { Logger.error("UPDATE ISSUE: " + e); } } + + public void auditBoxedStatus(){ + + if (!this.timestamps.containsKey("nextBoxCheck")) + this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 3000); + + if(this.timestamps.get("nextBoxCheck") < System.currentTimeMillis()) { + if (!this.isBoxed) { + this.isBoxed = checkIfBoxed(this); + } + this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 3000); + } + + if (this.isBoxed && !this.containsEffect(-654906771)) { + PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, -935138707, 40, false); + }else if(!this.isBoxed && this.containsEffect(-654906771)){ + try { + this.effects.get("PvE-Flagged").endEffect(); + //this.effects.remove("PvE-Flagged"); + }catch(Exception ignored){ + + } + try{ + this.effects.get("1258").endEffect(); + //this.effects.remove("1258"); + }catch(Exception ignored){ + + } + } + } + public void auditFlightStatus(){ + if (this.effects.containsKey("MoveBuff")) { + GroundPlayer(this); + } + if (!this.timestamps.containsKey("StunGrounded")) + this.timestamps.put("StunGrounded", System.currentTimeMillis() - 1000L); + if (this.bonuses.getBool(ModType.Stunned, SourceType.None) && this.timestamps.get("StunGrounded") < System.currentTimeMillis()) { + boolean isFlyMoving = this.getDesiredAltitude() != this.altitude; + if (!isFlyMoving && this.bonuses.getBool(ModType.Stunned, SourceType.None)) { + this.setDesiredAltitude(this.altitude - 10); + this.setTakeOffTime(System.currentTimeMillis()); + + ChangeAltitudeMsg msg = new ChangeAltitudeMsg(this.getObjectType().ordinal(), this.getObjectUUID(), false, this.getAltitude(), this.getDesiredAltitude(), this.getAltitude()); + // force a landing + DispatchMessage.dispatchMsgToInterestArea(this, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); + this.timestamps.put("StunGrounded", System.currentTimeMillis() + 1500L); + ChatManager.chatSystemInfo(this, "Applying 1 Tier Ground"); + } + } + } public static void unboxPlayer(PlayerCharacter player){ String machineID = player.getClientConnection().machineID; ArrayList sameMachine = new ArrayList<>();