1
0
mirror of https://github.com/lucko/LuckPerms.git synced 2025-08-31 10:01:45 +02:00

Preload dependencies in Docker image

This commit is contained in:
Luck
2022-10-22 00:07:40 +01:00
parent dc22847fa3
commit 5ff9a12a72
6 changed files with 129 additions and 27 deletions

View File

@@ -51,7 +51,8 @@ public class StandaloneLoader implements ShutdownCallback {
public static final Logger LOGGER = LogManager.getLogger(StandaloneLoader.class);
private static final String JAR_NAME = "luckperms-standalone.jarinjar";
private static final String BOOTSTRAP_CLASS = "me.lucko.luckperms.standalone.LPStandaloneBootstrap";
private static final String BOOTSTRAP_PLUGIN_CLASS = "me.lucko.luckperms.standalone.LPStandaloneBootstrap";
private static final String BOOTSTRAP_DEPENDENCY_PRELOADER_CLASS = "me.lucko.luckperms.standalone.StandaloneDependencyPreloader";
private LuckPermsApplication app;
private JarInJarClassLoader loader;
@@ -72,7 +73,19 @@ public class StandaloneLoader implements ShutdownCallback {
// create a jar-in-jar classloader for the standalone plugin, then enable it
// the application is passes to the plugin constructor, to allow it to pass hooks back
this.loader = new JarInJarClassLoader(getClass().getClassLoader(), JAR_NAME);
this.plugin = this.loader.instantiatePlugin(BOOTSTRAP_CLASS, LuckPermsApplication.class, this.app);
// special case for dependency preload command
if (args.length == 1 && args[0].equals("preloadDependencies")) {
try {
Class<?> clazz = this.loader.loadClass(BOOTSTRAP_DEPENDENCY_PRELOADER_CLASS);
clazz.getMethod("main").invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
return;
}
this.plugin = this.loader.instantiatePlugin(BOOTSTRAP_PLUGIN_CLASS, LuckPermsApplication.class, this.app);
this.plugin.onLoad();
this.plugin.onEnable();