So, can i use PHP: Server::getInstance()->getPluginManager()->getPlugin("Core")->getDataFolder() . "config.yml", Config::YAML); ?
Oh..There are two ways to choose. One is that if you know or you can see the code of that plugin, open it and see which is the config variable. You can use getPlugin(PluginName)->"That variable" to get. Another is a stupid method... PHP: $this->cfg=new Config("plugins/Another Plugin's FolderName/"."config.yml",Config::YAML,array()); Then you can manage it.
wtf? the path plugins/ is not valid in ANY system. (and even if, why do you expect plugins to be at the root?) What are you doing? Please note that you are specifying a real file path here. you should use the server object to get the server plugin path.
seeing as the plugin's config is names "config.yml", this should work: PHP: Server::getInstance()->getPluginManager()->getPlugin("Core")->getConfig();
$this->getServer () ->getDataPath (); It refers to the root files PHP: $cfg = new Config($this->getServer()->getDataPath()."/plugins/PluginName/config.yml", Config::YAML);
just a little tweak PHP: public $cfg; public function checkConfig() { if($this->getServer()->getPluginManager()->getPlugin("PluginName")->isEnabled()) { $this->cfg = new Config($this->getServer()->getDataPath()."plugins/PluginName/config.yml", Config::YAML); } else { $this->getLogger()->warning("plugin was not found."); } }
If the plugin doesn't exist you cannot call isEnabled on it. And if you are already using the plugin manager why not just do: PHP: public function getDefaultConfigFrom(string $pluginName){ if($plugin = $this->getServer()->getPluginManager()->getPlugin("PluginName") instanceof PluginBase) { return $plugin->getConfig(); } $this->getLogger()->warning("Plugin '".$pluginName."' was not found."); #Assuming this function is in your PluginBase } public function getConfigFrom(string $pluginName, string $configNamePath){ if($plugin = $this->getServer()->getPluginManager()->getPlugin("PluginName") instanceof PluginBase){ if(file_exists($plugin->getDataPath().$configNamePath)){ return new Config($plugin->getDataPath().$configNamePath, Config::DETECT); } } $this->getLogger()->warning("Plugin '".$pluginName."' was not found."); #Assuming this function is in your PluginBase } [/QUOTE]
also UNLESS you know the plugin well, dont assume they uses Plugins/PluginName/config.yml some developers like to use: /plugins/config/pluginName.yml But if you are very certain of the behavior you probably can get away with it even tho i am starting to get offtopic, mind telling us why? sometimes most decent plugins offer APIs to make getting it's config last resort (and i am assuming you own the other Core plugin so why not just add APIs there?)