Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

copy and rename world ?

Comments in 'Plugin Development' started by Asparanc, Apr 28, 2015.

  1. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    With a pocketmine function how to copy a world ( exemple : copyworld ) and rename the copy with a custom name ( like "worldA") i need it in a function for a plugin. Like as onPlayerJoin....the plugins create a copy of the patern world and rename the copy with the player name. Can someone help me ?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Filesystem-related functions aren't related to PocketMine at all.

    PHP:
    function recursive_copyDir($from$to){
      @
    mkdir($to0777true);
      
    $from rtrim($from"/\\") . DIRECTORY_SEPARATOR;
      
    $to rtrim($to"/\\") . DIRECTORY_SEPARATOR;
      
    $dir dir($from);
      while((
    $f $dir->read()) !== false){
        
    $file $from $f;
        
    $toFile $to $f;
        if(
    is_dir($file)){
          
    recursive_copyDir($file$toFile);
        }else{
          
    copy($file$toFile);
        }
      }
    }
  3. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    I know but the name of the maps are not only in the directory name.
    Martin77Epic likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What do you mean?
  5. Asparanc
    Offline

    Asparanc Active Member

    Joined:
    Feb 20, 2015
    Posts:
    210
    Minecraft User:
    Asparanc
    The worlds have name, the name is in the level.dat, i would like know how to change it.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Unload it, create an NBT object, tell NBT to read level.dat using $nbt->readCompressed(), modify values inside it, reload level.
  7. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    How to reload a level? It can crash :p
  8. HOST
    Offline

    HOST Active Member

    Joined:
    Mar 15, 2015
    Posts:
    52
    Minecraft User:
    HOST
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    please when can i find tutorial how work with files and folders?
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Last edited: May 23, 2015
  11. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace

Share This Page

Advertisement