Player: Give me ALLLLL your crashdumps

I suspect this is going to cause a firestorm, but once it does we'll be able to see what needs fixing.
This commit is contained in:
Dylan K. Taylor 2018-12-28 19:30:05 +00:00
parent 0ea166a551
commit 0eef634aab

View File

@ -3398,92 +3398,82 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
*/ */
final public function close($message = "", string $reason = "generic reason", bool $notify = true) : void{ final public function close($message = "", string $reason = "generic reason", bool $notify = true) : void{
if($this->isConnected() and !$this->closed){ if($this->isConnected() and !$this->closed){
if($notify and strlen($reason) > 0){
$pk = new DisconnectPacket();
$pk->message = $reason;
$this->directDataPacket($pk);
}
$this->interface->close($this, $notify ? $reason : "");
$this->sessionAdapter = null;
try{ PermissionManager::getInstance()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
if($notify and strlen($reason) > 0){ PermissionManager::getInstance()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
$pk = new DisconnectPacket();
$pk->message = $reason; $this->stopSleep();
$this->directDataPacket($pk);
if($this->spawned){
$ev = new PlayerQuitEvent($this, $message, $reason);
$ev->call();
if($ev->getQuitMessage() != ""){
$this->server->broadcastMessage($ev->getQuitMessage());
} }
$this->interface->close($this, $notify ? $reason : "");
$this->sessionAdapter = null;
PermissionManager::getInstance()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this); $this->save();
PermissionManager::getInstance()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this); }
$this->stopSleep(); if($this->isValid()){
foreach($this->usedChunks as $index => $d){
if($this->spawned){ Level::getXZ($index, $chunkX, $chunkZ);
$ev = new PlayerQuitEvent($this, $message, $reason); $this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
$ev->call(); foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){
if($ev->getQuitMessage() != ""){ $entity->despawnFrom($this);
$this->server->broadcastMessage($ev->getQuitMessage());
} }
unset($this->usedChunks[$index]);
}
}
$this->usedChunks = [];
$this->loadQueue = [];
try{ if($this->loggedIn){
$this->save(); $this->server->onPlayerLogout($this);
}catch(\Throwable $e){ foreach($this->server->getOnlinePlayers() as $player){
$this->server->getLogger()->critical("Failed to save player data for " . $this->getName()); if(!$player->canSee($this)){
$this->server->getLogger()->logException($e); $player->showPlayer($this);
} }
} }
$this->hiddenPlayers = [];
}
if($this->isValid()){ $this->removeAllWindows(true);
foreach($this->usedChunks as $index => $d){ $this->windows = [];
Level::getXZ($index, $chunkX, $chunkZ); $this->windowIndex = [];
$this->level->unregisterChunkLoader($this, $chunkX, $chunkZ); $this->cursorInventory = null;
foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){ $this->craftingGrid = null;
$entity->despawnFrom($this);
}
unset($this->usedChunks[$index]);
}
}
$this->usedChunks = [];
$this->loadQueue = [];
if($this->loggedIn){ if($this->constructed){
$this->server->onPlayerLogout($this); parent::close();
foreach($this->server->getOnlinePlayers() as $player){ }
if(!$player->canSee($this)){ $this->spawned = false;
$player->showPlayer($this);
}
}
$this->hiddenPlayers = [];
}
$this->removeAllWindows(true); if($this->loggedIn){
$this->windows = []; $this->loggedIn = false;
$this->windowIndex = []; $this->server->removeOnlinePlayer($this);
$this->cursorInventory = null; }
$this->craftingGrid = null;
if($this->constructed){ $this->server->removePlayer($this);
parent::close();
}
$this->spawned = false;
if($this->loggedIn){ $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [
$this->loggedIn = false; TextFormat::AQUA . $this->getName() . TextFormat::WHITE,
$this->server->removeOnlinePlayer($this); $this->ip,
} $this->port,
$this->getServer()->getLanguage()->translateString($reason)
]));
$this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [ $this->spawnPosition = null;
TextFormat::AQUA . $this->getName() . TextFormat::WHITE,
$this->ip,
$this->port,
$this->getServer()->getLanguage()->translateString($reason)
]));
$this->spawnPosition = null; if($this->perm !== null){
$this->perm->clearPermissions();
if($this->perm !== null){ $this->perm = null;
$this->perm->clearPermissions();
$this->perm = null;
}
}catch(\Throwable $e){
$this->server->getLogger()->logException($e);
}finally{
$this->server->removePlayer($this);
} }
} }
} }