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

[Solved] Update .yml file (PM 1.4, API 1.0.0)

Comments in 'Plugin Development' started by iksaku, Apr 23, 2014.

  1. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Hi everyone!

    Well I'm writing a special plugin and I need to work with configs, but I want them to use YAML because is user-friendly for editing, ok ok, let's see what I want:

    I already discover how to generate a new YAML file using:
    PHP:
    public function __construct(){
            new 
    Config($directory_&_filenameConfig::YAML$messages);
    }
    Also I know how to put content on it, strings, values, arrays, etc. but I wanna know how to UPDATE array, so if I generate a config that says:
    Code:
    ---
    test:
      hi: Hi Coders! I'm iksaku :3
    ...
    and I also wanna put a "bye" property, what's the code I should use to ONLY ADD the "bye" property without erasing the "hi" one?

    Thanks :3
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    12 views... And the half are plugin devs... :(
  3. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    PHP:
    $this->config->set($key,$value);
    $this->config->save();
  4. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    but if I understand what you asking for, you want to update only one value from the $value array, right ?
  5. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Right, I have this values:
    I want to store them into an array inside a config, but IDK how to do that with the new API, I need to get something like this (inside the config):
    EDIT:
    I want to edit only 1 value inside an array, but IDK how to do it, if I use the
    PHP:
    $this->set($key$value);
    it only edit one of the values I set, I can't choose the sub-value :/
  6. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Okey, I get into the code, and I think that now I know how to do it :p
    Thanks @BlinkSun :D

Share This Page

Advertisement