From d0e919db19a4425e88f01ea21efac79a353e0ee2 Mon Sep 17 00:00:00 2001 From: Walter Higgins Date: Sat, 28 Feb 2015 17:13:29 +0000 Subject: [PATCH] Update Frequently-Asked-Questions.md --- docs/Frequently-Asked-Questions.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/Frequently-Asked-Questions.md b/docs/Frequently-Asked-Questions.md index a375308..792143a 100644 --- a/docs/Frequently-Asked-Questions.md +++ b/docs/Frequently-Asked-Questions.md @@ -20,3 +20,27 @@ if (pex.getUser(player).inGroup('moderator') ) { } ``` Generally if you want to use another plugin's API, then get the plugin object by name and then call its methods. In the above example the `pex` variable refers to the aforementioned `PermissionsEx` Plugin. Once you have that reference you can call any of the plugin's methods just as you would in Java. The tricky part is getting the reference and that's where `server.pluginManager.getPlugin()` comes in. + +To get a reference to and work with another plugin's API using ScriptCraft for CanaryMod the same principle applies. Say you've installed ScriptCraft and the dConomy plugin: + +```javascript +var Canary = Packages.net.canarymod.Canary; +var pluginMgr = Canary.pluginManager(); +var dConomy = pluginMgr.getPlugin('dConomy'); +var dConomyServer = dConomy.modServer; +// from here on in you can access all of the dConomyServer object's calls +// e.g. dConomyServer.newTransaction() +``` + +The only difference between CanaryMod and Bukkit is how you get the plugin reference. In Bukkit it's: + +```javascript +var otherPlugin = server.pluginManager.getPlugin('PLUGIN_NAME_GOES_HERE'); +``` + +whereas in CanaryMod it's: + +```javascript +var Canary = Packages.net.canarymod.Canary; +var otherPlugin = Canary.pluginManager().getPlugin('PLUGIN_NAME_GOES_HERE'); +```