ScriptCraft

ScriptCraft

14.6k Downloads

[Question] How do you access the methods from another plugin

lukecfairchild opened this issue ยท 9 comments

commented

Say you have the FE economy plugin and want to access its api, how would you go about this?

I was trying to access the getAccounts function in FE's api, I have already tried:

org.melonbrew.fe.APi.getAccounts()


var fe = new org.melonbrew.fe.API();
fe.getAccounts();


Ive also tried many combinations using the importPackage and JavaImporter with no success. So any help you could provide would be really appreciated.

FYI: I've also been trying to access stuff from another plugin called commandhelper, no success from either.

commented

It's been a while since I've done plugin devving, but IIRC, you need to get the plugin via the PluginManager, and then (according to the Fe plugin), get the API.

commented

org.bukkit.Bukkit.getPluginManager().getPlugin( 'FE' );

I was messing with this earlier but never got it working

commented

I think the plugin names are case-sensitive. The Fe plugin identifies itself as Fe.

commented

o sorry i had it right in my code but not here.

commented

Instead of doing the whole org.bukkit.Bukkit dance, try doing server.getPluginManager().getPlugin(), since there's always the possibility you're not running Bukkit.

And of course, if that still doesn't work, tell us what error you're getting in here. (be sure to wrap it in ```s.)

commented

well i think im getting the plugin but at that point what am i suppost to do now?

commented

Well, you wanted to get to the API and use the call, right?
I mentioned before that if you want to use the plugin's API, you have to call getAPI() on the plugin, and then do whatever you wanted to do with it (e.g. getAccounts()).

commented

\o/
Now just how to use this with commandhelper too..
Thank you for your help!

commented

No problem; be sure to close the issue.