Browse Source

box check only every 10 seconds

lakebane-master
FatBoy-DOTC 6 months ago
parent
commit
422cf10eea
  1. 2
      src/engine/InterestManagement/InterestManager.java
  2. 25
      src/engine/objects/PlayerCharacter.java

2
src/engine/InterestManagement/InterestManager.java

@ -530,7 +530,7 @@ public enum InterestManager implements Runnable { @@ -530,7 +530,7 @@ public enum InterestManager implements Runnable {
player.setDirtyLoad(true);
updateStaticList(player, origin);
updateMobileList(player, origin);
player.isBoxed = PlayerCharacter.checkIfBoxed(player);
PlayerCharacter.checkIfBoxed(player);
}

25
src/engine/objects/PlayerCharacter.java

@ -180,7 +180,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -180,7 +180,7 @@ public class PlayerCharacter extends AbstractCharacter {
public long lastAction = 0;
public long lastBoxCheck = System.currentTimeMillis();
public long nextBoxCheck = System.currentTimeMillis();
/**
* No Id Constructor
*/
@ -4865,11 +4865,13 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4865,11 +4865,13 @@ public class PlayerCharacter extends AbstractCharacter {
ItemFactory.fillInventory(this, 980066, 1);
}
}
this.isBoxed = checkIfBoxed(this);
if(!this.isBoxed) {
checkIfBoxed(this);
}
if(this.isBoxed) {
if(!this.title.equals(CharacterTitle.BOX)) {
this.title = CharacterTitle.BOX;
InterestManager.reloadCharacter(this);
//InterestManager.reloadCharacter(this);
}
if (!this.containsEffect(1672601862)) {//Deathshroud
@ -4881,7 +4883,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4881,7 +4883,7 @@ public class PlayerCharacter extends AbstractCharacter {
}else{
if(!this.title.equals(CharacterTitle.NONE)) {
this.title = CharacterTitle.NONE;
InterestManager.reloadCharacter(this);
//InterestManager.reloadCharacter(this);
}
}
}
@ -4894,11 +4896,11 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4894,11 +4896,11 @@ public class PlayerCharacter extends AbstractCharacter {
}
}
public static boolean checkIfBoxed(PlayerCharacter player){
if(System.currentTimeMillis() < player.lastBoxCheck + 5000)
return false;
public static void checkIfBoxed(PlayerCharacter player){
if(System.currentTimeMillis() > player.nextBoxCheck)
return;
player.lastBoxCheck = System.currentTimeMillis();
player.nextBoxCheck = System.currentTimeMillis() + 10000;
try {
for (PlayerCharacter pc : SessionManager.getAllActivePlayers()) {
if(pc.getClientConnection().machineID.equals(player.getClientConnection().machineID) == false)
@ -4910,13 +4912,14 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4910,13 +4912,14 @@ public class PlayerCharacter extends AbstractCharacter {
if (pc.equals(player))
continue;
if (pc.isBoxed == false) {
return true;
player.isBoxed = true;
return;
}
}
return false;
player.isBoxed = false;
}catch(Exception e){
return false;
player.isBoxed = false;
}
}

Loading…
Cancel
Save