mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-18 03:35:33 +00:00
CompoundTagMetadataProperty: fix unhandled exception when decoding
This commit is contained in:
parent
0a4a1f634f
commit
81620441a4
@ -23,8 +23,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\network\mcpe\protocol\types\entity;
|
namespace pocketmine\network\mcpe\protocol\types\entity;
|
||||||
|
|
||||||
|
use pocketmine\nbt\NbtDataException;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\TreeRoot;
|
use pocketmine\nbt\TreeRoot;
|
||||||
|
use pocketmine\network\BadPacketException;
|
||||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||||
use pocketmine\network\mcpe\serializer\NetworkNbtSerializer;
|
use pocketmine\network\mcpe\serializer\NetworkNbtSerializer;
|
||||||
|
|
||||||
@ -54,11 +56,21 @@ final class CompoundTagMetadataProperty implements MetadataProperty{
|
|||||||
return $other instanceof self and $other->value->equals($this->value);
|
return $other instanceof self and $other->value->equals($this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param NetworkBinaryStream $in
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws BadPacketException
|
||||||
|
*/
|
||||||
public static function read(NetworkBinaryStream $in) : self{
|
public static function read(NetworkBinaryStream $in) : self{
|
||||||
$offset = $in->getOffset();
|
$offset = $in->getOffset();
|
||||||
$result = new self((new NetworkNbtSerializer())->read($in->getBuffer(), $offset, 512)->getTag());
|
try{
|
||||||
|
$tag = (new NetworkNbtSerializer())->read($in->getBuffer(), $offset, 512)->mustGetCompoundTag();
|
||||||
|
}catch(NbtDataException $e){
|
||||||
|
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||||
|
}
|
||||||
$in->setOffset($offset);
|
$in->setOffset($offset);
|
||||||
return $result;
|
return new self($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write(NetworkBinaryStream $out) : void{
|
public function write(NetworkBinaryStream $out) : void{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user