mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-07-07 08:19:45 +03:00
Compare commits
5 commits
6934c37a33
...
b41e8db336
Author | SHA1 | Date | |
---|---|---|---|
|
b41e8db336 | ||
|
76570ddbe5 | ||
|
3a160b8124 | ||
|
8fb1dc275c | ||
|
95aed151e7 |
4 changed files with 60 additions and 30 deletions
|
@ -6,7 +6,7 @@ public final class Version implements Comparable<Version> {
|
||||||
|
|
||||||
public static final int MAJOR = 5;
|
public static final int MAJOR = 5;
|
||||||
public static final int MINOR = 6;
|
public static final int MINOR = 6;
|
||||||
public static final int PATCH = 13;
|
public static final int PATCH = 14;
|
||||||
public static final int BUILD = 1;
|
public static final int BUILD = 1;
|
||||||
public static final Version.Type RELEASE = Type.STABLE;
|
public static final Version.Type RELEASE = Type.STABLE;
|
||||||
public final int major;
|
public final int major;
|
||||||
|
|
|
@ -25,15 +25,18 @@
|
||||||
import pro.gravit.utils.launch.*;
|
import pro.gravit.utils.launch.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ServerWrapper extends JsonConfigurable<ServerWrapper.Config> {
|
public class ServerWrapper extends JsonConfigurable<ServerWrapper.Config> {
|
||||||
public static final Path configFile = Paths.get(System.getProperty("serverwrapper.configFile", "ServerWrapperConfig.json"));
|
public static final Path configFile = Paths.get(System.getProperty("serverwrapper.configFile", "ServerWrapperConfig.json"));
|
||||||
|
@ -100,31 +103,20 @@ public void getProfiles() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String... args) throws Throwable {
|
|
||||||
|
public void initialize() throws Exception {
|
||||||
initGson();
|
initGson();
|
||||||
AuthRequest.registerProviders();
|
AuthRequest.registerProviders();
|
||||||
GetAvailabilityAuthRequest.registerProviders();
|
GetAvailabilityAuthRequest.registerProviders();
|
||||||
OptionalAction.registerProviders();
|
OptionalAction.registerProviders();
|
||||||
OptionalTrigger.registerProviders();
|
OptionalTrigger.registerProviders();
|
||||||
if (args.length > 0 && args[0].equalsIgnoreCase("setup") && !disableSetup) {
|
|
||||||
LogHelper.debug("Read ServerWrapperConfig.json");
|
LogHelper.debug("Read ServerWrapperConfig.json");
|
||||||
loadConfig();
|
loadConfig();
|
||||||
ServerWrapperSetup setup = new ServerWrapperSetup();
|
|
||||||
setup.run();
|
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
if (args.length > 1 && args[0].equalsIgnoreCase("installAuthlib") && !disableSetup) {
|
|
||||||
LogHelper.debug("Read ServerWrapperConfig.json");
|
public void connect() throws Exception {
|
||||||
loadConfig();
|
|
||||||
InstallAuthlib command = new InstallAuthlib();
|
|
||||||
command. run(args[1]);
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
LogHelper.debug("Read ServerWrapperConfig.json");
|
|
||||||
loadConfig();
|
|
||||||
config.applyEnv();
|
config.applyEnv();
|
||||||
updateLauncherConfig();
|
updateLauncherConfig();
|
||||||
Launcher.applyLauncherEnv(Objects.requireNonNullElse(config.env, LauncherConfig.LauncherEnvironment.STD));
|
|
||||||
StdWebSocketService service = StdWebSocketService.initWebSockets(config.address).get();
|
StdWebSocketService service = StdWebSocketService.initWebSockets(config.address).get();
|
||||||
service.reconnectCallback = () ->
|
service.reconnectCallback = () ->
|
||||||
{
|
{
|
||||||
|
@ -136,11 +128,6 @@ public void run(String... args) throws Throwable {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(config.properties != null) {
|
|
||||||
for(Map.Entry<String, String> e : config.properties.entrySet()) {
|
|
||||||
System.setProperty(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Request.setRequestService(service);
|
Request.setRequestService(service);
|
||||||
if (config.logFile != null) LogHelper.addOutput(IOHelper.newWriter(Paths.get(config.logFile), true));
|
if (config.logFile != null) LogHelper.addOutput(IOHelper.newWriter(Paths.get(config.logFile), true));
|
||||||
{
|
{
|
||||||
|
@ -153,6 +140,34 @@ public void run(String... args) throws Throwable {
|
||||||
if(config.encodedServerEcPublicKey != null) {
|
if(config.encodedServerEcPublicKey != null) {
|
||||||
KeyService.serverEcPublicKey = SecurityHelper.toPublicECDSAKey(config.encodedServerEcPublicKey);
|
KeyService.serverEcPublicKey = SecurityHelper.toPublicECDSAKey(config.encodedServerEcPublicKey);
|
||||||
}
|
}
|
||||||
|
ClientService.nativePath = config.nativesDir;
|
||||||
|
ConfigService.serverName = config.serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(String... args) throws Throwable {
|
||||||
|
initialize();
|
||||||
|
if (args.length > 0 && args[0].equalsIgnoreCase("setup") && !disableSetup) {
|
||||||
|
ServerWrapperSetup setup = new ServerWrapperSetup();
|
||||||
|
setup.run();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
if (args.length > 1 && args[0].equalsIgnoreCase("installAuthlib") && !disableSetup) {
|
||||||
|
InstallAuthlib command = new InstallAuthlib();
|
||||||
|
command. run(args[1]);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
connect();
|
||||||
|
if(config.properties != null) {
|
||||||
|
for(Map.Entry<String, String> e : config.properties.entrySet()) {
|
||||||
|
System.setProperty(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(config.encodedServerRsaPublicKey != null) {
|
||||||
|
KeyService.serverRsaPublicKey = SecurityHelper.toPublicRSAKey(config.encodedServerRsaPublicKey);
|
||||||
|
}
|
||||||
|
if(config.encodedServerEcPublicKey != null) {
|
||||||
|
KeyService.serverEcPublicKey = SecurityHelper.toPublicECDSAKey(config.encodedServerEcPublicKey);
|
||||||
|
}
|
||||||
String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass;
|
String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass;
|
||||||
if (classname.isEmpty()) {
|
if (classname.isEmpty()) {
|
||||||
LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.json or first commandline argument");
|
LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.json or first commandline argument");
|
||||||
|
@ -182,8 +197,6 @@ public void run(String... args) throws Throwable {
|
||||||
System.arraycopy(args, 1, real_args, 0, args.length - 1);
|
System.arraycopy(args, 1, real_args, 0, args.length - 1);
|
||||||
} else real_args = args;
|
} else real_args = args;
|
||||||
Launch launch;
|
Launch launch;
|
||||||
ClientService.nativePath = config.nativesDir;
|
|
||||||
ConfigService.serverName = config.serverName;
|
|
||||||
if(config.loadNatives != null) {
|
if(config.loadNatives != null) {
|
||||||
for(String e : config.loadNatives) {
|
for(String e : config.loadNatives) {
|
||||||
System.load(Paths.get(config.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString());
|
System.load(Paths.get(config.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString());
|
||||||
|
@ -209,7 +222,19 @@ public void run(String... args) throws Throwable {
|
||||||
LaunchOptions options = new LaunchOptions();
|
LaunchOptions options = new LaunchOptions();
|
||||||
options.enableHacks = config.enableHacks;
|
options.enableHacks = config.enableHacks;
|
||||||
options.moduleConf = config.moduleConf;
|
options.moduleConf = config.moduleConf;
|
||||||
classLoaderControl = launch.init(config.classpath.stream().map(Paths::get).collect(Collectors.toCollection(ArrayList::new)), config.nativesDir, options);
|
classLoaderControl = launch.init(config.classpath.stream()
|
||||||
|
.map(Paths::get)
|
||||||
|
.flatMap(p -> {
|
||||||
|
if(!Files.isDirectory(p)) {
|
||||||
|
return Stream.of(p);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Files.walk(p).filter(e -> e.getFileName().toString().endsWith(".jar"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(Collectors.toCollection(ArrayList::new)), config.nativesDir, options);
|
||||||
if(ServerAgent.isAgentStarted()) {
|
if(ServerAgent.isAgentStarted()) {
|
||||||
ClientService.instrumentation = ServerAgent.inst;
|
ClientService.instrumentation = ServerAgent.inst;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package pro.gravit.launcher.server;
|
||||||
|
|
||||||
|
public class ServerWrapperInlineInitializer {
|
||||||
|
public static void initialize() throws Exception {
|
||||||
|
ServerWrapper.wrapper = new ServerWrapper(ServerWrapper.Config.class, ServerWrapper.configFile);
|
||||||
|
ServerWrapper.wrapper.initialize();
|
||||||
|
ServerWrapper.wrapper.connect();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
||||||
}
|
}
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.6.13'
|
version = '5.6.14'
|
||||||
|
|
||||||
apply from: 'props.gradle'
|
apply from: 'props.gradle'
|
||||||
|
|
||||||
|
@ -71,10 +71,6 @@
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = version.endsWith('SNAPSHOT') ? getProperty('mavenSnapshotRepository') : getProperty('mavenReleaseRepository')
|
url = version.endsWith('SNAPSHOT') ? getProperty('mavenSnapshotRepository') : getProperty('mavenReleaseRepository')
|
||||||
credentials {
|
|
||||||
username getProperty('mavenUsername')
|
|
||||||
password getProperty('mavenPassword')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue