9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-23 17:09:19 +00:00

修改库类加载器

This commit is contained in:
XiaoMoMi
2025-09-04 01:06:14 +08:00
parent 65baf247ed
commit c2973e904c
2 changed files with 16 additions and 7 deletions

View File

@@ -39,12 +39,21 @@ public class PaperCraftEngineBootstrap implements PluginBootstrap {
} catch (ReflectiveOperationException e) { } catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to getLogger", e); throw new RuntimeException("Failed to getLogger", e);
} }
this.plugin = new BukkitCraftEngine( try {
logger, this.plugin = new BukkitCraftEngine(
context.getDataDirectory(), logger,
new BukkitClassPathAppender(), context.getDataDirectory(),
new PaperPluginClassPathAppender(this.getClass().getClassLoader()) new BukkitClassPathAppender(),
); new PaperPluginClassPathAppender(this.getClass().getClassLoader())
);
} catch (UnsupportedOperationException e) {
this.plugin = new BukkitCraftEngine(
logger,
context.getDataDirectory(),
new PaperPluginClassPathAppender(this.getClass().getClassLoader()),
new PaperPluginClassPathAppender(this.getClass().getClassLoader())
);
}
this.plugin.applyDependencies(); this.plugin.applyDependencies();
this.plugin.setUpConfig(); this.plugin.setUpConfig();
if (isDatapackDiscoveryAvailable()) { if (isDatapackDiscoveryAvailable()) {

View File

@@ -21,7 +21,7 @@ public class BukkitClassPathAppender implements ClassPathAppender {
if (bukkitClassLoader.getClass().getName().equals("space.vectrix.ignite.launch.ember.EmberClassLoader") && bukkitClassLoader.getParent() instanceof URLClassLoader urlClassLoader) { if (bukkitClassLoader.getClass().getName().equals("space.vectrix.ignite.launch.ember.EmberClassLoader") && bukkitClassLoader.getParent() instanceof URLClassLoader urlClassLoader) {
this.libraryClassLoaderAccess = URLClassLoaderAccess.create(urlClassLoader); this.libraryClassLoaderAccess = URLClassLoaderAccess.create(urlClassLoader);
} else { } else {
this.libraryClassLoaderAccess = null; throw new UnsupportedOperationException("Unsupported classloader " + bukkitClassLoader.getClass());
} }
} }
} }