Bukkit动态引入Jar包
需要把Jar包丢进配置文件夹的lib目录下才行
onEnable()时调用addBukkitLibraries()即可!
public void addBukkitLibraries()
{
try
{
Method method = URLClassLoader.class.getDeclaredMethod("addURL",new Class[] { URL.class });
method.setAccessible(true);
ClassLoader loader = this.getClassLoader();
for (File file : new File(this.getDataFolder(), "lib").listFiles())
{
if (file.getName().endsWith(".jar"))
{
URL url = file.toURI().toURL();
method.invoke(loader, new Object[] { url });
}
}
} catch (Exception e) {
e.printStackTrace();
}
}