BaseLevelProvider: clean up not-exists error handling disaster

It checks for the existence of (and creates) the world directory if it doesn't exist. But what sense does this make when the world obviously doesn't exist in this case and must be generated first?
This commit is contained in:
Dylan K. Taylor
2018-10-04 15:41:18 +01:00
parent f787552e97
commit 4f421d561c
2 changed files with 13 additions and 5 deletions

View File

@ -100,8 +100,12 @@ class LevelDB extends BaseLevelProvider{
}
protected function loadLevelData() : void{
$levelDatPath = $this->getPath() . "level.dat";
if(!file_exists($levelDatPath)){
throw new LevelException("level.dat not found");
}
$nbt = new LittleEndianNBTStream();
$levelData = $nbt->read(substr(file_get_contents($this->getPath() . "level.dat"), 8));
$levelData = $nbt->read(substr(file_get_contents($levelDatPath), 8));
if($levelData instanceof CompoundTag){
$this->levelData = $levelData;
}else{