Compare commits

...

22 commits

Author SHA1 Message Date
Antoni
c3aca15738
Merge 0e1691ee4c into 911ca1e69f 2025-05-05 14:09:43 +03:00
Gravita
911ca1e69f [FIX] Duplicate classpath and modulepath entities 2025-05-04 22:03:28 +07:00
Gravita
90f74aaf25 [FEATURE] Build ServerWrapper inline jar 2025-05-04 21:54:51 +07:00
Gravita
880957fa9b [FEATURE] Support inline initialization in DebugMain 2025-05-04 21:18:03 +07:00
Gravita
2fea94071b [FEATURE] Support runCompatClasses in ServerWrapperInlineInitializer 2025-05-04 21:12:57 +07:00
Gravita
b41e8db336 [FEATURE] Add ServerWrapperInlineInitializer 2025-05-04 19:38:34 +07:00
Gravita
76570ddbe5 [FEATURE] Support directories in classpath in ServerWrapper 2025-05-04 19:02:46 +07:00
Gravita
3a160b8124 Merge tag 'v5.6.14' into dev
5.6.14 stable
2025-05-04 17:58:08 +07:00
Gravita
8fb1dc275c Merge branch 'release/5.6.14' 2025-05-04 17:57:55 +07:00
Gravita
95aed151e7 [ANY] 5.6.14 2025-05-04 17:57:46 +07:00
Gravita
6934c37a33 [FIX] Wrong if in clientType 2025-05-04 05:35:35 +07:00
Gravita
5155c470c6 Merge tag 'v5.6.13' into dev
5.6.13 stable release
2025-05-03 23:59:13 +07:00
Gravita
533dcfce14 Merge branch 'release/5.6.13' 2025-05-03 23:58:58 +07:00
Gravita
d2f83d81eb [ANY] 5.6.13 stable 2025-05-03 23:58:41 +07:00
Gravita
2379398c30 [ANY] Update gradle to 8.14 2025-05-03 23:26:34 +07:00
Gravita
f53c48a5ae [ANY] Update gradle 2025-05-03 23:24:30 +07:00
Gravita
394b64e22d Merge tag 'v5.6.12' into dev
5.6.12 stable release
2025-05-03 23:11:55 +07:00
Gravita
7c15742478 Merge branch 'release/5.6.12' 2025-05-03 23:11:40 +07:00
Gravita
d65fffade9 [ANY] 5.6.12 release 2025-05-03 23:11:33 +07:00
Gravita
bb6c95ca12 [FEATURE] Support multiple lwjgl3 versions 2025-05-03 22:43:06 +07:00
Gravita
9027987b29 [FEATURE] Support multiple client types 2025-05-03 22:31:04 +07:00
microwin7
0e1691ee4c
Add Discord Widget 2023-05-19 22:40:26 +03:00
14 changed files with 135 additions and 63 deletions

View file

@ -39,6 +39,7 @@ jobs:
cp LaunchServer.jar ../../../artifacts/LaunchServer.jar
cd ../../..
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 modules/*_module/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 projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
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 disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh");
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
@ -37,6 +38,14 @@ public class DebugMain {
public static void main(String[] args) throws Throwable {
LogHelper.printVersion("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);
LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
LogHelper.debug("Initialization LauncherConfig");
@ -56,7 +65,9 @@ public static void main(String[] args) throws Throwable {
}
LauncherEngine.modulesManager.initModules(null);
LauncherEngine.initGson(LauncherEngine.modulesManager);
if(!disableConsole) {
ConsoleManager.initConsole();
}
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
RequestService service;
if (offlineMode) {
@ -72,10 +83,6 @@ public static void main(String[] args) throws Throwable {
if(!disableAutoRefresh) {
Request.startAutoRefresh();
}
LogHelper.debug("Initialization LauncherEngine");
LauncherEngine instance = LauncherEngine.newInstance(false, ClientRuntimeProvider.class);
instance.start(args);
LauncherEngine.exitLauncher(0);
}
@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
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
RequestService service;
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());
}
}
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(JVMHelper.JVM_VERSION <= 11) {
launch = new LegacyLaunch();
@ -274,10 +277,12 @@ 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 {
Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath());
if(actions != null) {
for (OptionalAction a : actions) {
if (a instanceof OptionalActionClassPath)
result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args));
}
}
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 MINOR = 6;
public static final int PATCH = 11;
public static final int PATCH = 14;
public static final int BUILD = 1;
public static final Version.Type RELEASE = Type.STABLE;
public final int major;

View file

@ -1,4 +1,6 @@
# Modification of the launcher sashok724's v3 from Gravit [![Build Status](https://travis-ci.com/GravitLauncher/Launcher.svg?branch=master)](https://travis-ci.com/GravitLauncher/Launcher)
# Modification of the launcher sashok724's v3 from Gravit
[![Build Status](https://travis-ci.com/GravitLauncher/Launcher.svg?branch=master)](https://travis-ci.com/GravitLauncher/Launcher)
[![Join our Discord](https://img.shields.io/discord/853340557522370561.svg?logo=discord&label=)](https://discord.gg/b9QG4ygY75)
* [Discord channel](https://discord.gg/b9QG4ygY75)

View file

@ -48,6 +48,21 @@ pack project(':LauncherAPI')
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 {
publications {
serverwrapperapi(MavenPublication) {
@ -94,4 +109,4 @@ pack project(':LauncherAPI')
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 java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ServerWrapper extends JsonConfigurable<ServerWrapper.Config> {
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();
AuthRequest.registerProviders();
GetAvailabilityAuthRequest.registerProviders();
OptionalAction.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");
loadConfig();
public void connect() throws Exception {
config.applyEnv();
updateLauncherConfig();
Launcher.applyLauncherEnv(Objects.requireNonNullElse(config.env, LauncherConfig.LauncherEnvironment.STD));
StdWebSocketService service = StdWebSocketService.initWebSockets(config.address).get();
service.reconnectCallback = () ->
{
@ -136,11 +128,6 @@ public void run(String... args) throws Throwable {
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);
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) {
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;
if (classname.isEmpty()) {
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);
} else real_args = args;
Launch launch;
ClientService.nativePath = config.nativesDir;
ConfigService.serverName = config.serverName;
if(config.loadNatives != null) {
for(String e : config.loadNatives) {
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();
options.enableHacks = config.enableHacks;
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()) {
ClientService.instrumentation = ServerAgent.inst;
}
ClientService.classLoaderControl = classLoaderControl;
ClientService.baseURLs = classLoaderControl.getURLs();
if(config.configServiceSettings != null) {
config.configServiceSettings.apply();
}
LogHelper.info("Start Minecraft Server");
try {
if(config.compatClasses != null) {
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);
}
}
runCompatClasses();
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args));
} catch (Throwable e) {

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
}
group = 'pro.gravit.launcher'
version = '5.6.11'
version = '5.6.14'
apply from: 'props.gradle'
@ -71,10 +71,6 @@
repositories {
maven {
url = version.endsWith('SNAPSHOT') ? getProperty('mavenSnapshotRepository') : getProperty('mavenReleaseRepository')
credentials {
username getProperty('mavenUsername')
password getProperty('mavenPassword')
}
}
}
}

Binary file not shown.

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

2
gradlew vendored
View file

@ -205,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

@ -1 +1 @@
Subproject commit 03804a3a0e638f05c9ce65c01dbdb2f6c9ae630c
Subproject commit a2c3ccecadb7f864039b88e6269583c4b77fba13