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

Deleting a world completely

Comments in 'Plugin Development' started by args, Sep 5, 2014.

  1. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    How would I go about getting the folder of one of the worlds in the worlds folder?

    I've got some code to unload the world, and to delete the directory once its found.

    I have a feeling one of these functions may be helpful but I'm haven't really worked with directoriees in php before and have hit a bit of wall:
    $level->getFolderName();
    $worldFolder = dir($this->getDataFolder());

    The goal is to have the map reset every time the server closes or the function is called.

    Regards, args
    LDX likes this.
  2. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    78
    You can use PHP functions. You can remove a directory using rmdir(); but first you must delete all files inside.
    LDX likes this.
  3. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Yeah, ive got a code snippet for remove the file and directories, I just need to work out how to locate the world directory and im not sure how to find it,
    thanks for the reply
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You need to hardcode it:
    PHP:
    $this->getServer()->getDataPath() . "worlds/$worldName"
    64FF00 likes this.
  5. 64FF00
    Offline

    64FF00 Active Member Plugin Developer

    Joined:
    May 11, 2014
    Posts:
    298
    Plugins:
    2
    Minecraft User:
    64FF00
    + rmdir()
    Adaasi likes this.
  6. args
    Offline

    args New Member

    Joined:
    Jun 14, 2014
    Posts:
    47
    Minecraft User:
    args
    Cheers guys, much appreciated:)
    Adaasi likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yeah he saw it, he just said he didn't know the directory path.
    Adaasi, LDX and 64FF00 like this.

Share This Page

Advertisement