1.18.2 Run Spigot from other jar

Discussion in 'Spigot Plugin Development' started by Ya_Mo_TAT, Dec 7, 2021.

Thread Status:
Not open for further replies.
  1. 我的 boot.jar 包含一些库
    使用jar-loader加载spigot-1.18.jar文件,然后反射调用spigot-1.18.jar的main-class中的main方法

    在 1.18 之前,一切正常,spigot 插件能够访问 boot.jar 库,
    1.18以后好像是因为classloader的变化导致spigot插件找不到boot.jar的库类(抛出ClassNotFoundException)

    我该怎么办?

    好吧编辑页面自动翻译为中文呢了,,懒得再改回去了,解决办法1楼或者override classloader

    jar-loader: https://github.com/CGJennings/jar-loader/blob/main/src/ca/cgjennings/jvm/JarLoader.java
     
    #1 Ya_Mo_TAT, Dec 7, 2021
    Last edited: Dec 14, 2021
  2. Stop using a hacky solution and make use of an actual supported solution: Use bukkit's dependency api that got introduced already in 1.16.2.

    If your dependencies are not on maven central, just add your library jar files to the classpath or module-path.
     
    #2 Jannyboy11, Dec 7, 2021
    Last edited: Dec 7, 2021
    • Agree Agree x 1
    • Informative Informative x 1
Thread Status:
Not open for further replies.