diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index d7cd9bb7..2f5d8bcb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -50,7 +50,7 @@ public final class LaunchServerConfig { public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) { LaunchServerConfig newConfig = new LaunchServerConfig(); - newConfig.mirrors = new String[]{"https://mirror.gravit.pro/", "https://gravit-launcher-mirror.storage.googleapis.com/"}; + newConfig.mirrors = new String[]{"https://mirror.gravit.pro/5.2.x/", "https://gravit-launcher-mirror.storage.googleapis.com/"}; newConfig.launch4j = new LaunchServerConfig.ExeConf(); newConfig.launch4j.enabled = true; newConfig.launch4j.copyright = "© GravitLauncher Team"; @@ -169,6 +169,18 @@ public void verify() { if (netty == null) { throw new NullPointerException("Netty must not be null"); } + // Mirror check + { + boolean updateMirror = Boolean.getBoolean("launchserver.config.disableUpdateMirror"); + if(!updateMirror) { + for(int i=0;i < mirrors.length;++i) { + if("https://mirror.gravit.pro/".equals(mirrors[i])) { + logger.warn("Replace mirror 'https://mirror.gravit.pro/' to 'https://mirror.gravit.pro/5.2.x/'. If you really need to use original url, use '-Dlaunchserver.config.disableUpdateMirror=true'"); + mirrors[i] = "https://mirror.gravit.pro/5.2.x/"; + } + } + } + } } public void init(LaunchServer.ReloadType type) { 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 4bee8597..405f93be 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java @@ -97,6 +97,17 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti optionalOther.triggersList = List.of(nonMacTrigger); optionals.add(optionalOther); } + Optional logFile = findOption(options, MakeProfileOptionLog4j.class); + if(logFile.isPresent()) { + var log4jOption = logFile.get(); + if(log4jOption.logFile != null) { + jvmArgs.add("-Dlog4j.configurationFile=".concat(logFile.get().logFile)); + } else if(log4jOption.affected) { + if(version.compareTo(ClientProfile.Version.MC117) >= 0 && version.compareTo(ClientProfile.Version.MC118) < 0) { + jvmArgs.add("-Dlog4j2.formatMsgNoLookups=true"); + } + } + } if (version.compareTo(ClientProfile.Version.MC117) >= 0) { builder.setMinJavaVersion(16); builder.setRecommendJavaVersion(16); @@ -156,18 +167,52 @@ public static String getMainClassByVersion(ClientProfile.Version version, MakePr return "net.minecraft.client.main.Main"; } + private static boolean isAffectedLog4jVersion(String version) { + if(version == null) { + return true; + } + String[] split = version.split("\\."); + if(split.length < 2) return true; + if(!split[0].equals("2")) return false; + return Integer.parseInt(split[1]) < 15; + } + + private static String getLog4jVersion(Path dir) throws IOException { + Path log4jCore = dir.resolve("org/apache/logging/log4j/log4j-core"); + if(Files.exists(log4jCore)) { + Path target = Files.list(log4jCore).findFirst().orElse(null); + if(target != null) { + return target.getFileName().toString(); + } + } + return null; + } + public static MakeProfileOption[] getMakeProfileOptionsFromDir(Path dir, ClientProfile.Version version) throws IOException { List options = new ArrayList<>(2); - if (version.compareTo(ClientProfile.Version.MC1122) <= 0) { - if (Files.exists(dir.resolve("forge.jar"))) { + if (Files.exists(dir.resolve("forge.jar"))) { + options.add(new MakeProfileOptionForge()); + } + else if (Files.exists(dir.resolve("libraries/net/minecraftforge/forge"))) { + if(version.compareTo(ClientProfile.Version.MC1122) > 0) { + options.add(new MakeProfileOptionForge(dir)); + } else { options.add(new MakeProfileOptionForge()); } - } else { - if (Files.exists(dir.resolve("libraries/net/minecraftforge/forge"))) { - options.add(new MakeProfileOptionForge(dir)); - } - if (Files.exists(dir.resolve("libraries/net/fabricmc/fabric-loader"))) { - options.add(new MakeProfileOptionFabric(dir)); + } + if (Files.exists(dir.resolve("libraries/net/fabricmc/fabric-loader"))) { + options.add(new MakeProfileOptionFabric(dir)); + } + { + String log4jVersion = getLog4jVersion(dir); + if(log4jVersion != null) { + + boolean affected = isAffectedLog4jVersion(log4jVersion); + if(Files.exists(dir.resolve("log4j2_custom.xml"))) { + options.add(new MakeProfileOptionLog4j(affected, "log4j2_custom.xml")); + } else { + options.add(new MakeProfileOptionLog4j(affected, null)); + } } } if (Files.exists(dir.resolve("liteloader.jar"))) { @@ -176,7 +221,7 @@ public static MakeProfileOption[] getMakeProfileOptionsFromDir(Path dir, ClientP if (Files.exists(dir.resolve("libraries/org/lwjgl/lwjgl/3.2.2")) && Files.exists(dir.resolve("libraries/org/lwjgl/lwjgl/3.2.1"))) { options.add(new MakeProfileOptionLwjgl()); } - if (version.compareTo(ClientProfile.Version.MC1122) <= 0) { + if (Files.exists(dir.resolve("libraries/forge/launchwrapper-1.12-launcherfixed.jar.jar")) || Files.exists(dir.resolve("libraries/net/minecraft/launchwrapper"))) { options.add(new MakeProfileOptionLaunchWrapper()); } return options.toArray(new MakeProfileOption[0]); @@ -193,6 +238,16 @@ private static Path findFirstMavenFile(Path path) throws IOException { public interface MakeProfileOption { } + public static class MakeProfileOptionLog4j implements MakeProfileOption { + public boolean affected; + public String logFile; + + public MakeProfileOptionLog4j(boolean lower15, String logFile) { + this.affected = lower15; + this.logFile = logFile; + } + } + public static class MakeProfileOptionForge implements MakeProfileOption { public String launchTarget; public String forgeVersion; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java index f94dbd85..a33d5755 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/LaunchServerGsonManager.java @@ -33,7 +33,9 @@ public LaunchServerGsonManager(LaunchServerModulesManager modulesManager) { @Override public void registerAdapters(GsonBuilder builder) { super.registerAdapters(builder); - builder.registerTypeAdapterFactory(RecordTypeAdapterFactory.DEFAULT); + builder.registerTypeAdapterFactory(RecordTypeAdapterFactory.builder() + .allowMissingComponentValues() + .create()); builder.registerTypeAdapter(TextureProvider.class, new UniversalJsonAdapter<>(TextureProvider.providers)); builder.registerTypeAdapter(AuthCoreProvider.class, new UniversalJsonAdapter<>(AuthCoreProvider.providers)); builder.registerTypeAdapter(PasswordVerifier.class, new UniversalJsonAdapter<>(PasswordVerifier.providers)); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 8453a7d1..4c645a7b 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -119,7 +119,8 @@ public static void main(String[] args) throws Throwable { // Verify ClientLauncher sign and classpath LogHelper.debug("Verifying ClientLauncher sign and classpath"); - List classpath = resolveClassPath(clientDir, params.actions, params.profile).map(IOHelper::toURL).collect(Collectors.toList()); + List classpath = resolveClassPath(clientDir, params.actions, params.profile).collect(Collectors.toList()); + List classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList()); // Start client with WatchService monitoring boolean digest = !profile.isUpdateFastCheck(); RequestService service; @@ -145,7 +146,8 @@ public static void main(String[] args) throws Throwable { } ClientProfile.ClassLoaderConfig classLoaderConfig = profile.getClassLoaderConfig(); if (classLoaderConfig == ClientProfile.ClassLoaderConfig.LAUNCHER) { - ClientClassLoader classLoader = new ClientClassLoader(classpath.toArray(new URL[0]), ClassLoader.getSystemClassLoader()); + ClientClassLoader classLoader = new ClientClassLoader(classpathURLs.toArray(new URL[0]), ClassLoader.getSystemClassLoader()); + System.setProperty("java.class.path", classpath.stream().map(Path::toString).collect(Collectors.joining(File.pathSeparator))); ClientLauncherEntryPoint.classLoader = classLoader; Thread.currentThread().setContextClassLoader(classLoader); classLoader.nativePath = clientDir.resolve("natives").toString(); @@ -156,19 +158,19 @@ public static void main(String[] args) throws Throwable { ClientService.baseURLs = classLoader.getURLs(); } else if (classLoaderConfig == ClientProfile.ClassLoaderConfig.AGENT) { ClientLauncherEntryPoint.classLoader = ClassLoader.getSystemClassLoader(); - classpath.add(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toUri().toURL()); - for (URL url : classpath) { + classpathURLs.add(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toUri().toURL()); + for (URL url : classpathURLs) { LauncherAgent.addJVMClassPath(Paths.get(url.toURI())); } ClientService.instrumentation = LauncherAgent.inst; ClientService.nativePath = clientDir.resolve("natives").toString(); LauncherEngine.modulesManager.invokeEvent(new ClientProcessClassLoaderEvent(engine, classLoader, profile)); ClientService.classLoader = classLoader; - ClientService.baseURLs = classpath.toArray(new URL[0]); + ClientService.baseURLs = classpathURLs.toArray(new URL[0]); } else if (classLoaderConfig == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) { ClientLauncherEntryPoint.classLoader = ClassLoader.getSystemClassLoader(); ClientService.classLoader = ClassLoader.getSystemClassLoader(); - ClientService.baseURLs = classpath.toArray(new URL[0]); + ClientService.baseURLs = classpathURLs.toArray(new URL[0]); } AuthService.username = params.playerProfile.username; AuthService.uuid = params.playerProfile.uuid; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/PlayerProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/PlayerProfile.java index 115500b7..09ebeac1 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/PlayerProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/PlayerProfile.java @@ -15,7 +15,7 @@ public final class PlayerProfile { public PlayerProfile(UUID uuid, String username, Texture skin, Texture cloak) { this.uuid = Objects.requireNonNull(uuid, "uuid"); - this.username = VerifyHelper.verifyUsername(username); + this.username = username; this.skin = skin; this.cloak = cloak; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java index e8c79910..ac647341 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/CheckServerRequest.java @@ -14,7 +14,7 @@ public final class CheckServerRequest extends Request i public CheckServerRequest(String username, String serverID) { - this.username = VerifyHelper.verifyUsername(username); + this.username = username; this.serverID = VerifyHelper.verifyServerID(serverID); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java index 19e028cc..6a3cf1ab 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/JoinServerRequest.java @@ -18,7 +18,7 @@ public final class JoinServerRequest extends Request imp public JoinServerRequest(String username, String accessToken, String serverID) { - this.username = VerifyHelper.verifyUsername(username); + this.username = username; this.accessToken = accessToken; this.serverID = VerifyHelper.verifyServerID(serverID); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java index b120341c..20708419 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java @@ -21,8 +21,6 @@ public BatchProfileByUsernameRequest(String... usernames) throws IOException { this.list[i].username = usernames[i]; } IOHelper.verifyLength(usernames.length, IOHelper.MAX_BATCH_SIZE); - for (String username : usernames) - VerifyHelper.verifyUsername(username); } @Override diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java index 9b7c1d8b..43c5c02a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/uuid/ProfileByUsernameRequest.java @@ -12,7 +12,7 @@ public final class ProfileByUsernameRequest extends Request { public static final int MAJOR = 5; public static final int MINOR = 2; - public static final int PATCH = 7; + public static final int PATCH = 8; 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/JavaHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java index ca23555f..ad70ca4f 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -77,6 +78,8 @@ public synchronized static List findJava() { tryAddJava(javaPaths, result, JavaVersion.getByPath(p1)); trySearchJava(javaPaths, result, p1.getParent()); } + } catch (InvalidPathException ignored) { + } catch (IOException e) { LogHelper.error(e); } diff --git a/build.gradle b/build.gradle index 8d1bbf49..a72ae376 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.0.10' apply false } group = 'pro.gravit.launcher' -version = '5.2.7' +version = '5.2.8' apply from: 'props.gradle' diff --git a/modules b/modules index dced1548..4eb5b326 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit dced154854c59d8b1e816ebfb1f51baaaeafabfb +Subproject commit 4eb5b32678202efcff2d7cf8f87bdf32eab5384d diff --git a/props.gradle b/props.gradle index 330903d1..6d5b39ab 100644 --- a/props.gradle +++ b/props.gradle @@ -1,7 +1,7 @@ project.ext { verAsm = '9.2' verNetty = '4.1.70.Final' - verOshiCore = '5.8.5' + verOshiCore = '6.0.0' verJunit = '5.8.2' verGuavaC = '30.1.1-jre' verJansi = '2.3.4' @@ -11,7 +11,7 @@ verGson = '2.8.9' verBcpkix = '1.70' verSlf4j = '1.7.32' - verLog4j = '2.15.0' + verLog4j = '2.17.1' verMySQLConn = '8.0.27' verPostgreSQLConn = '42.3.1' verProguard = '7.2.0-beta2'