Merge remote-tracking branch 'origin/next-minor' into next-major

This commit is contained in:
Dylan K. Taylor
2022-12-25 18:22:13 +00:00
16 changed files with 136 additions and 129 deletions

View File

@ -41,7 +41,6 @@ use pocketmine\world\World;
use pocketmine\world\WorldCreationOptions;
use Symfony\Component\Filesystem\Path;
use function array_map;
use function file_get_contents;
use function file_put_contents;
use function strlen;
use function substr;
@ -138,9 +137,10 @@ class BedrockWorldData extends BaseNbtWorldData{
}
protected function load() : CompoundTag{
$rawLevelData = @file_get_contents($this->dataPath);
if($rawLevelData === false){
throw new CorruptedWorldException("Failed to read level.dat (permission denied or doesn't exist)");
try{
$rawLevelData = Filesystem::fileGetContents($this->dataPath);
}catch(\RuntimeException $e){
throw new CorruptedWorldException($e->getMessage(), 0, $e);
}
if(strlen($rawLevelData) <= 8){
throw new CorruptedWorldException("Truncated level.dat");

View File

@ -36,7 +36,6 @@ use pocketmine\world\World;
use pocketmine\world\WorldCreationOptions;
use Symfony\Component\Filesystem\Path;
use function ceil;
use function file_get_contents;
use function file_put_contents;
use function microtime;
use function zlib_decode;
@ -90,9 +89,10 @@ class JavaWorldData extends BaseNbtWorldData{
}
protected function load() : CompoundTag{
$rawLevelData = @file_get_contents($this->dataPath);
if($rawLevelData === false){
throw new CorruptedWorldException("Failed to read level.dat (permission denied or doesn't exist)");
try{
$rawLevelData = Filesystem::fileGetContents($this->dataPath);
}catch(\RuntimeException $e){
throw new CorruptedWorldException($e->getMessage(), 0, $e);
}
$nbt = new BigEndianNbtSerializer();
$decompressed = @zlib_decode($rawLevelData);