updated CommandRequestPacket

This commit is contained in:
Dylan K. Taylor 2017-11-01 20:11:31 +00:00
parent 372b97ba8f
commit 8d07f833fc
3 changed files with 86 additions and 2 deletions

View File

@ -26,21 +26,28 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
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{

View File

@ -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);
}
}
}

View File

@ -0,0 +1,52 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types;
use pocketmine\utils\UUID;
class CommandOriginData{
const ORIGIN_PLAYER = 0;
const ORIGIN_BLOCK = 1;
const ORIGIN_MINECART_BLOCK = 2;
const ORIGIN_DEV_CONSOLE = 3;
const ORIGIN_TEST = 4;
const ORIGIN_AUTOMATION_PLAYER = 5;
const ORIGIN_CLIENT_AUTOMATION = 6;
const ORIGIN_DEDICATED_SERVER = 7;
const ORIGIN_ENTITY = 8;
const ORIGIN_VIRTUAL = 9;
const ORIGIN_GAME_ARGUMENT = 10;
const ORIGIN_ENTITY_SERVER = 11; //???
/** @var int */
public $type;
/** @var UUID */
public $uuid;
/** @var string */
public $requestId;
/** @var int */
public $varlong1;
}