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

How to get a setting from another plugin

Discussion in 'Plugin Help' started by Znightmare123, Oct 28, 2020.

  1. Znightmare123

    Znightmare123 Spider Jockey

    Messages:
    25
    Hi! If you would be so kind to answer me this question, how can I get a result of a pre-defined config, from another plugin? as if a function is activated or not and how to customize it
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    This is confusing, bet lets say that You want to gain read & write access to another's plugin config file.
    PHP:
    1. $other PluginManager::getPlugin(string $name);
    2.
     2.1
    $config $other->getConfig() : Config// if second plugin is using default config's name (config.yml)
     
    2.2$config = new Config($other->getDataFolder() . "custom_name.yml"); (if it's saved in other than ^)
    Note: read the file in correct format. Refer to documentation for more details.

    P.S. You get PluginManager instance from Server class/object (it's singleton)
    example in context of PluginBase: $this->getServer()->getPluginManager()


    as for that: make sure that the other plugin has actually done fiddling with the config. You might actually face an issue if holding two different instances of Config objects that points to same file, that is they could store different values in runtime.
     
  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.