Handle errors properly on chunk load

Only CorruptedChunkException and UnsupportedChunkFormatException are expected. Anything else should crash the server.
This commit is contained in:
Dylan K. Taylor
2018-12-29 16:37:10 +00:00
parent beb5d72299
commit cd80ae00d4
5 changed files with 39 additions and 9 deletions

View File

@ -24,8 +24,8 @@ declare(strict_types=1);
namespace pocketmine\level\format\io\region;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\ChunkException;
use pocketmine\level\format\io\ChunkUtils;
use pocketmine\level\format\io\exception\CorruptedChunkException;
use pocketmine\level\format\SubChunk;
use pocketmine\nbt\BigEndianNBTStream;
use pocketmine\nbt\NBT;
@ -99,7 +99,7 @@ class Anvil extends McRegion{
$nbt = new BigEndianNBTStream();
$chunk = $nbt->readCompressed($data);
if(!($chunk instanceof CompoundTag) or !$chunk->hasTag("Level")){
throw new ChunkException("Invalid NBT format");
throw new CorruptedChunkException("'Level' key is missing from chunk NBT");
}
$chunk = $chunk->getCompoundTag("Level");