mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Fixed NBT parsing on false properties
This commit is contained in:
@ -119,28 +119,26 @@ class NBT{
|
||||
*/
|
||||
public function write(){
|
||||
$this->offset = 0;
|
||||
$data = false;
|
||||
if($this->data instanceof Compound){
|
||||
$this->writeTag($this->data);
|
||||
|
||||
$data = $this->buffer;
|
||||
return $this->buffer;
|
||||
}elseif(is_array($this->data)){
|
||||
foreach($this->data as $tag){
|
||||
$this->writeTag($tag);
|
||||
}
|
||||
$data = $this->buffer;
|
||||
return $this->buffer;
|
||||
}
|
||||
|
||||
return $data;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function writeCompressed($compression = ZLIB_ENCODING_GZIP, $level = 7){
|
||||
$data = false;
|
||||
if(($write = $this->write()) !== false){
|
||||
$data = zlib_encode($write, $compression, $level);
|
||||
return zlib_encode($write, $compression, $level);
|
||||
}
|
||||
|
||||
return $data;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function readTag(){
|
||||
@ -312,7 +310,7 @@ class NBT{
|
||||
}
|
||||
|
||||
public function setArray(array $data){
|
||||
$this->data = new Compound(null, []);
|
||||
$this->data = new Compound("", []);
|
||||
$this->fromArray($this->data, $data);
|
||||
}
|
||||
|
||||
|
@ -110,57 +110,57 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{
|
||||
for($i = 0; $i < $size and !$nbt->feof(); ++$i){
|
||||
switch($this->tagType){
|
||||
case NBT::TAG_Byte:
|
||||
$tag = new Byte(false);
|
||||
$tag = new Byte("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Short:
|
||||
$tag = new Short(false);
|
||||
$tag = new Short("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Int:
|
||||
$tag = new Int(false);
|
||||
$tag = new Int("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Long:
|
||||
$tag = new Long(false);
|
||||
$tag = new Long("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Float:
|
||||
$tag = new Float(false);
|
||||
$tag = new Float("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Double:
|
||||
$tag = new Double(false);
|
||||
$tag = new Double("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_ByteArray:
|
||||
$tag = new ByteArray(false);
|
||||
$tag = new ByteArray("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_String:
|
||||
$tag = new String(false);
|
||||
$tag = new String("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Enum:
|
||||
$tag = new TagEnum(false);
|
||||
$tag = new TagEnum("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_Compound:
|
||||
$tag = new Compound(false);
|
||||
$tag = new Compound("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
case NBT::TAG_IntArray:
|
||||
$tag = new IntArray(false);
|
||||
$tag = new IntArray("");
|
||||
$tag->read($nbt);
|
||||
$this->{$i} = $tag;
|
||||
break;
|
||||
|
@ -31,7 +31,7 @@ abstract class NamedTag extends Tag{
|
||||
* @param bool|float|double|int|byte|short|array|Compound|Enum|string $value
|
||||
*/
|
||||
public function __construct($name = "", $value = null){
|
||||
$this->name = $name;
|
||||
$this->name = ($name === null or $name === false) ? "" : $name;
|
||||
if($value !== null){
|
||||
$this->value = $value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user