mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Added NetworkSession->sendEncoded(), clean up some code
This commit is contained in:
parent
2647b3f404
commit
bdd42d6a78
@ -908,7 +908,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$this->usedChunks[Level::chunkHash($x, $z)] = true;
|
$this->usedChunks[Level::chunkHash($x, $z)] = true;
|
||||||
$this->chunkLoadCount++;
|
$this->chunkLoadCount++;
|
||||||
|
|
||||||
$this->networkSession->getInterface()->putPacket($this->networkSession, $payload);
|
$this->networkSession->sendEncoded($payload);
|
||||||
|
|
||||||
if($this->spawned){
|
if($this->spawned){
|
||||||
foreach($this->level->getChunkEntities($x, $z) as $entity){
|
foreach($this->level->getChunkEntities($x, $z) as $entity){
|
||||||
|
@ -1903,7 +1903,7 @@ class Server{
|
|||||||
public function broadcastPacketsCallback(string $payload, array $sessions, bool $immediate = false){
|
public function broadcastPacketsCallback(string $payload, array $sessions, bool $immediate = false){
|
||||||
/** @var NetworkSession $session */
|
/** @var NetworkSession $session */
|
||||||
foreach($sessions as $session){
|
foreach($sessions as $session){
|
||||||
$session->getInterface()->putPacket($session, $payload, $immediate);
|
$session->sendEncoded($payload, $immediate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +192,11 @@ class NetworkSession{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sendEncoded(string $payload, bool $immediate = false) : void{
|
||||||
|
//TODO: encryption
|
||||||
|
$this->interface->putPacket($this, $payload, $immediate);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the session, destroying the associated player (if it exists).
|
* Disconnects the session, destroying the associated player (if it exists).
|
||||||
*
|
*
|
||||||
|
@ -86,7 +86,7 @@ class PreSpawnSessionHandler extends SessionHandler{
|
|||||||
$this->player->sendAllInventories();
|
$this->player->sendAllInventories();
|
||||||
$this->player->getInventory()->sendCreativeContents();
|
$this->player->getInventory()->sendCreativeContents();
|
||||||
$this->player->getInventory()->sendHeldItem($this->player);
|
$this->player->getInventory()->sendHeldItem($this->player);
|
||||||
$this->session->getInterface()->putPacket($this->session, $this->server->getCraftingManager()->getCraftingDataPacket());
|
$this->session->sendEncoded($this->server->getCraftingManager()->getCraftingDataPacket());
|
||||||
|
|
||||||
$this->server->sendFullPlayerListData($this->player);
|
$this->server->sendFullPlayerListData($this->player);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user