Merge branch 'release/5.6.15'

This commit is contained in:
Gravita 2025-05-25 12:28:59 +07:00
commit c76aae76a5
9 changed files with 131 additions and 56 deletions

View file

@ -35,10 +35,12 @@ jobs:
run: | run: |
mkdir -p artifacts/modules mkdir -p artifacts/modules
cd LaunchServer/build/libs cd LaunchServer/build/libs
mv proguard proguard-libraries
zip -r -9 ../../../artifacts/libraries.zip * -x "LaunchServer.jar" -x "LaunchServer-clean.jar" zip -r -9 ../../../artifacts/libraries.zip * -x "LaunchServer.jar" -x "LaunchServer-clean.jar"
cp LaunchServer.jar ../../../artifacts/LaunchServer.jar cp LaunchServer.jar ../../../artifacts/LaunchServer.jar
cd ../../.. cd ../../..
cp ServerWrapper/build/libs/ServerWrapper.jar artifacts/ServerWrapper.jar cp ServerWrapper/build/libs/ServerWrapper.jar artifacts/ServerWrapper.jar
cp ServerWrapper/build/libs/ServerWrapper-inline.jar artifacts/ServerWrapperInline.jar
cp LauncherAuthlib/build/libs/LauncherAuthlib.jar artifacts/LauncherAuthlib.jar || true cp LauncherAuthlib/build/libs/LauncherAuthlib.jar artifacts/LauncherAuthlib.jar || true
cp modules/*_module/build/libs/*.jar artifacts/modules || true cp modules/*_module/build/libs/*.jar artifacts/modules || true
cp modules/*_lmodule/build/libs/*.jar artifacts/modules || true cp modules/*_lmodule/build/libs/*.jar artifacts/modules || true

View file

@ -28,6 +28,7 @@ public class DebugMain {
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api"); public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft"); public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", ""); public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
public static boolean disableConsole = Boolean.getBoolean("launcherdebug.disableConsole");
public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode"); public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode");
public static boolean disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh"); public static boolean disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh");
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(","); public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
@ -37,6 +38,14 @@ public class DebugMain {
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
LogHelper.printVersion("Launcher"); LogHelper.printVersion("Launcher");
LogHelper.printLicense("Launcher"); LogHelper.printLicense("Launcher");
initialize();
LogHelper.debug("Initialization LauncherEngine");
LauncherEngine instance = LauncherEngine.newInstance(false, ClientRuntimeProvider.class);
instance.start(args);
LauncherEngine.exitLauncher(0);
}
public static void initialize() throws Exception {
IS_DEBUG.set(true); IS_DEBUG.set(true);
LogHelper.info("Launcher start in DEBUG mode (Only for developers)"); LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
LogHelper.debug("Initialization LauncherConfig"); LogHelper.debug("Initialization LauncherConfig");
@ -56,7 +65,9 @@ public static void main(String[] args) throws Throwable {
} }
LauncherEngine.modulesManager.initModules(null); LauncherEngine.modulesManager.initModules(null);
LauncherEngine.initGson(LauncherEngine.modulesManager); LauncherEngine.initGson(LauncherEngine.modulesManager);
ConsoleManager.initConsole(); if(!disableConsole) {
ConsoleManager.initConsole();
}
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase()); LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
RequestService service; RequestService service;
if (offlineMode) { if (offlineMode) {
@ -72,10 +83,6 @@ public static void main(String[] args) throws Throwable {
if(!disableAutoRefresh) { if(!disableAutoRefresh) {
Request.startAutoRefresh(); Request.startAutoRefresh();
} }
LogHelper.debug("Initialization LauncherEngine");
LauncherEngine instance = LauncherEngine.newInstance(false, ClientRuntimeProvider.class);
instance.start(args);
LauncherEngine.exitLauncher(0);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -0,0 +1,7 @@
package pro.gravit.launcher.runtime.debug;
public class DebugMainInlineInitializer {
public static void run() throws Exception {
DebugMain.initialize();
}
}

View file

@ -116,15 +116,6 @@ private static void realMain(String[] args) throws Throwable {
// Verify ClientLauncher sign and classpath // Verify ClientLauncher sign and classpath
LogHelper.debug("Verifying ClientLauncher sign and classpath"); LogHelper.debug("Verifying ClientLauncher sign and classpath");
Set<Path> ignoredPath = new HashSet<>();
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
.collect(Collectors.toCollection(ArrayList::new));
if(LogHelper.isDevEnabled()) {
for(var e : classpath) {
LogHelper.dev("Classpath entry %s", e);
}
}
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).toList();
// Start client with WatchService monitoring // Start client with WatchService monitoring
RequestService service; RequestService service;
if (params.offlineMode) { if (params.offlineMode) {
@ -158,6 +149,18 @@ private static void realMain(String[] args) throws Throwable {
System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString()); System.load(Paths.get(params.nativesDir).resolve(ClientService.findLibrary(e)).toAbsolutePath().toString());
} }
} }
Set<Path> ignoredPath = new HashSet<>();
if(options.moduleConf != null && options.moduleConf.modulePath != null) {
List<Path> resolvedModulePath = resolveClassPath(ignoredPath, clientDir, null, params.profile).toList();
}
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
.collect(Collectors.toCollection(ArrayList::new));
if(LogHelper.isDevEnabled()) {
for(var e : classpath) {
LogHelper.dev("Classpath entry %s", e);
}
}
List<URL> classpathURLs = classpath.stream().map(IOHelper::toURL).toList();
if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER || classLoaderConfig == ClientProfile.ClassLoaderConfig.MODULE) { if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER || classLoaderConfig == ClientProfile.ClassLoaderConfig.MODULE) {
if(JVMHelper.JVM_VERSION <= 11) { if(JVMHelper.JVM_VERSION <= 11) {
launch = new LegacyLaunch(); launch = new LegacyLaunch();
@ -274,9 +277,11 @@ private static Stream<Path> resolveClassPathStream(Set<Path> ignorePaths, Path c
public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException { public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath()); Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath());
for (OptionalAction a : actions) { if(actions != null) {
if (a instanceof OptionalActionClassPath) for (OptionalAction a : actions) {
result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args)); if (a instanceof OptionalActionClassPath)
result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args));
}
} }
return result; return result;
} }

View file

@ -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 = 14; public static final int PATCH = 15;
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;

View file

@ -48,6 +48,21 @@ pack project(':LauncherAPI')
exclude 'module-info.class' exclude 'module-info.class'
} }
tasks.register('inlinejar', Jar) {
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.filter {! (it.name =~ /gson.*\.jar/ || it.name =~ /error_prone_annotations.*\.jar/)}.collect { it.isDirectory() ? it : zipTree(it) }
}
from {
sourceSets.main.output
}
archiveClassifier.set('inline')
manifest.attributes("Main-Class": mainClassName,
"Automatic-Module-Name": "ServerWrapper"
)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
publishing { publishing {
publications { publications {
serverwrapperapi(MavenPublication) { serverwrapperapi(MavenPublication) {
@ -94,4 +109,4 @@ pack project(':LauncherAPI')
sign publishing.publications.serverwrapperapi sign publishing.publications.serverwrapperapi
} }
assemble.dependsOn tasks.shadowJar assemble.dependsOn tasks.shadowJar, tasks.inlinejar

View file

@ -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");
loadConfig();
ServerWrapperSetup setup = new ServerWrapperSetup();
setup.run();
System.exit(0);
}
if (args.length > 1 && args[0].equalsIgnoreCase("installAuthlib") && !disableSetup) {
LogHelper.debug("Read ServerWrapperConfig.json");
loadConfig();
InstallAuthlib command = new InstallAuthlib();
command. run(args[1]);
System.exit(0);
}
LogHelper.debug("Read ServerWrapperConfig.json"); LogHelper.debug("Read ServerWrapperConfig.json");
loadConfig(); loadConfig();
}
public void connect() throws Exception {
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,47 @@ 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;
if(config.configServiceSettings != null) {
config.configServiceSettings.apply();
}
}
public void runCompatClasses() throws Throwable {
if(config.compatClasses != null) {
for (String e : config.compatClasses) {
Class<?> clazz = classLoaderControl == null ? Class.forName(e) : classLoaderControl.getClass(e);
MethodHandle runMethod = MethodHandles.lookup().findStatic(clazz, "run", MethodType.methodType(void.class, ClassLoaderControl.class));
runMethod.invoke(classLoaderControl);
}
}
}
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 +210,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,24 +235,27 @@ 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;
} }
ClientService.classLoaderControl = classLoaderControl; ClientService.classLoaderControl = classLoaderControl;
ClientService.baseURLs = classLoaderControl.getURLs(); ClientService.baseURLs = classLoaderControl.getURLs();
if(config.configServiceSettings != null) {
config.configServiceSettings.apply();
}
LogHelper.info("Start Minecraft Server"); LogHelper.info("Start Minecraft Server");
try { try {
if(config.compatClasses != null) { runCompatClasses();
for (String e : config.compatClasses) {
Class<?> clazz = classLoaderControl.getClass(e);
MethodHandle runMethod = MethodHandles.lookup().findStatic(clazz, "run", MethodType.methodType(void.class, ClassLoaderControl.class));
runMethod.invoke(classLoaderControl);
}
}
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName()); LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args)); launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args));
} catch (Throwable e) { } catch (Throwable e) {
@ -253,12 +282,12 @@ public void setConfig(Config config) {
@Override @Override
public Config getDefaultConfig() { public Config getDefaultConfig() {
Config newConfig = new Config(); Config newConfig = new Config();
newConfig.serverName = "your server name"; newConfig.serverName = "";
newConfig.mainclass = ""; newConfig.mainclass = "";
newConfig.extendedTokens = new HashMap<>(); newConfig.extendedTokens = new HashMap<>();
newConfig.args = new ArrayList<>(); newConfig.args = new ArrayList<>();
newConfig.classpath = new ArrayList<>(); newConfig.classpath = new ArrayList<>();
newConfig.address = "ws://localhost:9274/api"; newConfig.address = "";
newConfig.classLoaderConfig = ClientProfile.ClassLoaderConfig.SYSTEM_ARGS; newConfig.classLoaderConfig = ClientProfile.ClassLoaderConfig.SYSTEM_ARGS;
newConfig.env = LauncherConfig.LauncherEnvironment.STD; newConfig.env = LauncherConfig.LauncherEnvironment.STD;
newConfig.properties = new HashMap<>(); newConfig.properties = new HashMap<>();

View file

@ -0,0 +1,10 @@
package pro.gravit.launcher.server;
public class ServerWrapperInlineInitializer {
public static void run() throws Throwable {
ServerWrapper.wrapper = new ServerWrapper(ServerWrapper.Config.class, ServerWrapper.configFile);
ServerWrapper.wrapper.initialize();
ServerWrapper.wrapper.connect();
ServerWrapper.wrapper.runCompatClasses();
}
}

View file

@ -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.14' version = '5.6.15'
apply from: 'props.gradle' apply from: 'props.gradle'