forked from MagicBane/Server
stop invisible player plague
This commit is contained in:
@@ -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 {
|
||||
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 {
|
||||
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")) {
|
||||
|
||||
Reference in New Issue
Block a user