mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Added correct handling of RemovePlayer packet for in-game player list
This commit is contained in:
@ -148,7 +148,9 @@ class EntityAPI{
|
||||
|
||||
public function spawnAll(Player $player){
|
||||
foreach($this->getAll($player->level) as $e){
|
||||
$e->spawn($player);
|
||||
if($e->class !== ENTITY_PLAYER){
|
||||
$e->spawn($player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,6 +161,16 @@ class EntityAPI{
|
||||
unset($this->entities[$eid]);
|
||||
$entity->closed = true;
|
||||
$this->server->query("DELETE FROM entities WHERE EID = ".$eid.";");
|
||||
if($entity->class === ENTITY_PLAYER){
|
||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($entity->level), MC_REMOVE_PLAYER, array(
|
||||
"clientID" => 0,
|
||||
"eid" => $entity->eid,
|
||||
));
|
||||
}else{
|
||||
$this->server->api->player->broadcastPacket($this->server->api->player->getAll($entity->level), MC_REMOVE_ENTITY, array(
|
||||
"eid" => $entity->eid,
|
||||
));
|
||||
}
|
||||
$this->server->api->dhandle("entity.remove", $entity);
|
||||
$entity = null;
|
||||
unset($entity);
|
||||
|
@ -375,6 +375,42 @@ class PlayerAPI{
|
||||
$this->server->query("INSERT OR REPLACE INTO players (CID, ip, port, name) VALUES (".$player->CID.", '".$player->ip."', ".$player->port.", '".strtolower($player->username)."');");
|
||||
}
|
||||
}
|
||||
|
||||
public function spawnAllPlayers(Player $player){
|
||||
foreach($this->getAll() as $p){
|
||||
if($p !== $player){
|
||||
$p->entity->spawn($player);
|
||||
if($p->level !== $player->level){
|
||||
$player->dataPacket(MC_MOVE_ENTITY_POSROT, array(
|
||||
"eid" => $p->entity->eid,
|
||||
"x" => -256,
|
||||
"y" => 128,
|
||||
"z" => -256,
|
||||
"yaw" => 0,
|
||||
"pitch" => 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function spawnToAllPlayers(Player $player){
|
||||
foreach($this->getAll() as $p){
|
||||
if($p !== $player){
|
||||
$player->entity->spawn($p);
|
||||
if($p->level !== $player->level){
|
||||
$p->dataPacket(MC_MOVE_ENTITY_POSROT, array(
|
||||
"eid" => $player->entity->eid,
|
||||
"x" => -256,
|
||||
"y" => 128,
|
||||
"z" => -256,
|
||||
"yaw" => 0,
|
||||
"pitch" => 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($CID){
|
||||
if(isset($this->server->clients[$CID])){
|
||||
|
Reference in New Issue
Block a user