Hello everyone. How to clone(duplicate) level with changing name of level. Sorry for my bad english...
This is method (not my, but I have permission), I use in my BW plugin: PHP: public function addWorld($worldname){ $base = ($worldname . "_base"); $source = Server::getInstance()->getDataPath() . "worlds/" . $base . "/"; $dest = Server::getInstance()->getDataPath() . "worlds/" . $worldname . "/"; $count = 0; if ($this->xcopy($source,$dest)){ try { Server::getInstance()->loadLevel($worldname); $level = Server::getInstance()->getLevelByName($worldname); }}function xcopy($source, $dest, $permissions = 0755) { if (is_link ( $source )) { return symlink ( readlink ( $source ), $dest ); } if (is_file ( $source )) { return copy ( $source, $dest ); } if (! is_dir ( $dest )) { mkdir ( $dest, $permissions ); } $dir = dir ( $source ); while ( false !== $entry = $dir->read () ) { if ($entry == '.' || $entry == '..') {continue; } $this->xcopy ( "$source/$entry", "$dest/$entry", $permissions );} $dir->close (); return true;} public function recurse_copy($src, $dst) { $dir = opendir ( $src ); @mkdir ( $dst ); while ( false !== ($file = readdir ( $dir )) ) { if (($file != '.') && ($file != '..')) { if (is_dir ( $src . '/' . $file )) { recurse_copy ( $src . '/' . $file, $dst . '/' . $file );} else { copy ( $src . '/' . $file, $dst . '/' . $file ); } } } closedir ( $dir );} PS: I rewrite a bit this method, so It can be laggy and bad. PS: This copy the level called $worldname."_base" to level $worldname
WoW, you have own BedWars plugin. I also. Now l do SW plugin. I copy level folder with other function.
Yes, I found out Server::getInstance() is bad. Like loads of starting PocketMine developers, I learned something by minecraftgenius. However, now, I don't use any methods of minecraftgenius. Reason: LAGGGGGGGS