I would like to untar and rename map: I have <server>/map/DarkForest.tar (with level.dat and region/) I try to untar map to <server>/worlds/HG1 and load it My code: PHP: // I try loadMap("DarkForest", "HG1");public function loadMap($standartMapName, $customMapName){ // Server path $path = $this->plugin->getServer()->getDataPath(); // Untar map to worlds exec("tar -xf $path/map/$standartMapName.tar -C $path/worlds"); // Rename to $customName exec("mv $path/worlds/$standartMapName $path/worlds/$customMapName"); $worldPath = "$path/worlds/$customMapName/"; // Cnange LevelName to $customName in level.dat $data = file_get_contents($worldPath."level.dat"); $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->readCompressed($data); $nbt->getData()->Data->LevelName = new StringTag("LevelName", $customMapName); $this->plugin->getServer()->loadLevel($customMapName);} And it's load map with name "DarkForest", whyy?)
No Spoiler: var_dump($nbt) PHP: object(pocketmine\nbt\NBT)#15733 (4) { ["buffer"]=> string(0) "" ["offset":"pocketmine\nbt\NBT":private]=> int(1225) ["endianness"]=> int(1) ["data":"pocketmine\nbt\NBT":private]=> object(pocketmine\nbt\tag\CompoundTag)#15611 (3) { ["__name":protected]=> string(0) "" ["value":protected]=> array(0) { } ["Data"]=> object(pocketmine\nbt\tag\CompoundTag)#15636 (40) { ["__name":protected]=> string(4) "Data" ["value":protected]=> array(0) { } *** ["LevelName"]=> object(pocketmine\nbt\tag\StringTag)#15587 (2) { ["__name":protected]=> string(9) "LevelName" ["value":protected]=> string(3) "HG1" } *** } }} Full var_dump($nbt): http://pastebin.com/iQy19yp2 UPD: Map copy from minecraft pc.
Ooops, i miss PHP: $nbt = $nbt->writeCompressed();file_put_contents($worldPath."level.dat", $nbt); xD