From 038af764a1643c6988299953eff0b1a9f79febb2 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:40:45 +0700 Subject: [PATCH] [REFACTOR] IDEA Code Inspect --- .../pro/gravit/launchserver/LaunchServer.java | 1 - .../java/pro/gravit/launchserver/Main.java | 1 - .../auth/core/AuthCoreProvider.java | 1 - .../auth/core/MemoryAuthCoreProvider.java | 1 - .../auth/core/RejectAuthCoreProvider.java | 1 - .../command/handler/CommandHandler.java | 2 - .../command/service/SecurityCheckCommand.java | 26 +++++----- .../components/AbstractLimiter.java | 2 +- .../components/ProGuardComponent.java | 2 - .../config/LaunchServerConfig.java | 2 - .../manangers/hook/AuthHookManager.java | 1 - .../launchserver/socket/WebSocketService.java | 4 +- .../handlers/WebSocketFrameHandler.java | 48 ++++++++++--------- .../fileserver/FileServerHandler.java | 2 +- .../runtime/client/ClientLauncherProcess.java | 2 +- .../pro/gravit/launcher/base/Downloader.java | 1 - .../launcher/base/profiles/Texture.java | 1 - .../base/profiles/optional/OptionalView.java | 6 +-- .../uuid/BatchProfileByUsernameRequest.java | 2 +- .../request/websockets/ClientJSONPoint.java | 1 - .../client/BasicLauncherEventHandler.java | 6 +-- .../launcher/client/ClientModuleManager.java | 1 - .../client/api/CertificateService.java | 1 - .../launcher/core/hasher/HashedDir.java | 1 - .../pro/gravit/utils/helper/JVMHelper.java | 1 - .../pro/gravit/utils/helper/UnpackHelper.java | 2 +- 26 files changed, 48 insertions(+), 71 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 13236d5a..d3a435ea 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -34,7 +34,6 @@ import java.io.BufferedReader; import java.io.IOException; -import java.lang.ProcessBuilder.Redirect; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; import java.security.KeyStore; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java b/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java index 8361e8f4..fc95cb72 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/Main.java @@ -6,7 +6,6 @@ import pro.gravit.utils.launch.LaunchOptions; import pro.gravit.utils.launch.ModuleLaunch; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthCoreProvider.java index bdf060ee..b6e14d8d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthCoreProvider.java @@ -27,7 +27,6 @@ import pro.gravit.utils.ProviderMap; import pro.gravit.utils.command.Command; import pro.gravit.utils.command.SubCommand; -import pro.gravit.utils.helper.VerifyHelper; import java.io.IOException; import java.lang.reflect.Type; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MemoryAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MemoryAuthCoreProvider.java index 280ae084..bae81df6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MemoryAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MemoryAuthCoreProvider.java @@ -4,7 +4,6 @@ import pro.gravit.launcher.base.events.request.GetAvailabilityAuthRequestEvent; import pro.gravit.launcher.base.request.auth.AuthRequest; import pro.gravit.launcher.base.request.auth.details.AuthLoginOnlyDetails; -import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportSudo; import pro.gravit.launchserver.manangers.AuthManager; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java index 509abef5..3358ad9b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java @@ -1,7 +1,6 @@ package pro.gravit.launchserver.auth.core; import pro.gravit.launcher.base.request.auth.AuthRequest; -import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.manangers.AuthManager; import pro.gravit.launchserver.socket.Client; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index 5b6d9aff..bd8a8567 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -5,9 +5,7 @@ import pro.gravit.launchserver.command.hash.*; import pro.gravit.launchserver.command.modules.LoadModuleCommand; import pro.gravit.launchserver.command.modules.ModulesCommand; -import pro.gravit.launchserver.command.profiles.MakeProfileCommand; import pro.gravit.launchserver.command.profiles.ProfilesCommand; -import pro.gravit.launchserver.command.profiles.SaveProfilesCommand; import pro.gravit.launchserver.command.service.*; import pro.gravit.launchserver.command.sync.*; import pro.gravit.launchserver.command.tools.SignDirCommand; 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 a18c19e7..88472600 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 @@ -60,19 +60,19 @@ public void invoke(String... args) { LaunchServerConfig config = server.config; config.auth.forEach((name, pair) -> { }); - if (config.protectHandler instanceof NoProtectHandler) { - printCheckResult("protectHandler", "protectHandler none", false); - } else if (config.protectHandler instanceof AdvancedProtectHandler) { - printCheckResult("protectHandler", "", true); - if (!((AdvancedProtectHandler) config.protectHandler).enableHardwareFeature) { - printCheckResult("protectHandler.hardwareId", "you can improve security by using hwid provider", null); - } else { - printCheckResult("protectHandler.hardwareId", "", true); + switch (config.protectHandler) { + case NoProtectHandler noProtectHandler -> printCheckResult("protectHandler", "protectHandler none", false); + case AdvancedProtectHandler advancedProtectHandler -> { + printCheckResult("protectHandler", "", true); + if (!advancedProtectHandler.enableHardwareFeature) { + printCheckResult("protectHandler.hardwareId", "you can improve security by using hwid provider", null); + } else { + printCheckResult("protectHandler.hardwareId", "", true); + } } - } else if (config.protectHandler instanceof StdProtectHandler) { - printCheckResult("protectHandler", "you can improve security by using advanced", null); - } else { - printCheckResult("protectHandler", "unknown protectHandler", null); + case StdProtectHandler stdProtectHandler -> + printCheckResult("protectHandler", "you can improve security by using advanced", null); + case null, default -> printCheckResult("protectHandler", "unknown protectHandler", null); } if (config.netty.address.startsWith("ws://")) { if (config.netty.ipForwarding) @@ -110,7 +110,7 @@ public void invoke(String... args) { KeyStore keyStore = SignHelper.getStore(new File(config.sign.keyStore).toPath(), config.sign.keyStorePass, config.sign.keyStoreType); Certificate[] certChainPlain = keyStore.getCertificateChain(config.sign.keyAlias); List certChain = Arrays.stream(certChainPlain).map(e -> (X509Certificate) e).toList(); - X509Certificate cert = certChain.get(0); + X509Certificate cert = certChain.getFirst(); cert.checkValidity(); if (certChain.size() == 1) { printCheckResult("sign", "certificate chain contains <2 element(recommend 2 and more)", false); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java index 3fd4f2eb..1c74307e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java @@ -90,7 +90,7 @@ public boolean check(T address) { } } - static class LimitEntry { + protected static class LimitEntry { long time; int trys; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java index ee92b7e0..97a36b49 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java @@ -9,7 +9,6 @@ import pro.gravit.utils.command.SubCommand; 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 pro.gravit.utils.helper.UnpackHelper; @@ -20,7 +19,6 @@ import java.nio.file.Paths; import java.security.SecureRandom; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; 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 9300340a..ecba3a95 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -15,9 +15,7 @@ import pro.gravit.launchserver.components.AuthLimiterComponent; import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.components.ProGuardComponent; -import pro.gravit.utils.helper.JVMHelper; -import java.io.File; import java.util.*; import static java.util.concurrent.TimeUnit.HOURS; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java index fcaaf91a..27b5a491 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/hook/AuthHookManager.java @@ -7,7 +7,6 @@ import pro.gravit.launchserver.socket.response.auth.JoinServerResponse; import pro.gravit.launchserver.socket.response.auth.SetProfileResponse; import pro.gravit.utils.BiHookSet; -import pro.gravit.utils.HookSet; public class AuthHookManager { public final BiHookSet preHook = new BiHookSet<>(); 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 024d1644..ee46dc8f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -142,9 +142,7 @@ public void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client if(executors == null) { process(safeStatus, client, ip, context, response); } else { - executors.submit(() -> { - process(safeStatus, client, ip, context, response); - }); + executors.submit(() -> process(safeStatus, client, ip, context, response)); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java index c4260949..9b5a25dc 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/WebSocketFrameHandler.java @@ -63,32 +63,36 @@ protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) { } catch (Throwable ex) { logger.error("WebSocket frame handler hook error", ex); } - if (frame instanceof TextWebSocketFrame textWebSocketFrame) { - if (logger.isTraceEnabled()) { - logger.trace("Message from {}: {}", context.ip == null ? IOHelper.getIP(ctx.channel().remoteAddress()) : context.ip, textWebSocketFrame.text()); - } - try { - service.process(ctx, textWebSocketFrame, client, context.ip, connectUUID); - } catch (Throwable ex) { - logger.warn("Client {} send invalid request. Connection force closed.", context.ip == null ? IOHelper.getIP(ctx.channel().remoteAddress()) : context.ip); + switch (frame) { + case TextWebSocketFrame textWebSocketFrame -> { if (logger.isTraceEnabled()) { - logger.trace("Client message: {}", textWebSocketFrame.text()); - logger.error("Process websockets request failed", ex); + logger.trace("Message from {}: {}", context.ip == null ? IOHelper.getIP(ctx.channel().remoteAddress()) : context.ip, textWebSocketFrame.text()); } + try { + service.process(ctx, textWebSocketFrame, client, context.ip, connectUUID); + } catch (Throwable ex) { + logger.warn("Client {} send invalid request. Connection force closed.", context.ip == null ? IOHelper.getIP(ctx.channel().remoteAddress()) : context.ip); + if (logger.isTraceEnabled()) { + logger.trace("Client message: {}", textWebSocketFrame.text()); + logger.error("Process websockets request failed", ex); + } + ctx.channel().close(); + } + } + case PingWebSocketFrame pingWebSocketFrame -> { + frame.content().retain(); + ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content())); + //return; + } + case PongWebSocketFrame pongWebSocketFrame -> logger.trace("WebSocket Client received pong"); + case CloseWebSocketFrame closeWebSocketFrame -> { + int statusCode = closeWebSocketFrame.statusCode(); ctx.channel().close(); } - } else if ((frame instanceof PingWebSocketFrame)) { - frame.content().retain(); - ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content())); - //return; - } else if (frame instanceof PongWebSocketFrame) { - logger.trace("WebSocket Client received pong"); - } else if (frame instanceof CloseWebSocketFrame closeWebSocketFrame) { - int statusCode = closeWebSocketFrame.statusCode(); - ctx.channel().close(); - } else { - String message = "unsupported frame type: " + frame.getClass().getName(); - logger.error(new UnsupportedOperationException(message)); // prevent strange crash here. + case null, default -> { + String message = "unsupported frame type: " + frame.getClass().getName(); + logger.error(new UnsupportedOperationException(message)); // prevent strange crash here. + } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java index 2f91224f..1030b973 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/fileserver/FileServerHandler.java @@ -152,7 +152,7 @@ private static void setDateAndCacheHeaders(HttpResponse response, File fileToCac response.headers().set(HttpHeaderNames.DATE, dateFormatter.format(time)); // Add cache headers - response.headers().set(HttpHeaderNames.EXPIRES, dateFormatter.format(time.plus(HTTP_CACHE_SECONDS, ChronoUnit.SECONDS))); + response.headers().set(HttpHeaderNames.EXPIRES, dateFormatter.format(time.plusSeconds(HTTP_CACHE_SECONDS))); response.headers().set(HttpHeaderNames.CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS); response.headers().set( HttpHeaderNames.LAST_MODIFIED, dateFormatter.format(Instant.ofEpochMilli(fileToCache.lastModified()))); 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 ac85b898..9f8b3293 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 @@ -150,7 +150,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(workDir, params.actions, params.profile) .filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString())) .map(Path::toString) - .collect(Collectors.toList())); + .toList()); } if (Launcher.getConfig().environment != LauncherConfig.LauncherEnvironment.PROD) { processArgs.add(JVMHelper.jvmProperty(LogHelper.DEV_PROPERTY, String.valueOf(LogHelper.isDevEnabled()))); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java index f7f0038a..6eecdc21 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/Downloader.java @@ -6,7 +6,6 @@ import pro.gravit.utils.helper.LogHelper; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSocketFactory; import java.io.IOException; import java.net.URI; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/Texture.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/Texture.java index d77fb3b7..568f1d14 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/Texture.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/Texture.java @@ -10,7 +10,6 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.nio.file.Path; import java.util.Arrays; import java.util.Map; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/optional/OptionalView.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/optional/OptionalView.java index d257215e..80df3666 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/optional/OptionalView.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/optional/OptionalView.java @@ -126,11 +126,7 @@ public void enable(OptionalFile file, boolean manual, BiConsumer new OptionalFileInstallInfo()); installInfo.isManual = manual; if (file.dependencies != null) { for (OptionalFile dep : file.dependencies) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/uuid/BatchProfileByUsernameRequest.java index 65509418..01e5067a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/uuid/BatchProfileByUsernameRequest.java @@ -27,7 +27,7 @@ public String getType() { return "batchProfileByUsername"; } - static class Entry { + public static class Entry { @LauncherNetworkAPI String username; @LauncherNetworkAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java index 08df0ec1..ffdab6c6 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java @@ -15,7 +15,6 @@ import java.security.cert.CertificateException; import java.time.Duration; import java.util.concurrent.CompletionStage; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/BasicLauncherEventHandler.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/BasicLauncherEventHandler.java index 87d03fa9..6269c269 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/BasicLauncherEventHandler.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/BasicLauncherEventHandler.java @@ -13,8 +13,7 @@ public class BasicLauncherEventHandler implements RequestService.EventHandler { @Override public boolean eventHandle(T event) { - if (event instanceof SecurityReportRequestEvent) { - SecurityReportRequestEvent event1 = (SecurityReportRequestEvent) event; + if (event instanceof SecurityReportRequestEvent event1) { if (event1.action == SecurityReportRequestEvent.ReportAction.TOKEN_EXPIRED) { try { Request.restore(); @@ -22,8 +21,7 @@ public boolean eventHandle(T event) { LogHelper.error(e); } } - } else if (event instanceof ExtendedTokenRequestEvent) { - ExtendedTokenRequestEvent event1 = (ExtendedTokenRequestEvent) event; + } else if (event instanceof ExtendedTokenRequestEvent event1) { String token = event1.getExtendedToken(); if (token != null) { Request.addExtendedToken(event1.getExtendedTokenName(), new Request.ExtendedToken(event1.getExtendedToken(), event1.getExtendedTokenExpire())); diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java index b516523f..bbcefeeb 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java @@ -5,7 +5,6 @@ import pro.gravit.launcher.base.modules.LauncherModule; import pro.gravit.launcher.base.modules.impl.SimpleModuleManager; -import java.net.URL; import java.nio.file.Path; import java.util.Collections; import java.util.List; diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/api/CertificateService.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/api/CertificateService.java index 3c6a6e56..ada1e6ac 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/api/CertificateService.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/api/CertificateService.java @@ -84,7 +84,6 @@ private static CheckClassResultTypeApi fromType(LauncherTrustManager.CheckClassR case UNTRUSTED -> CheckClassResultTypeApi.UNTRUSTED; case UNVERIFED -> CheckClassResultTypeApi.UNVERIFED; case UNCOMPAT -> CheckClassResultTypeApi.UNCOMPAT; - default -> CheckClassResultTypeApi.UNKNOWN; }; } } diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java b/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java index 232e98ce..343f7e80 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java @@ -33,7 +33,6 @@ public HashedDir(HInput input) throws IOException { entry = switch (type) { case FILE -> new HashedFile(input); case DIR -> new HashedDir(input); - default -> throw new AssertionError("Unsupported hashed entry type: " + type.name()); }; // Try add entry to map diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/JVMHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/JVMHelper.java index af0d7c6e..bf5ecbdf 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JVMHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JVMHelper.java @@ -61,7 +61,6 @@ public static String getNativeExtension(JVMHelper.OS OS_TYPE) { case MUSTDIE -> ".dll"; case LINUX -> ".so"; case MACOSX -> ".dylib"; - default -> throw new InternalError(String.format("Unsupported OS TYPE '%s'", OS_TYPE)); }; } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/UnpackHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/UnpackHelper.java index b967fb03..5ba58433 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/UnpackHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/UnpackHelper.java @@ -61,7 +61,7 @@ public static void unpackZipNoCheck(String resource, Path target) throws IOExcep IOHelper.transfer(input, target.resolve(IOHelper.toPath(entry.getName()))); } } - } catch (NoSuchFileException e) { + } catch (NoSuchFileException ignored) { } } }