mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Fixed crashes closing entities with unloaded levels
This commit is contained in:
parent
f8b9a13440
commit
abffe1297d
@ -1699,11 +1699,16 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->allowFlight = (bool) ($this->gamemode & 0x01);
|
||||
|
||||
if(($level = $this->server->getLevelByName($nbt["Level"])) === null){
|
||||
$this->setLevel($this->server->getDefaultLevel());
|
||||
$nbt["Level"] = $this->level->getName();
|
||||
$nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
|
||||
$nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
|
||||
$nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
|
||||
if($this->server->getDefaultLevel() instanceof Level){
|
||||
$this->setLevel($this->server->getDefaultLevel());
|
||||
$nbt["Level"] = $this->level->getName();
|
||||
$nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
|
||||
$nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
|
||||
$nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
|
||||
}else{
|
||||
$this->close("", "No default level is loaded", true);
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
$this->setLevel($level);
|
||||
}
|
||||
@ -3081,7 +3086,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
* @param bool $notify
|
||||
*/
|
||||
public final function close($message = "", $reason = "generic reason", $notify = true){
|
||||
|
||||
if($this->connected and !$this->closed){
|
||||
if($notify and strlen((string) $reason) > 0){
|
||||
$pk = new DisconnectPacket;
|
||||
@ -3108,8 +3112,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
unset($this->usedChunks[$index]);
|
||||
}
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->interface->close($this, $notify ? $reason : "");
|
||||
|
||||
if($this->loggedIn){
|
||||
@ -3127,6 +3129,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
}
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->loggedIn = false;
|
||||
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
|
||||
$this->spawned = false;
|
||||
@ -3142,21 +3146,21 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$this->loadQueue = [];
|
||||
$this->hasSpawned = [];
|
||||
$this->spawnPosition = null;
|
||||
|
||||
if($this->perm !== null){
|
||||
$this->perm->clearPermissions();
|
||||
$this->perm = null;
|
||||
}
|
||||
|
||||
if($this->inventory !== null){
|
||||
$this->inventory = null;
|
||||
$this->currentTransaction = null;
|
||||
}
|
||||
|
||||
$this->chunk = null;
|
||||
|
||||
$this->server->removePlayer($this);
|
||||
}
|
||||
|
||||
if($this->perm !== null){
|
||||
$this->perm->clearPermissions();
|
||||
$this->perm = null;
|
||||
}
|
||||
|
||||
if($this->inventory !== null){
|
||||
$this->inventory = null;
|
||||
$this->currentTransaction = null;
|
||||
}
|
||||
|
||||
$this->chunk = null;
|
||||
|
||||
$this->server->removePlayer($this);
|
||||
}
|
||||
|
||||
public function __debugInfo(){
|
||||
|
@ -1636,8 +1636,8 @@ abstract class Entity extends Location implements Metadatable{
|
||||
if($this->chunk !== null){
|
||||
$this->chunk->removeEntity($this);
|
||||
}
|
||||
if($this->level !== null){
|
||||
$this->level->removeEntity($this);
|
||||
if($this->getLevel() !== null){
|
||||
$this->getLevel()->removeEntity($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user