Fixed world data ::generate() functions putting level.dat in the wrong place if the world path didn't end with a /

This commit is contained in:
Dylan K. Taylor 2021-10-08 23:39:25 +01:00
parent 4910250a81
commit 308d7c126a
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 4 additions and 2 deletions

View File

@ -39,6 +39,7 @@ use pocketmine\world\generator\Generator;
use pocketmine\world\generator\GeneratorManager;
use pocketmine\world\World;
use pocketmine\world\WorldCreationOptions;
use Webmozart\PathUtil\Path;
use function file_get_contents;
use function file_put_contents;
use function strlen;
@ -101,7 +102,7 @@ class BedrockWorldData extends BaseNbtWorldData{
$nbt = new LittleEndianNbtSerializer();
$buffer = $nbt->write(new TreeRoot($worldData));
file_put_contents($path . "level.dat", Binary::writeLInt(self::CURRENT_STORAGE_VERSION) . Binary::writeLInt(strlen($buffer)) . $buffer);
file_put_contents(Path::join($path, "level.dat"), Binary::writeLInt(self::CURRENT_STORAGE_VERSION) . Binary::writeLInt(strlen($buffer)) . $buffer);
}
protected function load() : CompoundTag{

View File

@ -33,6 +33,7 @@ use pocketmine\world\format\io\exception\CorruptedWorldException;
use pocketmine\world\generator\GeneratorManager;
use pocketmine\world\World;
use pocketmine\world\WorldCreationOptions;
use Webmozart\PathUtil\Path;
use function ceil;
use function file_get_contents;
use function file_put_contents;
@ -68,7 +69,7 @@ class JavaWorldData extends BaseNbtWorldData{
$nbt = new BigEndianNbtSerializer();
$buffer = zlib_encode($nbt->write(new TreeRoot(CompoundTag::create()->setTag("Data", $worldData))), ZLIB_ENCODING_GZIP);
file_put_contents($path . "level.dat", $buffer);
file_put_contents(Path::join($path, "level.dat"), $buffer);
}
protected function load() : CompoundTag{