From 1aba7624a1cf002c0cbb4a19ef59fe8f986028e0 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Mon, 17 Dec 2018 19:22:04 +0300 Subject: [PATCH] Commands fixes. --- .../command/hash/DownloadClientCommand.java | 1 + .../command/modules/LoadModuleCommand.java | 2 +- .../launcher/modules/SimpleModuleManager.java | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java index ec7376aa..2ddd708e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/hash/DownloadClientCommand.java @@ -59,6 +59,7 @@ public void invoke(String... args) throws IOException, CommandException { } client.setTitle(dirName); client.block.getEntry("dir", StringConfigEntry.class).setValue(dirName); + client.block.getEntry("title", StringConfigEntry.class).setValue(dirName); try (BufferedWriter writer = IOHelper.newWriter(IOHelper.resolveIncremental(server.profilesDir, dirName, "cfg"))) { TextConfigWriter.write(client.block, writer, true); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java index e4f83eeb..1ab8a23a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/modules/LoadModuleCommand.java @@ -25,6 +25,6 @@ public String getUsageDescription() { public void invoke(String... args) throws Exception { verifyArgs(args, 1); URI uri = Paths.get(args[0]).toUri(); - server.modulesManager.loadModule(uri.toURL(), false); + server.modulesManager.loadModuleFull(uri.toURL()); } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java b/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java index a66faa36..afbef9c2 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/modules/SimpleModuleManager.java @@ -105,6 +105,21 @@ public void loadModule(URL jarpath, boolean preload) throws ClassNotFoundExcepti f.close(); } + public void loadModuleFull(URL jarpath) throws ClassNotFoundException, IllegalAccessException, InstantiationException, URISyntaxException, IOException { + JarFile f = new JarFile(Paths.get(jarpath.toURI()).toString()); + Manifest m = f.getManifest(); + String mainclass = m.getMainAttributes().getValue("Main-Class"); + classloader.addURL(jarpath); + Class moduleclass = Class.forName(mainclass, true, classloader); + Module module = (Module) moduleclass.newInstance(); + modules.add(module); + module.preInit(context); + module.init(context); + module.postInit(context); + LogHelper.info("Module %s version: %s loaded", module.getName(), module.getVersion()); + f.close(); + } + @Override public void loadModule(URL jarpath, String classname, boolean preload) throws ClassNotFoundException, IllegalAccessException, InstantiationException {