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

Another config question... :P

Comments in 'Plugin Development' started by minebuilder0110, Nov 19, 2015.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Right, I almost got how to use info from the config, but now I am stuck on how to make the plugin to create a new 'section' (I don't know what the word is to describe it :p) with custom name. Because this makes absolutely no sense, this is what I am talking about.
    Code:
    ---
    playername:
      worldname: 9
    anotherplayer:
      worldname: 20
    ...
    So I know how to retrieve them, but I can't figure out how to make plugin to create a new 'section' named after a player name and a world name. ($this->yml->setNested("$name.$world", $health); is the method I use) I have noticed that EconomyAPI have managed to do this, but the code is just too much for me.
    Just in case you need some info for this plugin, it is a plugin to set a players' health per world. I might release it here.
    Last edited: Nov 19, 2015
  2. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    If $this->yml is your config:
    $this->yml->setNested($name . '.' . $world, $health);
  3. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Uh... I guess this is kinda bumping, but it didn't create another section for me :(
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    after Config::setNested() you must save it Config::save().

Share This Page

Advertisement