Introduce dedicated NBT data exceptions, fix up some corrupted chunk handling

This commit is contained in:
Dylan K. Taylor
2019-01-19 12:43:47 +00:00
parent c5998a92a8
commit 6b7710e62b
10 changed files with 117 additions and 49 deletions

View File

@ -35,6 +35,7 @@ use pocketmine\item\enchantment\EnchantmentInstance;
use pocketmine\math\Vector3;
use pocketmine\nbt\LittleEndianNbtSerializer;
use pocketmine\nbt\NBT;
use pocketmine\nbt\NbtDataException;
use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;
@ -64,11 +65,13 @@ class Item implements ItemIds, \JsonSerializable{
/** @var LittleEndianNbtSerializer */
private static $cachedParser = null;
/**
* @param string $tag
*
* @return CompoundTag
* @throws NbtDataException
*/
private static function parseCompoundTag(string $tag) : CompoundTag{
if($tag === ""){
throw new \InvalidArgumentException("No NBT data found in supplied string");
}
if(self::$cachedParser === null){
self::$cachedParser = new LittleEndianNbtSerializer();
}