1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to get a spezific config

Discussion in 'Development' started by TestDevelopment, Feb 23, 2021.

  1. TestDevelopment

    TestDevelopment Spider Jockey

    Messages:
    41
    GitHub:
    non
    I want to get an Config by file name, is this possible?
     
  2. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    I think you can get the plugin instance from PluginManager then call getConfig() on the plugin instance if that's what you want, not sure how would you get it by it's name tho
     
  3. TestDevelopment

    TestDevelopment Spider Jockey

    Messages:
    41
    GitHub:
    non
    no when you have multiple datas as config in your plugin and want to get one spezific
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    This may be outdated or not recommended but it's the only way I currently can think of.

    PHP:
    @mkdir($this->getDataFolder());
    $this->saveResource("config.yml");
    $this->coin = new Config($this->getDataFolder() . "config.yml"Config::YAML); 

    // now you can use $this->coin to call this db
     
  5. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    1. mkdir() isn't needed here
    2. you can use saveDefaultConfig() instead if you want to save the config, otherwise use saveResource() for other files
    3. if you want to get your config instance, just use getConfig(), if you have other yml or json files create a new Config instance ig
    (btw i assumed they wanted to get the config of other plugins lol)
     
    minijaham likes this.
  6. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Ah...yes.
    I’ve see lots of posts regarding mkdir() and other config management but I’ve never really paid attention to them. Thanks!
     
  7. TestDevelopment

    TestDevelopment Spider Jockey

    Messages:
    41
    GitHub:
    non
    Made new Config() not a new config?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.