mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 00:55:14 +00:00
forward-port of 2f47597d75
as best it fits
This commit is contained in:
@ -111,8 +111,11 @@ class BedrockWorldData extends BaseNbtWorldData{
|
||||
}
|
||||
|
||||
protected function load() : CompoundTag{
|
||||
$rawLevelData = file_get_contents($this->dataPath);
|
||||
if($rawLevelData === false or strlen($rawLevelData) <= 8){
|
||||
$rawLevelData = @file_get_contents($this->dataPath);
|
||||
if($rawLevelData === false){
|
||||
throw new CorruptedWorldException("Failed to read level.dat (permission denied or doesn't exist)");
|
||||
}
|
||||
if(strlen($rawLevelData) <= 8){
|
||||
throw new CorruptedWorldException("Truncated level.dat");
|
||||
}
|
||||
$nbt = new LittleEndianNbtSerializer();
|
||||
|
@ -75,9 +75,13 @@ 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)");
|
||||
}
|
||||
$nbt = new BigEndianNbtSerializer();
|
||||
try{
|
||||
$worldData = $nbt->readCompressed(file_get_contents($this->dataPath))->mustGetCompoundTag();
|
||||
$worldData = $nbt->readCompressed($rawLevelData)->mustGetCompoundTag();
|
||||
}catch(NbtDataException $e){
|
||||
throw new CorruptedWorldException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user