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

HOW TO DELETE A WORLD

Discussion in 'Plugin Help' started by Shockskill, Feb 21, 2017.

  1. Shockskill

    Shockskill Silverfish

    Messages:
    15
    GitHub:
    Shockskill
    I will delete a world in the world file can y help me ?
    i have this but it not works


    private function rrmdir($dir) {
    if (is_dir($dir)) {
    $objects = scandir($dir);
    foreach ($objects as $object) {
    if ($object != "." && $object != "..&quot") {
    if (is_dir($dir."/".$object))
    rrmdir($dir."/".$object);
    else
    unlink($dir."/".$object);
    }
    }
    rmdir($dir);
    }
    }
    $this->rmdir("worlds/$arena");
     
  2. ZakousseMC

    ZakousseMC Spider Jockey

    Messages:
    46
    GitHub:
    ZakousseMC
    Please use
    PHP:
     [PHP
    for PHP and
    Code:
     [CODE] 
    for your code, otherwise it's pretty much impossible to understand...
     
    TheDiamondYT and HimbeersaftLP like this.
  3. Zayd

    Zayd Witch

    Messages:
    55
    GitHub:
    ZaydPE
    Simply go into FTP Server, 'worlds' folder and delete the world...
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    but i think OP is asking for code wise how to do it
     
  5. Zayd

    Zayd Witch

    Messages:
    55
    GitHub:
    ZaydPE
    Didn't realise. Sorry ;)
     
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    PHP:
    public function deleteLevel(\pocketmine\level\Level $level){
      
    $path $level->getProvider()->getPath();
      
    unloadLevel($leveltrue);
      
    self::deleteDir($path);
    }

    private static function 
    deleteDir($dir) {
       
    $files array_diff(scandir($dir), array('.','..'));
        foreach(
    $files as $file){
          (
    is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
        }
        return 
    rmdir($dir);
      }
     
  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.