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

Solved How i can link my plugin with any plugin?

Discussion in 'Development' started by KHAV, Jan 16, 2018.

  1. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    Hello

    How i can link any plugin with my plugin?, where i can use its codes in my plugin, if i can how? I tried but it is not working!

    i hope you understand me:)
     
  2. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    I think I understand what you mean, if the methods are static you can:
    PHP:
    use namespace/to/class;
    If they aren't static:
    PHP:
    $plugin $this->getServer()->getPluginManager()->getPlugin('MyPlugin');
    $plugin->whatever(...$args);
    EDIT: For both code snippets the methods you are trying to call MUST be public.
     
  3. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    can you explain more?:)

    like give me example on pocketmine plugin please:)
     
  4. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    First of all, the functions of the other plugin you want to link and use must be a public function.
    There are 3 types of functions: public, private, protected.

    public - All classes can use it
    private - Only owning class can use it
    protected - Owning class plus all extending classes can use it

    Let us start an example with EconomyAPI by onebone.

    Pocketmine's plugin manager let's you access other plugin's main class.
    PHP:
    $economyAPI Server::getInstance()->getPluginManager()->getPlugin('EconomyAPI');
    This will return the main class of EconomyAPI if the plugin is installed on the server

    You can make it so your plugin won't load without EconomyAPI by adding " depend: ['EconomyAPI'] " to plugin.yml

    Hope this helps :D
    Explained !
     
  5. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    thank you!
     
  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.