mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 10:19:39 +00:00
Check connection status on batch, check sleep when players leave a level
This commit is contained in:
parent
925b0c1b07
commit
13906b32b8
@ -2668,10 +2668,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
foreach($this->windowIndex as $window){
|
||||
$this->removeWindow($window);
|
||||
}
|
||||
|
||||
$this->interface->close($this, $notify ? $reason : "");
|
||||
|
||||
$chunkX = $chunkZ = null;
|
||||
foreach($this->usedChunks as $index => $d){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$this->level->freeChunk($chunkX, $chunkZ, $this);
|
||||
@ -2680,6 +2677,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->interface->close($this, $notify ? $reason : "");
|
||||
|
||||
$this->loggedIn = false;
|
||||
|
||||
if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){
|
||||
|
@ -1833,7 +1833,9 @@ class Server{
|
||||
|
||||
$targets = [];
|
||||
foreach($players as $p){
|
||||
$targets[] = $this->identifiers[spl_object_hash($p)];
|
||||
if($p->isConnected()){
|
||||
$targets[] = $this->identifiers[spl_object_hash($p)];
|
||||
}
|
||||
}
|
||||
|
||||
if(!$forceSync and $this->networkCompressionAsync){
|
||||
|
@ -1460,13 +1460,13 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if(!$this->closed){
|
||||
$this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));
|
||||
$this->closed = true;
|
||||
$this->despawnFromAll();
|
||||
if($this->chunk !== null){
|
||||
$this->chunk->removeEntity($this);
|
||||
}
|
||||
if($this->level instanceof Level){
|
||||
$this->level->removeEntity($this);
|
||||
}
|
||||
$this->despawnFromAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,6 +659,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
public function checkSleep(){
|
||||
if(count($this->players) === 0){
|
||||
return;
|
||||
}
|
||||
|
||||
$resetTime = true;
|
||||
foreach($this->getPlayers() as $p){
|
||||
if(!$p->isSleeping()){
|
||||
@ -2078,7 +2082,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
if($entity instanceof Player){
|
||||
unset($this->players[$entity->getId()]);
|
||||
//$this->everyoneSleeping();
|
||||
$this->checkSleep();
|
||||
}else{
|
||||
$entity->kill();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user