mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Server->batchPackets() now only accepts DataPacket objects, fixed players receiving double PlayerListPackets with their own data
This commit is contained in:
@ -54,20 +54,17 @@ class BatchPacket extends DataPacket{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataPacket|string $packet
|
||||
* @param DataPacket $packet
|
||||
*/
|
||||
public function addPacket($packet){
|
||||
if($packet instanceof DataPacket){
|
||||
if(!$packet->canBeBatched()){
|
||||
throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket");
|
||||
}
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
}
|
||||
$packet = $packet->buffer;
|
||||
public function addPacket(DataPacket $packet){
|
||||
if(!$packet->canBeBatched()){
|
||||
throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket");
|
||||
}
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
}
|
||||
|
||||
$this->payload .= Binary::writeUnsignedVarInt(strlen($packet)) . $packet;
|
||||
$this->payload .= Binary::writeUnsignedVarInt(strlen($packet->buffer)) . $packet->buffer;
|
||||
}
|
||||
|
||||
public function compress(int $level = 7){
|
||||
|
Reference in New Issue
Block a user