lonelymc
怎么在插件中动态加载jar包,比如spring框架的jar包

天辉胡萝卜
只是单纯依赖的话还是建议考虑用maven-shade-plugin,直接把库打包到最终的jar里面

William_Shi
首先确定这个包是不是Spigot、Paper的完整核心已经自带的
比如gson等是BuildTools自动打包到服务端核心里的,无需再重复打包
当然我指的是一个完整的核心jar,可以随便找一个开服核心看

如果是Spigot无的,可以采用
maven shade
gradle shadow jar

lonelymc
疾风暗影 发表于 2020-8-16 14:43
只是单纯依赖的话还是建议考虑用maven-shade-plugin,直接把库打包到最终的jar里面 ...

我试了一下,把ClassPathXmlApplicationContext("配置文件路径")放在了JavaPlugin的onLoad方法里初始化,
但是:
[org.springframework.context.support.FileSystemXmlApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [wetcland.cn.tst] for bean with name 'tst' defined in file [D:\LonelyLeaveTan\Minecraft server core\Paperspigot-1.16.1\src\config.xml]; nested exception is java.lang.ClassNotFoundException: wetcland.cn.tst
[18:52:37 ERROR]: [org.bukkit.craftbukkit.v1_16_R1.CraftServer] Cannot find class [wetcland.cn.tst] for bean with name 'tst' defined in file [D:\LonelyLeaveTan\Minecraft server core\Paperspigot-1.16.1\src\config.xml]; nested exception is java.lang.ClassNotFoundException: wetcland.cn.tst initializing TCSP v1 (Is it up to date?)

天辉胡萝卜
lonelymc 发表于 2020-8-16 18:58
我试了一下,把ClassPathXmlApplicationContext("配置文件路径")放在了JavaPlugin的onLoad方法里初始化, ...

参考该篇
https://www.spigotmc.org/threads ... o-find-file.419294/

1.15之后的临时解决方案

lonelymc
疾风暗影 发表于 2020-8-17 02:12
参考该篇
https://www.spigotmc.org/threads/when-class-implements-listener-spring-tried-to-find-file ...

Bukkit包里面的 FireWorkEffact和FireWorkEffact.Builder两个类构建烟花效果,但是构建完咋在世界放出来。。。,我在World里面没找到相关的生成方法,只有一个简单的spawnEntity(Location, EntityType)可以生成最简单的烟花

天辉胡萝卜
lonelymc 发表于 2020-8-18 06:44
Bukkit包里面的 FireWorkEffact和FireWorkEffact.Builder两个类构建烟花效果,但是构建完咋在世界放出来 ...
  1. Firework fw = (Firework) world.spawnEntity(loc, EntityType.FIREWORK);
  2. FireworkMeta fwm = fw.getFireworkMeta();
复制代码



剩下的自己看文档

第一页 上一页 下一页 最后一页