mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
forward-port of 2f47597d75b514944a2f3f5d293f2fb72dd7fb56 as best it fits
This commit is contained in:
parent
84f41153e9
commit
45f9c61d0f
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user