mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +00:00
parent
bc10edfdd3
commit
a724395148
@ -3645,83 +3645,91 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
*/
|
*/
|
||||||
final public function close($message = "", $reason = "generic reason", $notify = true){
|
final public function close($message = "", $reason = "generic reason", $notify = true){
|
||||||
if($this->connected and !$this->closed){
|
if($this->connected and !$this->closed){
|
||||||
if($notify and strlen((string) $reason) > 0){
|
try{
|
||||||
$pk = new DisconnectPacket();
|
if($notify and strlen((string) $reason) > 0){
|
||||||
$pk->message = $reason;
|
$pk = new DisconnectPacket();
|
||||||
$this->directDataPacket($pk);
|
$pk->message = $reason;
|
||||||
}
|
$this->directDataPacket($pk);
|
||||||
|
|
||||||
$this->connected = false;
|
|
||||||
|
|
||||||
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
|
|
||||||
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
|
|
||||||
|
|
||||||
if($this->joined){
|
|
||||||
$this->save();
|
|
||||||
|
|
||||||
$this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
|
|
||||||
if($ev->getQuitMessage() != ""){
|
|
||||||
$this->server->broadcastMessage($ev->getQuitMessage());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->joined = false;
|
|
||||||
|
|
||||||
if($this->isValid()){
|
$this->connected = false;
|
||||||
foreach($this->usedChunks as $index => $d){
|
|
||||||
Level::getXZ($index, $chunkX, $chunkZ);
|
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
|
||||||
$this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
|
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
|
||||||
foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){
|
|
||||||
$entity->despawnFrom($this);
|
if($this->joined){
|
||||||
|
try{
|
||||||
|
$this->save();
|
||||||
|
}catch(\Throwable $e){
|
||||||
|
$this->server->getLogger()->critical("Failed to save player data for " . $this->getName());
|
||||||
|
$this->server->getLogger()->logException($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
|
||||||
|
if($ev->getQuitMessage() != ""){
|
||||||
|
$this->server->broadcastMessage($ev->getQuitMessage());
|
||||||
}
|
}
|
||||||
unset($this->usedChunks[$index]);
|
|
||||||
}
|
}
|
||||||
}
|
$this->joined = false;
|
||||||
$this->usedChunks = [];
|
|
||||||
$this->loadQueue = [];
|
|
||||||
|
|
||||||
foreach($this->server->getOnlinePlayers() as $player){
|
if($this->isValid()){
|
||||||
if(!$player->canSee($this)){
|
foreach($this->usedChunks as $index => $d){
|
||||||
$player->showPlayer($this);
|
Level::getXZ($index, $chunkX, $chunkZ);
|
||||||
|
$this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
|
||||||
|
foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){
|
||||||
|
$entity->despawnFrom($this);
|
||||||
|
}
|
||||||
|
unset($this->usedChunks[$index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
$this->usedChunks = [];
|
||||||
$this->hiddenPlayers = [];
|
$this->loadQueue = [];
|
||||||
|
|
||||||
foreach($this->windowIndex as $window){
|
foreach($this->server->getOnlinePlayers() as $player){
|
||||||
$this->removeWindow($window);
|
if(!$player->canSee($this)){
|
||||||
}
|
$player->showPlayer($this);
|
||||||
$this->windows = null;
|
}
|
||||||
$this->windowIndex = [];
|
}
|
||||||
|
$this->hiddenPlayers = [];
|
||||||
|
|
||||||
parent::close();
|
foreach($this->windowIndex as $window){
|
||||||
$this->spawned = false;
|
$this->removeWindow($window);
|
||||||
|
}
|
||||||
|
$this->windows = null;
|
||||||
|
$this->windowIndex = [];
|
||||||
|
|
||||||
$this->interface->close($this, $notify ? $reason : "");
|
parent::close();
|
||||||
|
$this->spawned = false;
|
||||||
|
|
||||||
if($this->loggedIn){
|
$this->interface->close($this, $notify ? $reason : "");
|
||||||
|
|
||||||
|
$this->loggedIn = false;
|
||||||
|
|
||||||
|
$this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [
|
||||||
|
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();
|
||||||
|
$this->perm = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->inventory !== null){
|
||||||
|
$this->inventory = null;
|
||||||
|
$this->currentTransaction = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(\Throwable $e){
|
||||||
|
$this->server->getLogger()->logException($e);
|
||||||
|
}finally{
|
||||||
$this->server->removeOnlinePlayer($this);
|
$this->server->removeOnlinePlayer($this);
|
||||||
|
$this->server->removePlayer($this);
|
||||||
}
|
}
|
||||||
$this->loggedIn = false;
|
|
||||||
|
|
||||||
$this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logOut", [
|
|
||||||
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();
|
|
||||||
$this->perm = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->inventory !== null){
|
|
||||||
$this->inventory = null;
|
|
||||||
$this->currentTransaction = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->server->removePlayer($this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user