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

[NEW API] Making YAML files.

Comments in 'Plugin Development' started by Killman2, Jun 17, 2014.

  1. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Hi everyone. I am in the middle of developing a plugin, and got stuck with making a .yml file where all the data is sent. Notice that I am asking how to do it for NEW API, not the old one. So, how to make a .yml config file with the new API?
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    PHP:
    use pocketmine\utils\Config;

    $conf = new Config("directory/file.yml"Config::YAML, array("swag"=>"yolo"));
    Functions like Config::set etc are the same.
    Killman2 likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Look at CustomRanks.

    Create a folder at the plugin folder called "resources", and then create file config.yml. In onEnable() of the plugin, add this line:
    PHP:
    $this->saveResource("config.yml"false);
    config.yml is not a fixed name.
    thebigsmileXD and Killman2 like this.
  4. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Just so you know, there's a way to load a config file without needing to code it in php. Simply write the config file how you want it to look, then place it in a folder called "resources" in your plugin's folder, and then in onEnable, there's a way to call on the config. Simply write:
    PHP:
    $config $this->getConfig();
    $this->example $config->get("Example");
    Killman2 likes this.
  5. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Thanks :)
  6. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Thanks :)
  7. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Thanks :)

Share This Page

Advertisement