diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java index 239857a7..578c7f21 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/StdProtectHandler.java @@ -29,12 +29,12 @@ public void init(LaunchServer server) { @Override public boolean canGetProfile(ClientProfile profile, Client client) { - return !profile.isLimited() || isWhitelisted("launchserver.profile.%s.show", profile, client); + return (client.isAuth && !profile.isLimited()) || isWhitelisted("launchserver.profile.%s.show", profile, client); } @Override public boolean canChangeProfile(ClientProfile profile, Client client) { - return !profile.isLimited() || isWhitelisted("launchserver.profile.%s.enter", profile, client); + return (client.isAuth && !profile.isLimited()) || isWhitelisted("launchserver.profile.%s.enter", profile, client); } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java index d627d3ed..50cf3ba9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java @@ -31,6 +31,9 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar")); { List classPath = new ArrayList<>(5); + if(findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) { + classPath.add("libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar"); + } classPath.add("libraries"); classPath.add("minecraft.jar"); if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index ee46dc8f..e7e21cdf 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -31,7 +31,6 @@ import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse; import pro.gravit.launchserver.socket.response.secure.VerifySecureLevelKeyResponse; import pro.gravit.launchserver.socket.response.update.LauncherResponse; -import pro.gravit.launchserver.socket.response.update.UpdateListResponse; import pro.gravit.launchserver.socket.response.update.UpdateResponse; import pro.gravit.utils.BiHookSet; import pro.gravit.utils.HookSet; @@ -74,7 +73,6 @@ public static void registerResponses() { providers.register("joinServer", JoinServerResponse.class); providers.register("profiles", ProfilesResponse.class); providers.register("launcher", LauncherResponse.class); - providers.register("updateList", UpdateListResponse.class); providers.register("setProfile", SetProfileResponse.class); providers.register("update", UpdateResponse.class); providers.register("batchProfileByUsername", BatchProfileByUsername.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateListResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateListResponse.java deleted file mode 100644 index 5d3d7d67..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/update/UpdateListResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package pro.gravit.launchserver.socket.response.update; - -import io.netty.channel.ChannelHandlerContext; -import pro.gravit.launcher.base.events.request.UpdateListRequestEvent; -import pro.gravit.launchserver.socket.Client; -import pro.gravit.launchserver.socket.response.SimpleResponse; - -import java.util.HashSet; - -public class UpdateListResponse extends SimpleResponse { - - @Override - public String getType() { - return "updateList"; - } - - @Override - public void execute(ChannelHandlerContext ctx, Client client) { - if (!client.isAuth) { - sendError("Access denied"); - return; - } - HashSet set = server.updatesManager.getUpdatesList(); - sendResult(new UpdateListRequestEvent(set)); - } - -} diff --git a/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg b/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg index 2f89b1a5..2cf2ad89 100644 --- a/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg +++ b/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/proguard.cfg @@ -16,7 +16,7 @@ -keeppackagenames com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.runtime.api.**, pro.gravit.launcher.base.api.**, pro.gravit.launcher.client.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.** --keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.**, pro.gravit.launcher.runtime.LauncherEngineWrapper { +-keep class com.mojang.**,net.minecraftforge.fml.**,cpw.mods.fml.**,com.google.gson.**,pro.gravit.repackage.**,org.fusesource.**, pro.gravit.launcher.client.api.**, pro.gravit.launcher.base.api.**, pro.gravit.utils.**, pro.gravit.launcher.base.request.**, pro.gravit.launcher.base.events.**, pro.gravit.launcher.base.profiles.**, pro.gravit.launcher.runtime.LauncherEngineWrapper { *; } diff --git a/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java index 9f8b3293..4928f57c 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java @@ -147,7 +147,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) { processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString())); } else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) { - systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(workDir, params.actions, params.profile) + systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(new HashSet<>(), workDir, params.actions, params.profile) .filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString())) .map(Path::toString) .toList()); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/events/request/UpdateListRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/events/request/UpdateListRequestEvent.java deleted file mode 100644 index ba5962dc..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/events/request/UpdateListRequestEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -package pro.gravit.launcher.base.events.request; - -import pro.gravit.launcher.core.LauncherNetworkAPI; -import pro.gravit.launcher.base.events.RequestEvent; - -import java.util.HashSet; -import java.util.UUID; - - -public class UpdateListRequestEvent extends RequestEvent { - @SuppressWarnings("unused") - private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b"); - @LauncherNetworkAPI - public final HashSet dirs; - - public UpdateListRequestEvent(HashSet dirs) { - this.dirs = dirs; - } - - @Override - public String getType() { - return "updateList"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/auth/password/AuthCodePassword.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/auth/password/AuthCodePassword.java index 5b3c6e03..4d123b53 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/auth/password/AuthCodePassword.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/auth/password/AuthCodePassword.java @@ -3,10 +3,10 @@ import pro.gravit.launcher.base.request.auth.AuthRequest; public class AuthCodePassword implements AuthRequest.AuthPasswordInterface { - public final String code; + public final String uri; - public AuthCodePassword(String code) { - this.code = code; + public AuthCodePassword(String uri) { + this.uri = uri; } @Override diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/update/UpdateListRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/update/UpdateListRequest.java deleted file mode 100644 index 1406e132..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/update/UpdateListRequest.java +++ /dev/null @@ -1,13 +0,0 @@ -package pro.gravit.launcher.base.request.update; - -import pro.gravit.launcher.base.events.request.UpdateListRequestEvent; -import pro.gravit.launcher.base.request.Request; -import pro.gravit.launcher.base.request.websockets.WebSocketRequest; - -public final class UpdateListRequest extends Request implements WebSocketRequest { - - @Override - public String getType() { - return "updateList"; - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java index 11fd7493..a3e3a345 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java @@ -94,7 +94,6 @@ public void registerResults() { results.register("batchProfileByUsername", BatchProfileByUsernameRequestEvent.class); results.register("profiles", ProfilesRequestEvent.class); results.register("setProfile", SetProfileRequestEvent.class); - results.register("updateList", UpdateListRequestEvent.class); results.register("error", ErrorRequestEvent.class); results.register("update", UpdateRequestEvent.class); results.register("getAvailabilityAuth", GetAvailabilityAuthRequestEvent.class); diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 6c83934e..eb476436 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -118,7 +118,8 @@ private static void realMain(String[] args) throws Throwable { // Verify ClientLauncher sign and classpath LogHelper.debug("Verifying ClientLauncher sign and classpath"); - List classpath = resolveClassPath(clientDir, params.actions, params.profile) + Set ignoredPath = new HashSet<>(); + List classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile) .filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString())) .collect(Collectors.toCollection(ArrayList::new)); if(LogHelper.isDevEnabled()) { @@ -252,11 +253,11 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, } } - private static LinkedList resolveClassPathList(Path clientDir, String... classPath) throws IOException { - return resolveClassPathStream(clientDir, classPath).collect(Collectors.toCollection(LinkedList::new)); + private static LinkedList resolveClassPathList(Set ignorePaths, Path clientDir, String... classPath) throws IOException { + return resolveClassPathStream(ignorePaths, clientDir, classPath).collect(Collectors.toCollection(LinkedList::new)); } - private static Stream resolveClassPathStream(Path clientDir, String... classPath) throws IOException { + private static Stream resolveClassPathStream(Set ignorePaths, Path clientDir, String... classPath) throws IOException { Stream.Builder builder = Stream.builder(); for (String classPathEntry : classPath) { Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR))); @@ -265,20 +266,28 @@ private static Stream resolveClassPathStream(Path clientDir, String... cla IOHelper.walk(path, new ClassPathFileVisitor(jars), false); Collections.sort(jars); for(var e : jars) { + if(ignorePaths.contains(e)) { + continue; + } builder.accept(e); + ignorePaths.add(e); } continue; } + if(ignorePaths.contains(path)) { + continue; + } builder.accept(path); + ignorePaths.add(path); } return builder.build(); } - public static Stream resolveClassPath(Path clientDir, Set actions, ClientProfile profile) throws IOException { - Stream result = resolveClassPathStream(clientDir, profile.getClassPath()); + public static Stream resolveClassPath(Set ignorePaths, Path clientDir, Set actions, ClientProfile profile) throws IOException { + Stream result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath()); for (OptionalAction a : actions) { if (a instanceof OptionalActionClassPath) - result = Stream.concat(result, resolveClassPathStream(clientDir, ((OptionalActionClassPath) a).args)); + result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args)); } return result; } @@ -340,8 +349,9 @@ private ClassPathFileVisitor(List result) { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) + if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) { result.add(file); + } return super.visitFile(file, attrs); } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index 5da954a4..ee50e0c1 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -6,7 +6,7 @@ public final class Version implements Comparable { public static final int MAJOR = 5; public static final int MINOR = 6; - public static final int PATCH = 0; + public static final int PATCH = 1; public static final int BUILD = 1; public static final Version.Type RELEASE = Type.STABLE; public final int major; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index a286c248..f11f3567 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -258,6 +258,14 @@ public static ArgsParseResult parseJavaArgs(List args) { return new ArgsParseResult(conf, classpath, jvmArgs, mainClass, mainModule, jarFile, args); } + public static V multimapFirstOrNullValue(K key, Map> params) { + List list = params.getOrDefault(key, Collections.emptyList()); + if (list.isEmpty()) { + return null; + } + return list.getFirst(); + } + public record ArgsParseResult(LaunchOptions.ModuleConf conf, List classpath, List jvmArgs, String mainClass, String mainModule, String jarFile, List args) { } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java index e73cec59..77285591 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java @@ -93,6 +93,7 @@ public synchronized static List findJava() { trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Java")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("AdoptOpenJDK")); trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Eclipse Foundation")); //AdoptJDK rebranding + trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("Eclipse Adoptium")); //AdoptJDK rebranding trySearchJava(javaPaths, result, rootDrive.resolve("Program Files").resolve("BellSoft")); // LibericaJDK } catch (IOException e) { LogHelper.error(e); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/QueryHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/QueryHelper.java new file mode 100644 index 00000000..e34b06d4 --- /dev/null +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/QueryHelper.java @@ -0,0 +1,29 @@ +package pro.gravit.utils.helper; + +import java.net.URI; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class QueryHelper { + public static Map> splitUriQuery(URI uri) { + var query = uri.getRawQuery(); + if (query == null) { + return Collections.emptyMap(); + } + Map> params = new HashMap<>(); + String[] split = query.split("&"); + for (String qParams : split) { + String[] splitParams = qParams.split("="); + List strings = params.computeIfAbsent(URLDecoder.decode(splitParams[0], StandardCharsets.UTF_8), + k -> new ArrayList<>(1)); + strings.add(URLDecoder.decode(splitParams[1], StandardCharsets.UTF_8)); + } + return params; + } + + public static String encodeFormPair(String key, String value) { + return URLEncoder.encode(key, StandardCharsets.UTF_8) + "=" + URLEncoder.encode(value, StandardCharsets.UTF_8); + } +} diff --git a/build.gradle b/build.gradle index b4b18f09..3e0cff99 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.1.0' apply false } group = 'pro.gravit.launcher' -version = '5.6.0' +version = '5.6.1' apply from: 'props.gradle' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd491..e6441136 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2ea3535d..e7646dea 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/modules b/modules index e93620f1..dba18b58 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit e93620f10963b951c8874dfef17dce91cf8c8da9 +Subproject commit dba18b58312a92e465ad17d78ea3504a8b3c1818