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

Error : Copy World

Discussion in 'Development' started by LCraftPE, Dec 4, 2016.

  1. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    Hello,
    I want to copy a world and I have this error :
    Code:
    "pocketmine\utils\LevelException: "Invalid empty level name" (EXCEPTION) in "/src/pocketmine/Server" at line 1160"
    
    "[Network] Stopped interface pocketmine\network\RakLibInterface due to Call to a member function getName() on null"
    
    "zend_mm_heap corrupted"
    My code (based on that of PEMapModder) :
    PHP:
    public function copyWorld(){
        
    $src $this->getDataFolder() . "/Map/Test";
        
    $dst $this->getServer()->getDataPath() . "/worlds";
        
    $dir opendir($src);
        @
    mkdir($dst);
        while (
    false !== ($file readdir($dir))){
          if((
    $file != '.') && ($file != '..')){
            if(
    is_dir($src '/' $file)){
              
    $this->copyWorld($src '/' $file$dst '/' $file);
           }else{
              
    copy($src '/' $file$dst '/' $file);
            }
          }
        }
        
    closedir($dir);
      }
    Thank you. :)
     
  2. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
  3. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    Before copying, I unload and delete the world and after copying I load the world.

    My code for delete :
    PHP:
      public function deleteWorld(){
        
    $dirPath $this->getServer()->getDataPath() . "/worlds/Test";
        if(
    is_dir($dirPath)){
          
    $objects scandir($dirPath);
          foreach(
    $objects as $object){
            if(
    $object != "." && $object != ".."){
              if(
    filetype($dirPath DIRECTORY_SEPARATOR $object) == "dir"){
                
    $this->deleteWorld($dirPath DIRECTORY_SEPARATOR $object);
              }else{
                
    unlink($dirPath DIRECTORY_SEPARATOR $object);
              }
            }
          }
          
    reset($objects);
          
    rmdir($dirPath);
        }
      }
    The function wich I use for reset the world :
    PHP:
      public function resetWorld(){
        
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName("Test"));
        
    $this->deleteWorld();
        
    $this->copyWorld();
        
    $this->getServer()->loadLevel($this->getServer()->getLevelByName("Test"));
      }
     
  4. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
    Server::loadLevel expects a string. Server::getLevelByName returns a previously loaded Level, or null if the level wasn't loaded, which is your case. You've to pass the name of the level directly to Server::loadLevel.
     
    SOFe likes this.
  5. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    Thank you !! :D
    But I have again the error (which crashing the server) :
    Code:
    "[Network] Stopped interface pocketmine\network\RakLibInterface due to Call to a member function getName() on null"
    "zend_mm_heap corrupted"
     
  6. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
    Can we see the server log? Fixing issues is awfully hard without context. Is it while stopping the server? Does it appear when the server is loading your plugin?
     
    SOFe likes this.
  7. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    The error appears when the "resetWorld" function is called.... The world is unloading and after the error appears... Maybe when the world is loading ? (I am almost sure but how can I correct this error ?) :)
    Code:
    [36m21:52:19[36m | [m[37mPocketMine thread:INFO[36m > [m[37mUnloading level "Test"[m
    [36m21:52:19[36m | [m[37mPocketMine thread:INFO[36m > [m[37mPreparing level "Test"[m
    [36m21:52:19[36m | [m[31mPocketMine thread:CRITICAL[36m > [m[31m[Network] Stopped interface pocketmine\network\RakLibInterface due to Call to a member function getName() on null[m
    zend_mm_heap corrupted
     
    Last edited: Dec 4, 2016
  8. KnownUnown

    KnownUnown Spider Jockey Poggit Reviewer

    Messages:
    47
    GitHub:
    knownunown
    Awfully strange that when calling world functions the network decides to break. Do you mess with network functions in your plugin?
     
  9. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    No :/
     
  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.