0

I need to call a function from the IC2 (mod) API from within my bukkit plugin.

How would i go about importing the IC2 API into the plugin so i can call the function?

To give you an idea as to why i would want to do this;

Below is a piece of javascript that does exactly what i need. But this script runs off a plugin called ScriptCraft which lets you make plugins with javascript. I want this script to be implemented into it's own plugin with java so i don't need ScriptCraft.

cl = __plugin.getClass().getClassLoader().getParent();
ic2 = cl.loadClass("ic2.core.IC2").newInstance();
net = ic2.network;
dmm = cl.loadClass("net.minecraftforge.common.DimensionManager").newInstance();
worlds = dmm.getWorlds();

for(var wid in worlds){
    var te = worlds[wid].field_73009_h;
    for (var ti=0;ti<te.size();ti++){
        if(te.get(ti).getFacing!=undefined){
            net.updateTileEntityField(te.get(ti),"facing")
        }
    }
}

I can see what it is doing and how. I just don't know how to be able to run IC2's updateTileEntityField() in a bukkit plugin.

edit: I have started to convert it to java, but i didn't get far before running into a problem.

NetworkManager ic2 = new ic2.core.IC2().network;
DimensionManager dmm = new net.minecraftforge.common.DimensionManager();
?? worlds = dmm.getWorlds(); //What Data Type?

The problem is in the last line. getWorlds() asks for a in[] data type, which eclipse says does not exist.

Mattigins
  • 1,014
  • 9
  • 25

2 Answers2

0

You need to add the .jar API to your Java Build Path in eclipse.

Then you should be able to create a new instance and call the method you wish to call.

aman207
  • 1,068
  • 2
  • 11
  • 19
0

if you know the name of the plugin, You can get the permissionsEx (or any other plugin) like this...

var pex = server.pluginManager.getPlugin('PermissionsEx');

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. Hope this helps.

Walter

walter
  • 184
  • 1
  • 4