mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
rough work for CommandOutputPacket, no idea if it works
This commit is contained in:
parent
8d07f833fc
commit
b51ec9e606
@ -26,16 +26,73 @@ namespace pocketmine\network\mcpe\protocol;
|
|||||||
#include <rules/DataPacket.h>
|
#include <rules/DataPacket.h>
|
||||||
|
|
||||||
use pocketmine\network\mcpe\NetworkSession;
|
use pocketmine\network\mcpe\NetworkSession;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\CommandOutputMessage;
|
||||||
|
|
||||||
class CommandOutputPacket extends DataPacket{
|
class CommandOutputPacket extends DataPacket{
|
||||||
const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
|
const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
|
||||||
|
|
||||||
|
/** @var CommandOriginData */
|
||||||
|
public $originData;
|
||||||
|
/** @var int */
|
||||||
|
public $outputType;
|
||||||
|
/** @var int */
|
||||||
|
public $successCount;
|
||||||
|
/** @var CommandOutputMessage[] */
|
||||||
|
public $messages = [];
|
||||||
|
/** @var string */
|
||||||
|
public $unknownString;
|
||||||
|
|
||||||
protected function decodePayload(){
|
protected function decodePayload(){
|
||||||
//TODO
|
$this->originData = $this->getCommandOriginData();
|
||||||
|
$this->outputType = $this->getByte();
|
||||||
|
$this->successCount = $this->getUnsignedVarInt();
|
||||||
|
|
||||||
|
for($i = 0, $size = $this->getUnsignedVarInt(); $i < $size; ++$i){
|
||||||
|
$this->messages[] = $this->getCommandMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->outputType === 4){
|
||||||
|
$this->unknownString = $this->getString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCommandMessage() : CommandOutputMessage{
|
||||||
|
$message = new CommandOutputMessage();
|
||||||
|
|
||||||
|
$message->isInternal = $this->getBool();
|
||||||
|
$message->messageId = $this->getString();
|
||||||
|
|
||||||
|
for($i = 0, $size = $this->getUnsignedVarInt(); $i < $size; ++$i){
|
||||||
|
$message->parameters[] = $this->getString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function encodePayload(){
|
protected function encodePayload(){
|
||||||
//TODO
|
$this->putCommandOriginData($this->originData);
|
||||||
|
$this->putByte($this->outputType);
|
||||||
|
$this->putUnsignedVarInt($this->successCount);
|
||||||
|
|
||||||
|
$this->putUnsignedVarInt(count($this->messages));
|
||||||
|
foreach($this->messages as $message){
|
||||||
|
$this->putCommandMessage($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->outputType === 4){
|
||||||
|
$this->putString($this->unknownString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function putCommandMessage(CommandOutputMessage $message){
|
||||||
|
$this->putBool($message->isInternal);
|
||||||
|
$this->putString($message->messageId);
|
||||||
|
|
||||||
|
$this->putUnsignedVarInt(count($message->parameters));
|
||||||
|
foreach($message->parameters as $parameter){
|
||||||
|
$this->putString($parameter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(NetworkSession $session) : bool{
|
public function handle(NetworkSession $session) : bool{
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
class CommandOutputMessage{
|
||||||
|
/** @var bool */
|
||||||
|
public $isInternal;
|
||||||
|
/** @var string */
|
||||||
|
public $messageId;
|
||||||
|
/** @var string[] */
|
||||||
|
public $parameters = [];
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user