diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 51d290bd..d016db56 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -37,14 +37,11 @@ import java.io.BufferedReader; import java.io.IOException; import java.lang.ProcessBuilder.Redirect; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.security.KeyStore; import java.time.Duration; import java.time.Instant; -import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -244,7 +241,6 @@ public void invoke(String... args) throws Exception { } switch (args[0]) { case "full" -> reload(ReloadType.FULL); - case "no_auth" -> reload(ReloadType.NO_AUTH); case "no_components" -> reload(ReloadType.NO_COMPONENTS); default -> reload(ReloadType.NO_AUTH); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java index 750d4aff..c0e6d454 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java @@ -11,7 +11,6 @@ import java.util.*; import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; @SuppressWarnings("rawtypes") public class InjectClassAcceptor implements MainBuildTask.ASMTransformer { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java index bf1464cd..88893c87 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/NodeUtils.java @@ -149,10 +149,7 @@ public static int opcodeEmulation(AbstractInsnNode e) { break; case INVOKEVIRTUAL: case INVOKESPECIAL: - case INVOKEINTERFACE: - stackSize += doMethodEmulation(((MethodInsnNode) e).desc); - break; - case INVOKESTATIC: + case INVOKEINTERFACE, INVOKESTATIC: stackSize += doMethodEmulation(((MethodInsnNode) e).desc); break; case INVOKEDYNAMIC: diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SignerJar.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SignerJar.java index 34f342db..2596d484 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SignerJar.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SignerJar.java @@ -69,7 +69,6 @@ public SignerJar(ZipOutputStream out, Supplier gen, Stri * * @param filename name of the file to add (use forward slash as a path separator) * @param contents contents of the file - * @throws IOException * @throws NullPointerException if any of the arguments is {@code null} */ public void addFileContents(String filename, byte[] contents) throws IOException { @@ -82,7 +81,6 @@ public void addFileContents(String filename, byte[] contents) throws IOException * * @param filename name of the file to add (use forward slash as a path separator) * @param contents contents of the file - * @throws IOException * @throws NullPointerException if any of the arguments is {@code null} */ public void addFileContents(String filename, InputStream contents) throws IOException { @@ -95,7 +93,6 @@ public void addFileContents(String filename, InputStream contents) throws IOExce * * @param entry name of the file to add (use forward slash as a path separator) * @param contents contents of the file - * @throws IOException * @throws NullPointerException if any of the arguments is {@code null} */ public void addFileContents(ZipEntry entry, byte[] contents) throws IOException { @@ -108,7 +105,6 @@ public void addFileContents(ZipEntry entry, byte[] contents) throws IOException * * @param entry name of the file to add (use forward slash as a path separator) * @param contents contents of the file - * @throws IOException * @throws NullPointerException if any of the arguments is {@code null} */ public void addFileContents(ZipEntry entry, InputStream contents) throws IOException { @@ -134,7 +130,6 @@ public void addManifestAttribute(String name, String value) { * Closes the JAR file by writing the manifest and signature data to it and finishing the ZIP entries. It closes the * underlying stream. * - * @throws IOException * @throws RuntimeException if the signing goes wrong */ @Override @@ -148,7 +143,6 @@ public void close() throws IOException { * Finishes the JAR file by writing the manifest and signature data to it and finishing the ZIP entries. It leaves the * underlying stream open. * - * @throws IOException * @throws RuntimeException if the signing goes wrong */ public void finish() throws IOException { @@ -205,7 +199,6 @@ private byte[] signSigFile(byte[] sigContents) throws Exception { * Writes the manifest to the JAR. It also calculates the digests that are required to be placed in the the signature * file. * - * @throws IOException */ private void writeManifest() throws IOException { zos.putNextEntry(IOHelper.newZipEntry(MANIFEST_FN)); @@ -268,7 +261,6 @@ private byte[] writeSigFile() throws IOException { /** * Signs the .SIG file and writes the signature (.RSA file) to the JAR. * - * @throws IOException * @throws RuntimeException if the signing failed */ private void writeSignature(byte[] sigFile) throws IOException { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java index 43f147d0..5ac22a87 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java @@ -14,7 +14,6 @@ import java.io.BufferedWriter; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; import java.util.UUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/MakeProfileCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/MakeProfileCommand.java index 476024f9..78f6973d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/MakeProfileCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/MakeProfileCommand.java @@ -10,7 +10,6 @@ import pro.gravit.utils.helper.IOHelper; import java.io.Writer; -import java.nio.file.Files; public class MakeProfileCommand extends Command { private transient final Logger logger = LogManager.getLogger(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SecurityCheckCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SecurityCheckCommand.java index bebfbecc..95d6cf99 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SecurityCheckCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SecurityCheckCommand.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Set; import java.util.StringTokenizer; -import java.util.stream.Collectors; public class SecurityCheckCommand extends Command { private static final Logger logger = LogManager.getLogger(); @@ -113,7 +112,7 @@ public void invoke(String... args) { List certChain = Arrays.stream(certChainPlain).map(e -> (X509Certificate) e).toList(); X509Certificate cert = certChain.get(0); cert.checkValidity(); - if (certChain.size() <= 1) { + if (certChain.size() == 1) { printCheckResult("sign", "certificate chain contains <2 element(recommend 2 and more)", false); bad = true; } 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 2b4453f5..6f2354ad 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java @@ -49,9 +49,7 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti } else if (version.compareTo(ClientProfileVersions.MINECRAFT_1_18) <= 0) { // 1.13 - 1.16.5 jvmArgs.add("-XX:+UseG1GC"); jvmArgs.add("-XX:+UnlockExperimentalVMOptions"); - } else { // 1.18+ - //jvmArgs.add("-XX:+UseShenandoahGC"); - //jvmArgs.add("-XX:+UnlockExperimentalVMOptions"); + } else { } // ----------- Optional forge = findOption(options, MakeProfileOptionForge.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java index cf86c5d4..3466fe29 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/SignHelper.java @@ -22,7 +22,6 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.time.Instant; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/launchermodules/LauncherModuleLoader.java b/LaunchServer/src/main/java/pro/gravit/launchserver/launchermodules/LauncherModuleLoader.java index 706986e2..de2555f0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/launchermodules/LauncherModuleLoader.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/launchermodules/LauncherModuleLoader.java @@ -4,7 +4,6 @@ import org.apache.logging.log4j.Logger; import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherTrustManager; -import pro.gravit.launcher.modules.LauncherModule; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.asm.InjectClassAcceptor; import pro.gravit.launchserver.binary.tasks.MainBuildTask; @@ -109,7 +108,6 @@ private ModulesVisitor() { } @Override - @SuppressWarnings("unchecked") public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.toFile().getName().endsWith(".jar")) try (JarFile f = new JarFile(file.toFile())) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index 7df54538..d57dc46d 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -7,10 +7,8 @@ import pro.gravit.launcher.console.GetPublicKeyCommand; import pro.gravit.launcher.console.ModulesCommand; import pro.gravit.launcher.console.SignDataCommand; -import pro.gravit.launcher.events.request.*; import pro.gravit.launcher.gui.NoRuntimeProvider; import pro.gravit.launcher.gui.RuntimeProvider; -import pro.gravit.launcher.client.RuntimeGsonManager; import pro.gravit.launcher.managers.ConsoleManager; import pro.gravit.launcher.modules.events.OfflineModeEvent; import pro.gravit.launcher.modules.events.PreConfigPhase; @@ -20,11 +18,6 @@ import pro.gravit.launcher.request.RequestException; import pro.gravit.launcher.request.RequestService; import pro.gravit.launcher.request.auth.*; -import pro.gravit.launcher.request.auth.details.AuthLoginOnlyDetails; -import pro.gravit.launcher.request.management.FeaturesRequest; -import pro.gravit.launcher.request.secure.GetSecureLevelInfoRequest; -import pro.gravit.launcher.request.secure.SecurityReportRequest; -import pro.gravit.launcher.request.update.LauncherRequest; import pro.gravit.launcher.request.websockets.OfflineRequestService; import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.launcher.utils.NativeJVMHalt; @@ -39,9 +32,7 @@ import java.security.interfaces.ECPrivateKey; import java.security.interfaces.ECPublicKey; import java.security.spec.InvalidKeySpecException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/Launcher/src/main/java/pro/gravit/launcher/debug/ClientRuntimeProvider.java b/Launcher/src/main/java/pro/gravit/launcher/debug/ClientRuntimeProvider.java index 1499b143..d2bc9630 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/debug/ClientRuntimeProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/debug/ClientRuntimeProvider.java @@ -1,24 +1,19 @@ package pro.gravit.launcher.debug; import pro.gravit.launcher.ClientPermissions; -import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherEngine; import pro.gravit.launcher.api.AuthService; -import pro.gravit.launcher.api.ClientService; -import pro.gravit.launcher.client.ClientParams; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.events.request.ProfilesRequestEvent; import pro.gravit.launcher.gui.RuntimeProvider; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.auth.AuthRequest; -import pro.gravit.launcher.request.auth.password.AuthPlainPassword; import pro.gravit.launcher.request.update.ProfilesRequest; import pro.gravit.utils.helper.LogHelper; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.UUID; public class ClientRuntimeProvider implements RuntimeProvider { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java b/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java index 9b673b61..165f2bfb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java @@ -6,13 +6,11 @@ import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; -import pro.gravit.utils.helper.SecurityHelper; import java.io.IOException; import java.net.URL; import java.nio.file.NoSuchFileException; import java.security.spec.InvalidKeySpecException; -import java.util.Arrays; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java index 26515464..1ee786f8 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java @@ -46,7 +46,7 @@ public static CompletableFuture initWebSockets(String addre LogHelper.error(e); } })); - }, (error) -> future.completeExceptionally(error)); + }, future::completeExceptionally); return future; } diff --git a/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java b/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java index b676e662..205b495a 100644 --- a/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java +++ b/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java @@ -14,14 +14,14 @@ public void parseTest() { @Test public void compareTest() { - Assertions.assertTrue(ClientProfile.Version.of("1.0.0").compareTo(ClientProfile.Version.of("1.0.0")) == 0); + Assertions.assertEquals(0, ClientProfile.Version.of("1.0.0").compareTo(ClientProfile.Version.of("1.0.0"))); Assertions.assertTrue(ClientProfile.Version.of("1.1.0").compareTo(ClientProfile.Version.of("1.0.0")) > 0); Assertions.assertTrue(ClientProfile.Version.of("2.0.0").compareTo(ClientProfile.Version.of("1.0.0")) > 0); Assertions.assertTrue(ClientProfile.Version.of("1.0.0").compareTo(ClientProfile.Version.of("1.0.1")) < 0); Assertions.assertTrue(ClientProfile.Version.of("1.1.0").compareTo(ClientProfile.Version.of("1.0.0")) > 0); Assertions.assertTrue(ClientProfile.Version.of("1.0.0").compareTo(ClientProfile.Version.of("1.1.0")) < 0); - Assertions.assertTrue(ClientProfile.Version.of("1.0").compareTo(ClientProfile.Version.of("1.0.0")) == 0); - Assertions.assertTrue(ClientProfile.Version.of("1.0.0").compareTo(ClientProfile.Version.of("1.0")) == 0); + Assertions.assertEquals(0, ClientProfile.Version.of("1.0").compareTo(ClientProfile.Version.of("1.0.0"))); + Assertions.assertEquals(0, ClientProfile.Version.of("1.0.0").compareTo(ClientProfile.Version.of("1.0"))); Assertions.assertTrue(ClientProfile.Version.of("1.0.1").compareTo(ClientProfile.Version.of("1.0")) > 0); Assertions.assertTrue(ClientProfile.Version.of("1.0").compareTo(ClientProfile.Version.of("1.0.1")) < 0); Assertions.assertTrue(ClientProfile.Version.of("1.0").compareTo(ClientProfile.Version.of("1.0.1")) < 0); diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/api/CertificateService.java b/LauncherClient/src/main/java/pro/gravit/launcher/api/CertificateService.java index 2b2f0b5c..b21cb0b5 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/api/CertificateService.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/api/CertificateService.java @@ -2,7 +2,6 @@ import pro.gravit.launcher.ClientLauncherMethods; import pro.gravit.launcher.LauncherTrustManager; -import pro.gravit.launcher.client.ClientLauncherEntryPoint; import pro.gravit.launcher.utils.ApiBridgeService; import java.security.cert.X509Certificate; 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 997e1495..41bc3ab7 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -4,34 +4,22 @@ import pro.gravit.launcher.api.AuthService; import pro.gravit.launcher.api.ClientService; import pro.gravit.launcher.api.KeyService; -import pro.gravit.launcher.client.events.ClientExitPhase; import pro.gravit.launcher.client.events.client.*; -import pro.gravit.launcher.events.request.ProfileByUUIDRequestEvent; -import pro.gravit.launcher.events.request.ProfileByUsernameRequestEvent; import pro.gravit.launcher.hasher.FileNameMatcher; import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.hasher.HashedEntry; -import pro.gravit.launcher.modules.LauncherModulesManager; -import pro.gravit.launcher.modules.events.OfflineModeEvent; import pro.gravit.launcher.modules.events.PreConfigPhase; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.profiles.ClientProfileVersions; import pro.gravit.launcher.profiles.optional.actions.OptionalAction; import pro.gravit.launcher.profiles.optional.actions.OptionalActionClassPath; import pro.gravit.launcher.profiles.optional.actions.OptionalActionClientArgs; -import pro.gravit.launcher.profiles.optional.triggers.OptionalTrigger; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.RequestException; import pro.gravit.launcher.request.RequestService; -import pro.gravit.launcher.request.auth.AuthRequest; -import pro.gravit.launcher.request.auth.GetAvailabilityAuthRequest; -import pro.gravit.launcher.request.uuid.ProfileByUUIDRequest; -import pro.gravit.launcher.request.uuid.ProfileByUsernameRequest; -import pro.gravit.launcher.request.websockets.OfflineRequestService; import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.launcher.serialize.HInput; import pro.gravit.launcher.utils.DirWatcher; -import pro.gravit.launcher.utils.NativeJVMHalt; import pro.gravit.utils.helper.*; import java.io.File; @@ -45,7 +33,6 @@ import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; -import java.security.cert.X509Certificate; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/utils/DirWatcher.java b/LauncherClient/src/main/java/pro/gravit/launcher/utils/DirWatcher.java index 8469d64e..1ee0949b 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/utils/DirWatcher.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/utils/DirWatcher.java @@ -1,7 +1,6 @@ package pro.gravit.launcher.utils; import pro.gravit.launcher.ClientLauncherMethods; -import pro.gravit.launcher.client.ClientLauncherEntryPoint; import pro.gravit.launcher.hasher.FileNameMatcher; import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.hasher.HashedEntry;