简体   繁体   English

Bukkit插件调用IC2功能

[英]Bukkit Plugin Call IC2 Function

I need to call a function from the IC2 (mod) API from within my bukkit plugin. 我需要从bukkit插件中的IC2(mod)API调用一个函数。

How would i go about importing the IC2 API into the plugin so i can call the function? 如何将IC2 API导入插件,以便可以调用该函数?

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. 下面是一段javascript,正是我需要的。 But this script runs off a plugin called ScriptCraft which lets you make plugins with javascript. 但是,此脚本运行的是一个名为ScriptCraft的插件,可让您使用javascript制作插件。 I want this script to be implemented into it's own plugin with java so i don't need ScriptCraft. 我想用Java将这个脚本实现到它自己的插件中,所以我不需要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. 我只是不知道如何在bukkit插件中运行IC2的updateTileEntityField()。

edit: I have started to convert it to java, but i didn't get far before running into a problem. 编辑:我已经开始将其转换为Java,但是在遇到问题之前我走的不远。

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. getWorlds()要求输入in []数据类型,eclipse认为该数据类型不存在。

You need to add the .jar API to your Java Build Path in eclipse. 您需要在eclipse中将.jar API添加到Java Build Path中。

Then you should be able to create a new instance and call the method you wish to call. 然后,您应该能够创建一个新实例并调用您想要调用的方法。

if you know the name of the plugin, You can get the permissionsEx (or any other plugin) like this... 如果您知道插件的名称,则可以像下面这样获取PermissionsEx(或任何其他插件)...

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. 通常,如果要使用另一个插件的API,请按名称获取插件对象,然后调用其方法。 Hope this helps. 希望这可以帮助。

Walter 沃尔特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM