I have *.tar archive in map/ I would like to create function, witch will untar map, change level name and load map But LevelProviderManager::getProvider don't work :c My code: PHP: // I have map/*.tar where '*' - standart name // And I need to get load map with custom name public function loadMap($standartMapName, $customMapName){ $path = $this->getServer()->getDataPath(); exec("tar -xf $path/map/$standartMapName.tar -C $path/worlds"); exec("mv $path/worlds/$standartMapName $path/worlds/$customMapName"); exec("chmod -R 777 $path/worlds/$customMapName/*"); $worldPath = "$path/worlds/$customMapName/"; $provider = LevelProviderManager::getProvider($worldPath); $provider->getLevelData()->LevelName = new StringTag("LevelName", $customMapName); $this->getServer()->loadLevel($customMapName); return true; } Error: Call to a member function getLevelData() on null
Solve, I change name of world dir and world name in level.dat PHP: public function loadMap($standartMapName, $customMapName){ $path = $this->plugin->getServer()->getDataPath(); exec("tar -xf $path/map/$standartMapName.tar -C $path/worlds"); exec("mv $path/worlds/$standartMapName $path/worlds/$customMapName"); exec("chmod -R 777 $path/worlds/$customMapName/*"); $worldPath = "$path/worlds/$customMapName/"; $data = file_get_contents($worldPath."level.dat"); $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->readCompressed($data); $nbt->getData()->Data->LevelName = new StringTag("__name", $customMapName); $this->plugin->getServer()->loadLevel($customMapName); }