mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Updated NBT/DataPacket reading
This commit is contained in:
parent
f72d7284b9
commit
82cfe6ea9c
@ -72,23 +72,15 @@ class NBT{
|
||||
public $endianness;
|
||||
private $data;
|
||||
|
||||
public function get($len){
|
||||
protected function get($len){
|
||||
if($len < 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
|
||||
return "";
|
||||
}elseif($len === true){
|
||||
return substr($this->buffer, $this->offset);
|
||||
}
|
||||
if($len > 16){
|
||||
return substr($this->buffer, ($this->offset += $len) - $len, $len);
|
||||
}
|
||||
$buffer = "";
|
||||
for(; $len > 0; --$len, ++$this->offset){
|
||||
$buffer .= $this->buffer{$this->offset};
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len);
|
||||
}
|
||||
|
||||
public function put($v){
|
||||
|
@ -115,20 +115,14 @@ abstract class DataPacket extends \stdClass{
|
||||
}
|
||||
|
||||
protected function get($len){
|
||||
if($len <= 0){
|
||||
if($len < 0){
|
||||
$this->offset = strlen($this->buffer) - 1;
|
||||
|
||||
return "";
|
||||
}elseif($len === true){
|
||||
return substr($this->buffer, $this->offset);
|
||||
}
|
||||
|
||||
$buffer = "";
|
||||
for(; $len > 0; --$len, ++$this->offset){
|
||||
$buffer .= $this->buffer{$this->offset};
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len);
|
||||
}
|
||||
|
||||
protected function put($str){
|
||||
|
Loading…
x
Reference in New Issue
Block a user