From e5478930b42768ee3db80ad5178c6855c275c2a2 Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 23 Oct 2018 20:14:14 +0700 Subject: [PATCH] =?UTF-8?q?=D0=AD=D0=BA=D1=81=D0=BF=D0=B5=D1=80=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20launchLocal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/client/ClientLauncher.java | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 1cc236e2..aa1ae67f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -370,10 +370,6 @@ else if(isDownloadJava) } // Add classpath and main class String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); - StringBuilder classPathString = new StringBuilder(pathLauncher); - LinkedList classPath = resolveClassPathList(params.clientDir, profile.object.getClassPath()); - for (Path path : classPath) - classPathString.append(File.pathSeparatorChar).append(path.toString()); Collections.addAll(args, profile.object.getJvmArgs()); Collections.addAll(args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path Collections.addAll(args, "-javaagent:".concat(pathLauncher)); @@ -453,6 +449,46 @@ public static void main(String... args) throws Throwable { URL[] classpathurls = resolveClassPath(params.clientDir, profile.object.getClassPath()); classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader()); Thread.currentThread().setContextClassLoader(classLoader); + classLoader.nativePath = params.clientDir.resolve(NATIVES_DIR).toString(); + PublicURLClassLoader.systemclassloader = classLoader; + // Start client with WatchService monitoring + boolean digest = !profile.object.isUpdateFastCheck(); + LogHelper.debug("Starting JVM and client WatchService"); + FileNameMatcher assetMatcher = profile.object.getAssetUpdateMatcher(); + FileNameMatcher clientMatcher = profile.object.getClientUpdateMatcher(); + try (DirWatcher assetWatcher = new DirWatcher(params.assetDir, assetHDir.object, assetMatcher, digest); + DirWatcher clientWatcher = new DirWatcher(params.clientDir, clientHDir.object, clientMatcher, digest)) { + // Verify current state of all dirs + //verifyHDir(IOHelper.JVM_DIR, jvmHDir.object, null, digest); + HashedDir hdir = clientHDir.object; + for(ClientProfile.MarkedString s : Launcher.profile.getOptional()) + { + if(params.updateOptional.contains(s)) s.mark = true; + else hdir.removeR(s.string); + } + verifyHDir(params.assetDir, assetHDir.object, assetMatcher, digest); + verifyHDir(params.clientDir, hdir, clientMatcher, digest); + Launcher.modulesManager.postInitModules(); + // Start WatchService, and only then client + CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start(); + CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start(); + launch(profile.object, params); + } + } + @LauncherAPI + public void launchLocal(SignedObjectHolder assetHDir, SignedObjectHolder clientHDir, + SignedObjectHolder profile, Params params) throws Throwable { + RSAPublicKey publicKey = Launcher.getConfig().publicKey; + LogHelper.debug("Verifying ClientLauncher sign and classpath"); + SecurityHelper.verifySign(LauncherRequest.BINARY_PATH, params.launcherSign, publicKey); + LinkedList classPath = resolveClassPathList(params.clientDir, profile.object.getClassPath()); + for (Path classpathURL : classPath) { + LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString()); + } + URL[] classpathurls = resolveClassPath(params.clientDir, profile.object.getClassPath()); + classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader()); + Thread.currentThread().setContextClassLoader(classLoader); + classLoader.nativePath = params.clientDir.resolve(NATIVES_DIR).toString(); PublicURLClassLoader.systemclassloader = classLoader; // Start client with WatchService monitoring boolean digest = !profile.object.isUpdateFastCheck();