iTXTech / SynapsePM

Synapse client for PocketMine like server software. Supports multiple connections.
21 stars 17 forks source link

How can I find the description of the current server? #29

Closed Henning-Klatt closed 7 years ago

Henning-Klatt commented 7 years ago

I have a second plugin next to SynapsePM, which works with mysqli and that should know how the current server (on which it runs) description is. Whats the best way to do this?

SleepSpace9 commented 7 years ago

You could try this (untested):

if($synapsepm = $this->getServer()->getPluginManager()->getPlugin('SynapsePM') !== null) {
    $descriptionFromConfig = $synapsepm->getConfig()->get('description');
    $descriptionFromMethod = $synapsepm->getSynapse()->getDescription();
}
Henning-Klatt commented 7 years ago

Thank you, on method from Config it will return this error: Elywing thread:CRITICAL > Error: "Call to a member function getConfig() on boolean" (EXCEPTION) in "/plugins/SlaveServer/src/SlaveServer/Main" at line 135

on method fromMethod i have this error: Elywing thread:CRITICAL > Error: "Call to a member function getSynapse() on boolean" (EXCEPTION) in "/plugins/SlaveServer/src/SlaveServer/Main" at line 136

But when i look at the config file, the description is in an array like format?!?

bildschirmfoto 2016-12-29 um 12 11 46

Henning-Klatt commented 7 years ago

I found a solution: You must set $synapsepm again, after the if: if($synapsepm = $this->getServer()->getPluginManager()->getPlugin("SynapsePM") !== null) { $synapsepm = $this->getServer()->getPluginManager()->getPlugin("SynapsePM"); $this->description = $synapsepm->getSynapse()->getDescription(); }