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

How to get Plugin code and more...

Comments in 'Plugin Development' started by korado531m7, Dec 10, 2015.

  1. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Hi. I want to use "if enabled 'test' plugin".
    I wrote code, but it didn't work.
    Please tell me.

    PHP:
         if($this->getServer()->getPlugins()->isPluginEnabled("test")){

              
    $this->getLogger()->info("Running");

              }
    Error below

    Fatal error: Call to undefined method pocketmine\Server::getPlugins()
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    PHP:
    if($this->getServer()->getPluginManager()->isPluginEnabled($this->getServer()->getPluginManager()->getPlugin("..."))){
       ...
    }
    PEMapModder and PocketKiller like this.
  3. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Thank you for answering, i tried.
    It work loaded plugin, but it didn't work not load plugin.
    Err:
    [14:05:48] [NOTICE]: RuntimeException: "Argument 1 passed to pocketmine\plugin\PluginManager::isPluginEnabled() must implement interface pocketmine\plugin\Plugin, null given, called in /Users/XXX/Desktop/test/plugins/PluginName/src/Folder/Main.php on line 774 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/plugin/PluginManager" at line 550
  4. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    This means the plugin is not loaded, btw for getPlugin("...") you need to replace "..." with your plugin name
  5. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    I need to more explain, sorry.
    For ex. I make 'mk' plugin, target plugin 'tgp',
    If mk started, detect 'tgp', and if detected, shutdown the server. If not detect, send message "test".
    I want to know these feature code.
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    PHP:
    In the plugin 'mk'
    public function onEnable(){
    $plugin $this->getServer()->getPluginManager()->getPlugin("tgp");
    if(
    $plugin !== null){//plugin is loaded, not necessary enabled
    $this->getServer()->shutdown();
    }else{
    $this->getLogger()->info("test");
    }
    }
  7. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Thank you a lot!

Share This Page

Advertisement