mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Avoid use of internal fields in BinaryStream
This commit is contained in:
@ -56,7 +56,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
$stream = new PacketStream();
|
||||
$stream->putPacket($pk);
|
||||
|
||||
$this->setResult(NetworkCompression::compress($stream->buffer, $this->compressionLevel));
|
||||
$this->setResult(NetworkCompression::compress($stream->getBuffer(), $this->compressionLevel));
|
||||
}
|
||||
|
||||
public function onCompletion() : void{
|
||||
|
@ -31,12 +31,12 @@ class CompressBatchTask extends AsyncTask{
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @param PacketStream $stream
|
||||
* @param string $data
|
||||
* @param int $compressionLevel
|
||||
* @param CompressBatchPromise $promise
|
||||
*/
|
||||
public function __construct(PacketStream $stream, int $compressionLevel, CompressBatchPromise $promise){
|
||||
$this->data = $stream->buffer;
|
||||
public function __construct(string $data, int $compressionLevel, CompressBatchPromise $promise){
|
||||
$this->data = $data;
|
||||
$this->level = $compressionLevel;
|
||||
$this->storeLocal($promise);
|
||||
}
|
||||
|
@ -198,14 +198,14 @@ class NetworkSession{
|
||||
|
||||
$packet->decode();
|
||||
if(!$packet->feof() and !$packet->mayHaveUnreadBytes()){
|
||||
$remains = substr($packet->buffer, $packet->offset);
|
||||
$remains = substr($packet->getBuffer(), $packet->getOffset());
|
||||
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
|
||||
}
|
||||
|
||||
$ev = new DataPacketReceiveEvent($this->player, $packet);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled() and !$packet->handle($this->handler)){
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->getBuffer()));
|
||||
}
|
||||
|
||||
$timings->stopTiming();
|
||||
|
@ -32,7 +32,7 @@ class PacketStream extends NetworkBinaryStream{
|
||||
if(!$packet->isEncoded){
|
||||
$packet->encode();
|
||||
}
|
||||
$this->putString($packet->buffer);
|
||||
$this->putString($packet->getBuffer());
|
||||
}
|
||||
|
||||
public function getPacket() : DataPacket{
|
||||
|
@ -62,7 +62,7 @@ abstract class DataPacket extends NetworkBinaryStream{
|
||||
}
|
||||
|
||||
public function decode() : void{
|
||||
$this->offset = 0;
|
||||
$this->rewind();
|
||||
$this->decodeHeader();
|
||||
$this->decodePayload();
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ class StartGamePacket extends DataPacket{
|
||||
$stream->putString($v["name"]);
|
||||
$stream->putLShort($v["data"]);
|
||||
}
|
||||
self::$runtimeIdTable = $stream->buffer;
|
||||
self::$runtimeIdTable = $stream->getBuffer();
|
||||
}
|
||||
$this->put(self::$runtimeIdTable);
|
||||
|
||||
|
Reference in New Issue
Block a user