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

Set Plugin as Disabled on Server Start

Comments in 'Plugin Development' started by Tethered_, Jul 6, 2015.

  1. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    How can I set a plugin so that it won't be enabled until I enable it via another plugin? (instead of the plugin automatically loading when the server starts)
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    You could disable it when the server trigger the funtion plugin onEnable. Like this:
    PHP:
    public function onEnable()
    {
        
    $this->getServer()->getPluginManager()->disablePlugin($this);
    }
  3. Tethered_
    Offline

    Tethered_ Active Member Plugin Developer

    Joined:
    Jun 24, 2014
    Posts:
    178
    Plugins:
    2
    Minecraft User:
    Frostbyte58
    But I would need to be able to enable it from another plugin...
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    If you want to enable it from another plugin just:
    You are going to need some kind of control variable because the plugin is going to auto disable himself
    PHP:
    $plugin $this->getServer()->getPluginManager()->getPlugin($name);
    if(
    $plugin instanceof PluginClass)
    {
        
    $this->getServer()->getPluginManager()->enablePlugin($plugin);
    }
    Tethered_ likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Add the "depend" attribute in plugin.yml:

    Code:
     
    depend: [PluginToLoadBefore]

Share This Page

Advertisement