diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index 0eeb9abe8..344ed5a5f 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -65,7 +65,7 @@ abstract class DataPacket extends NetworkBinaryStream{ * @throws \OutOfBoundsException * @throws \UnexpectedValueException */ - public function decode() : void{ + final public function decode() : void{ $this->rewind(); $this->decodeHeader(); $this->decodePayload(); @@ -83,16 +83,14 @@ abstract class DataPacket extends NetworkBinaryStream{ } /** - * Note for plugin developers: If you're adding your own packets, you should perform decoding in here. + * Decodes the packet body, without the packet ID or other generic header fields. * * @throws \OutOfBoundsException * @throws \UnexpectedValueException */ - protected function decodePayload() : void{ + abstract protected function decodePayload() : void; - } - - public function encode() : void{ + final public function encode() : void{ $this->reset(); $this->encodeHeader(); $this->encodePayload(); @@ -104,11 +102,9 @@ abstract class DataPacket extends NetworkBinaryStream{ } /** - * Note for plugin developers: If you're adding your own packets, you should perform encoding in here. + * Encodes the packet body, without the packet ID or other generic header fields. */ - protected function encodePayload() : void{ - - } + abstract protected function encodePayload() : void; /** * Performs handling for this packet. Usually you'll want an appropriately named method in the session handler for diff --git a/src/pocketmine/network/mcpe/protocol/UnknownPacket.php b/src/pocketmine/network/mcpe/protocol/UnknownPacket.php index 6daf12bfb..f2e5986eb 100644 --- a/src/pocketmine/network/mcpe/protocol/UnknownPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UnknownPacket.php @@ -44,12 +44,19 @@ class UnknownPacket extends DataPacket{ return "unknown packet"; } - public function decode() : void{ + protected function decodeHeader() : void{ + + } + + protected function decodePayload() : void{ $this->payload = $this->getRemaining(); } - public function encode() : void{ - //Do not reset the buffer, this class does not have a valid NETWORK_ID constant. + protected function encodeHeader() : void{ + + } + + protected function encodePayload() : void{ $this->put($this->payload); }