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

Get variable from another plugin

Comments in 'Plugin Development' started by TonyDroidd, Apr 23, 2015.

  1. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    How i can get $variable from an plugin (plugin 1) to another plugin (plugin 2)??
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Variables are local. You can't even get it from your own plugin if the function has ended.

    You can save the variables to fields, and create getters for them. Then call the getter function from another plugin using Server->getPluginManager()->getPlugin()
    EvolSoft and Falk like this.
  3. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    well?

    PHP:
    Server->getPluginManager()->getPlugin("PluginName")
  4. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I think this should work.
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("PluginName");
    Last edited by a moderator: Apr 24, 2015
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Only in the case that you are in a PluginBase's context.
    RekkuzaRage and TonyDroidd like this.
  6. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Oh I am still learning the API. I just need a good reference for the API...
    TonyDroidd likes this.

Share This Page

Advertisement