Browse Source

stop invisible player plague

lakebane
FatBoy-DOTC 2 weeks ago
parent
commit
9032565220
  1. 3
      src/engine/InterestManagement/InterestManager.java
  2. 62
      src/engine/objects/PlayerCharacter.java

3
src/engine/InterestManagement/InterestManager.java

@ -537,7 +537,8 @@ public enum InterestManager implements Runnable { @@ -537,7 +537,8 @@ public enum InterestManager implements Runnable {
// Update loaded upbjects lists
player.isBoxed = PlayerCharacter.checkIfBoxed(player);
//player.isBoxed = PlayerCharacter.checkIfBoxed(player);
player.updateBoxStatus(player.isBoxed,PlayerCharacter.checkIfBoxed(player));
player.setDirtyLoad(true);
updateStaticList(player, origin);
updateMobileList(player, origin);

62
src/engine/objects/PlayerCharacter.java

@ -5205,26 +5205,31 @@ public class PlayerCharacter extends AbstractCharacter { @@ -5205,26 +5205,31 @@ 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()) {
this.isBoxed = checkIfBoxed(this);
// if (!this.isBoxed && this.timestamps.get("nextBoxCheck") < System.currentTimeMillis()) {
// this.isBoxed = checkIfBoxed(this);
// this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000);
//}
if(this.timestamps.get("nextBoxCheck") < System.currentTimeMillis()) {
updateBoxStatus(this.isBoxed,checkIfBoxed(this));
this.timestamps.put("nextBoxCheck", System.currentTimeMillis() + 10000);
}
if (this.isBoxed){
if(!this.title.equals(CharacterTitle.PVE)){
this.title = CharacterTitle.PVE;
InterestManager.setObjectDirty(this);
InterestManager.reloadCharacter(this, false);
this.setDirtyLoad(true);
}
}else {
if (!this.title.equals(CharacterTitle.NONE)) {
this.title = CharacterTitle.NONE;
InterestManager.setObjectDirty(this);
InterestManager.reloadCharacter(this, false);
this.setDirtyLoad(true);
}
}
//if (this.isBoxed){
//if(!this.title.equals(CharacterTitle.PVE)){
// this.title = CharacterTitle.PVE;
// InterestManager.setObjectDirty(this);
// InterestManager.reloadCharacter(this, false);
// this.setDirtyLoad(true);
//}
//}else {
// if (!this.title.equals(CharacterTitle.NONE)) {
// this.title = CharacterTitle.NONE;
// InterestManager.setObjectDirty(this);
// InterestManager.reloadCharacter(this, false);
// this.setDirtyLoad(true);
// }
//}
if (this.level < 10 && this.enteredWorld) {
while (this.level < 10) {
@ -5264,6 +5269,24 @@ public class PlayerCharacter extends AbstractCharacter { @@ -5264,6 +5269,24 @@ public class PlayerCharacter extends AbstractCharacter {
Logger.error("UPDATE ISSUE: " + e);
}
}
public void updateBoxStatus(boolean oldValue, boolean newValue) {
if ((oldValue && newValue) || (!oldValue && !newValue))
return; // Status has not changed, no need to proceed
this.isBoxed = newValue; // Update the isBoxed status
if (newValue) {
// Change from not boxed to boxed
this.title = CharacterTitle.PVE;//replace with effect bit or other visual system eventually
} else {
// Change from boxed to not boxed
this.title = CharacterTitle.NONE;//replace with removing effect bit or other visual system eventually
}
//remove this after new visual system implemented
this.getClientConnection().forceDisconnect();
}
public static void unboxPlayer(PlayerCharacter player) {
String machineID = player.getClientConnection().machineID;
ArrayList<PlayerCharacter> sameMachine = new ArrayList<>();
@ -5275,9 +5298,10 @@ public class PlayerCharacter extends AbstractCharacter { @@ -5275,9 +5298,10 @@ public class PlayerCharacter extends AbstractCharacter {
for (PlayerCharacter pc : sameMachine) {
if(pc.equals(player))
continue;
pc.isBoxed = true;
//pc.isBoxed = true;
pc.updateBoxStatus(pc.isBoxed,true);
}
player.isBoxed = false;
player.updateBoxStatus(player.isBoxed,true);
}
public static boolean checkIfBoxed(PlayerCharacter player){
if(ConfigManager.MB_WORLD_BOXLIMIT.getValue().equals("false")) {

Loading…
Cancel
Save