From 486ce140d83b18d34b272fee78d05884d738d8dc Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 18 May 2020 17:35:30 +0100 Subject: [PATCH] PacketBatch no longer extends NetworkBinaryStream this removes a whole bunch of crap from its API that shouldn't have been exposed. In the future we should look at splitting this into reader/writer halves, but for now this is a step in the right direction. --- .../mcpe/protocol/serializer/PacketBatch.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/network/mcpe/protocol/serializer/PacketBatch.php b/src/network/mcpe/protocol/serializer/PacketBatch.php index 15bfaeb3b..e58001539 100644 --- a/src/network/mcpe/protocol/serializer/PacketBatch.php +++ b/src/network/mcpe/protocol/serializer/PacketBatch.php @@ -27,18 +27,25 @@ use pocketmine\network\mcpe\protocol\Packet; use pocketmine\network\mcpe\protocol\PacketPool; use pocketmine\utils\BinaryDataException; -class PacketBatch extends NetworkBinaryStream{ +class PacketBatch{ + + /** @var NetworkBinaryStream */ + private $binaryStream; + + public function __construct(?string $buffer = null){ + $this->binaryStream = new NetworkBinaryStream($buffer ?? ""); + } public function putPacket(Packet $packet) : void{ $packet->encode(); - $this->putString($packet->getBinaryStream()->getBuffer()); + $this->binaryStream->putString($packet->getBinaryStream()->getBuffer()); } /** * @throws BinaryDataException */ public function getPacket(PacketPool $packetPool) : Packet{ - return $packetPool->getPacket($this->getString()); + return $packetPool->getPacket($this->binaryStream->getString()); } /** @@ -55,4 +62,12 @@ class PacketBatch extends NetworkBinaryStream{ } return $result; } + + public function getBuffer() : string{ + return $this->binaryStream->getBuffer(); + } + + public function feof() : bool{ + return $this->binaryStream->feof(); + } }