1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to copy and paste worlds and teleport to them

Discussion in 'Development' started by WEATHERCRAFTYT1, Apr 20, 2021.

  1. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Hello, I’m working on a BedWars pratice server and I was wondering how to get a world for instance the world is “Bridge” and I want to copy it and paste it so when players play the practice gamemode it can copy the world and the player gets teleported to the copied world, when they leave the world automatically deletes.
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Copy the world and just put the copied file under /worlds folder..?
     
    WEATHERCRAFTYT1 likes this.
  3. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Yes, copy the world and paste it there and whenever I want to remove it as well
     
  4. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    PHP:
    <?php

    public function recursive_copy($src,$dst) {
        
    $dir opendir($src);
        @
    mkdir($dst);
        while(( 
    $file readdir($dir)) ) {
            if (( 
    $file != '.' ) && ( $file != '..' )) {
                if ( 
    is_dir($src '/' $file) ) {
                    
    $this->recursive_copy($src .'/'$file$dst .'/'$file);
                }
                else {
                    
    copy($src .'/'$file,$dst .'/'$file);
                }
            }
        }
        
    closedir($dir);
    }
    $this->recursive_copy("world_name""folder_worlds");
     
    WEATHERCRAFTYT1 likes this.
  5. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
     
  6. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    That Work?
     
  7. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Still haven’t test it yet
     
  8. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    If I want to teleport the player to the copied world?
     
  9. NutXzG

    NutXzG Baby Zombie

    Messages:
    132
    GitHub:
    NutXzG
    PHP:
    $level $this->getServer()->getLevelByNaame("WolrdYourCopyName");
    $player->teleport($level->getSafeSpawn());
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.