diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 70d9dd2a..7e963040 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -60,6 +60,8 @@ public final class ClientProfile implements Comparable { @LauncherNetworkAPI private List compatClasses; @LauncherNetworkAPI + private List loadNatives; + @LauncherNetworkAPI private Map properties; @LauncherNetworkAPI private List servers; @@ -253,6 +255,10 @@ public ProfileDefaultSettings getSettings() { return settings; } + public List getLoadNatives() { + return loadNatives; + } + public void updateOptionalGraph() { for (OptionalFile file : updateOptional) { if (file.dependenciesFile != null) { diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 81069f83..167a542e 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -142,6 +142,12 @@ private static void realMain(String[] args) throws Throwable { LaunchOptions options = new LaunchOptions(); options.enableHacks = profile.hasFlag(ClientProfile.CompatibilityFlags.ENABLE_HACKS); options.moduleConf = profile.getModuleConf(); + ClientService.nativePath = params.nativesDir; + if(profile.getLoadNatives() != null) { + for(String e : profile.getLoadNatives()) { + System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString()); + } + } if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER) { if(JVMHelper.JVM_VERSION <= 11) { launch = new LegacyLaunch(); @@ -151,7 +157,6 @@ private static void realMain(String[] args) throws Throwable { classLoaderControl = launch.init(classpath, params.nativesDir, options); System.setProperty("java.class.path", classpath.stream().map(Path::toString).collect(Collectors.joining(File.pathSeparator))); modulesManager.invokeEvent(new ClientProcessClassLoaderEvent(launch, classLoaderControl, profile)); - ClientService.nativePath = params.nativesDir; ClientService.baseURLs = classLoaderControl.getURLs(); } else if (classLoaderConfig == ClientProfile.ClassLoaderConfig.AGENT) { launch = new BasicLaunch(LauncherAgent.inst); @@ -161,14 +166,12 @@ private static void realMain(String[] args) throws Throwable { LauncherAgent.addJVMClassPath(Paths.get(url.toURI())); } ClientService.instrumentation = LauncherAgent.inst; - ClientService.nativePath = params.nativesDir; modulesManager.invokeEvent(new ClientProcessClassLoaderEvent(launch, null, profile)); ClientService.baseURLs = classpathURLs.toArray(new URL[0]); } else if (classLoaderConfig == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) { launch = new BasicLaunch(); classLoaderControl = launch.init(classpath, params.nativesDir, options); ClientService.baseURLs = classpathURLs.toArray(new URL[0]); - ClientService.nativePath = params.nativesDir; } if(profile.hasFlag(ClientProfile.CompatibilityFlags.CLASS_CONTROL_API)) { ClientService.classLoaderControl = classLoaderControl; diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 03466718..42e85eec 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -184,6 +184,13 @@ public void run(String... args) throws Throwable { System.arraycopy(args, 1, real_args, 0, args.length - 1); } else real_args = args; Launch launch; + ClientService.nativePath = config.nativesDir; + ConfigService.serverName = config.serverName; + if(config.loadNatives != null) { + for(String e : config.loadNatives) { + System.load(Paths.get(config.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString()); + } + } switch (config.classLoaderConfig) { case LAUNCHER: launch = new LegacyLaunch(); @@ -210,8 +217,6 @@ public void run(String... args) throws Throwable { } ClientService.classLoaderControl = classLoaderControl; ClientService.baseURLs = classLoaderControl.getURLs(); - ClientService.nativePath = config.nativesDir; - ConfigService.serverName = config.serverName; if(config.configServiceSettings != null) { config.configServiceSettings.apply(); } @@ -277,6 +282,7 @@ public static final class Config { public String nativesDir = "natives"; public List args; public List compatClasses; + public List loadNatives; public String authId; public AuthRequestEvent.OAuthRequestEvent oauth; public long oauthExpireTime;