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

[API 1.4] How to call a plugin API from another plugin

Comments in 'Plugin Development' started by blocksandgold, Jun 15, 2014.

  1. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    For example how can a call the simpleauth API (example of code) in 1.4
    ==> bool isPlayerAuthenticated(pocketmine\Player $player)

    With 1.3, i was using a static class Bag_zoneAPI and i was calling it like this : $zone = Bag_zoneAPI::getZoneByAlias($args[0]);

    Is there a better way to do it in 1.4 ?
  2. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    PHP:
    if( isPlayerAuthenticated(pocketmine\Player $player)){ /* do some */
    Last edited: Jun 15, 2014
  3. shoghicp
    Offline

    shoghicp Staff Member PocketMine Team

    Joined:
    Aug 22, 2013
    Posts:
    436
    Plugins:
    14
    Minecraft User:
    shoghicp
    *cringes*

    PHP:
    $simpleAuthObject $this->getServer()->getPluginManager()->getPlugin("SimpleAuth");
    Be sure to check that it is correct and is not disabled. Also, add it to the dependencies if you NEED it, or to soft dependencies, if you CAN use it. That way pocketmine-mp will load it before your plugin
    args and PEMapModder like this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then why can't I getPlugin() myself in my own plugin? While that function will only be called when the plugin is enabled?
  5. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    Thx shoghicp ! you are everywhere ;-)

    into the plugin.yml ?
    Do you have a 1.4 syntax example ?
  6. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
  7. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    xpyctum there is nothing on that plugins because thay don't need any depedencies...
    with bukkit i can add dependencies into the plugin.yml
    something like that ?
    softdepend: [ pluginname ]

    i don't know how to do it with the 1.4 api :/ and where to find a response...
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Code:
    softdepend: [SimpleAuth]
    blocksandgold likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What are you saying...
  11. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    nothing, i brake
  12. blocksandgold
    Offline

    blocksandgold Active Member

    Joined:
    May 7, 2014
    Posts:
    68
    Minecraft User:
    bifag
    thx PEMapModder

    and for dependencies ? (not soft) ?

    Generally, do you have a documentation with all the parameters allowed into plugin.yml ? (i'm looking for aliases too for command too)
  13. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    You can define aliases in plugin.yml with "aliases:"
    Code:
    commands:
      example:
        description: example command
        usage: "Usage: /example"
        aliases: [ex, exa]
    The code above is an example, you can run /example command using /ex or /exa.
    blocksandgold likes this.

Share This Page

Advertisement