NetworkSession: allow provision of a custom list of players to syncPlayerList()

This commit is contained in:
Dylan K. Taylor 2020-04-29 16:27:34 +01:00
parent d8968e9e40
commit ad70a9e3dc
2 changed files with 6 additions and 3 deletions

View File

@ -835,10 +835,13 @@ class NetworkSession{
$this->sendDataPacket(TakeItemActorPacket::create($collector->getId(), $pickedUp->getId())); $this->sendDataPacket(TakeItemActorPacket::create($collector->getId(), $pickedUp->getId()));
} }
public function syncPlayerList() : void{ /**
* @param Player[] $players
*/
public function syncPlayerList(array $players) : void{
$this->sendDataPacket(PlayerListPacket::add(array_map(function(Player $player) : PlayerListEntry{ $this->sendDataPacket(PlayerListPacket::add(array_map(function(Player $player) : PlayerListEntry{
return PlayerListEntry::createAdditionEntry($player->getUniqueId(), $player->getId(), $player->getDisplayName(), SkinAdapterSingleton::get()->toSkinData($player->getSkin()), $player->getXuid()); return PlayerListEntry::createAdditionEntry($player->getUniqueId(), $player->getId(), $player->getDisplayName(), SkinAdapterSingleton::get()->toSkinData($player->getSkin()), $player->getXuid());
}, $this->server->getOnlinePlayers()))); }, $players)));
} }
public function onPlayerAdded(Player $p) : void{ public function onPlayerAdded(Player $p) : void{

View File

@ -99,7 +99,7 @@ class PreSpawnPacketHandler extends PacketHandler{
$this->session->getInvManager()->syncSelectedHotbarSlot(); $this->session->getInvManager()->syncSelectedHotbarSlot();
$this->session->queueCompressed($this->server->getCraftingManager()->getCraftingDataPacket($this->session->getCompressor())); $this->session->queueCompressed($this->server->getCraftingManager()->getCraftingDataPacket($this->session->getCompressor()));
$this->session->syncPlayerList(); $this->session->syncPlayerList($this->server->getOnlinePlayers());
} }
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{ public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{