diff --git a/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php b/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php index 5a1490669..b6975d21b 100644 --- a/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php @@ -26,21 +26,28 @@ namespace pocketmine\network\mcpe\protocol; #include use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\types\CommandOriginData; class CommandRequestPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET; /** @var string */ public $command; + /** @var CommandOriginData */ + public $originData; + /** @var bool */ + public $isInternal; protected function decodePayload(){ $this->command = $this->getString(); - //TODO: everything else + $this->originData = $this->getCommandOriginData(); + $this->isInternal = $this->getBool(); } protected function encodePayload(){ $this->putString($this->command); - //TODO + $this->putCommandOriginData($this->originData); + $this->putBool($this->isInternal); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index 908635dae..8361d065e 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -30,6 +30,7 @@ use pocketmine\entity\Entity; use pocketmine\item\ItemFactory; use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\types\CommandOriginData; use pocketmine\network\mcpe\protocol\types\EntityLink; use pocketmine\utils\BinaryStream; use pocketmine\utils\Utils; @@ -537,4 +538,28 @@ abstract class DataPacket extends BinaryStream{ $this->putByte($link->type); $this->putBool($link->bool1); } + + protected function getCommandOriginData() : CommandOriginData{ + $result = new CommandOriginData(); + + $result->type = $this->getUnsignedVarInt(); + $result->uuid = $this->getUUID(); + $result->requestId = $this->getString(); + + if($result->type === CommandOriginData::ORIGIN_DEV_CONSOLE or $result->type === CommandOriginData::ORIGIN_TEST){ + $result->varlong1 = $this->getVarLong(); + } + + return $result; + } + + protected function putCommandOriginData(CommandOriginData $data) : void{ + $this->putUnsignedVarInt($data->type); + $this->putUUID($data->uuid); + $this->putString($data->requestId); + + if($data->type === CommandOriginData::ORIGIN_DEV_CONSOLE or $data->type === CommandOriginData::ORIGIN_TEST){ + $this->putVarLong($data->varlong1); + } + } } diff --git a/src/pocketmine/network/mcpe/protocol/types/CommandOriginData.php b/src/pocketmine/network/mcpe/protocol/types/CommandOriginData.php new file mode 100644 index 000000000..de8ce6091 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/types/CommandOriginData.php @@ -0,0 +1,52 @@ +