mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-01 22:14:01 +03:00
Direct main class
This commit is contained in:
parent
74449c194c
commit
ac4086856b
1 changed files with 4 additions and 7 deletions
|
@ -43,33 +43,30 @@ public void invoke(String... args) throws Exception {
|
|||
String jarName = this.wrapper.commandHandler.readLine();
|
||||
Path jarPath = Paths.get(jarName);
|
||||
|
||||
String mainClassName;
|
||||
String agentClassName;
|
||||
|
||||
try (JarFile file = new JarFile(jarPath.toFile())) {
|
||||
LogHelper.info("Check server jar MainClass");
|
||||
mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class");
|
||||
this.wrapper.config.mainclass = file.getManifest().getMainAttributes().getValue("Main-Class");
|
||||
agentClassName = file.getManifest().getMainAttributes().getValue("Premain-Class");
|
||||
|
||||
if (mainClassName == null) {
|
||||
if (this.wrapper.config.mainclass == null) {
|
||||
LogHelper.error("Main-Class not found in MANIFEST");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName(mainClassName, false, new PublicURLClassLoader(new URL[] { jarPath.toUri().toURL() }));
|
||||
Class.forName(this.wrapper.config.mainclass, false, new PublicURLClassLoader(new URL[] { jarPath.toUri().toURL() }));
|
||||
} catch (ClassNotFoundException e) {
|
||||
LogHelper.error(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.info("Found MainClass %s", mainClassName);
|
||||
LogHelper.info("Found MainClass %s", this.wrapper.config.mainclass);
|
||||
if (agentClassName != null)
|
||||
LogHelper.info("Found PremainClass %s", agentClassName);
|
||||
|
||||
this.wrapper.config.mainclass = mainClassName;
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if(!Request.isAvailable() || Request.getRequestService().isClosed()) {
|
||||
LogHelper.info("Print websocket address (ws://host:port/api):");
|
||||
|
|
Loading…
Reference in a new issue