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

change something in config using code

Comments in 'Plugin Development' started by amiremad, May 10, 2016.

  1. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    how to make my plugin change something in config

    like

    happy : true

    using code to change happy to false
  2. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    i want the code from the plugin code it self to change something in the config
  3. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    PHP:
    $this->getConfig()->set("happy"true); // Set the value happy to true
    $this->getConfig()->save(); // Saves the config
    Survingo likes this.
  4. _Neisufek_
    Offline

    _Neisufek_ New Member

    Joined:
    Apr 17, 2016
    Posts:
    16
    Minecraft User:
    xNaisu
    You
    PHP:
    public function addCfgIndexVal($offset$val$config_file){
    $conf = new Config($config_fileConfig::YAML, []);
    $conf->getAll()[$offset] = $val;//setter
    $conf->setAll($conf->getAll());
    $conf->save();
    }
    //How to use:
    $class->addCfgIndexVal ("happy", (bool) true$base->getDataPath()."config.yml");

    //with array
    $class->addCfgIndexVal ("people", ["Bob""Ron"], $base->getDataPath()."config.yml");
    Last edited: May 10, 2016
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Why that useless function?
  6. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yep, thats the right way

    [QUOT="__, post: 162049, membe: 4684"YouPHP]
    pub
  7. _Neisufek_
    Offline

    _Neisufek_ New Member

    Joined:
    Apr 17, 2016
    Posts:
    16
    Minecraft User:
    xNaisu
    Why this "useless" reply?

    If you don't know the meaning of "useless" then don't use the word -_-
    ImagicalGamer likes this.

Share This Page

Advertisement