diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java index 1f896b95..638dc91f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java @@ -470,9 +470,9 @@ public String toString() { } public static class MySQLUserHardware implements UserHardware { - private HardwareReportRequest.HardwareInfo hardwareInfo; + private final HardwareReportRequest.HardwareInfo hardwareInfo; private byte[] publicKey; - private long id; + private final long id; private boolean banned; public MySQLUserHardware(HardwareReportRequest.HardwareInfo hardwareInfo, byte[] publicKey, long id, boolean banned) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DoubleDigestPasswordVerifier.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DoubleDigestPasswordVerifier.java index 49da448a..7f72e773 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DoubleDigestPasswordVerifier.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/password/DoubleDigestPasswordVerifier.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; import java.nio.charset.StandardCharsets; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java index fc2bef9d..c6851ae8 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -63,7 +63,6 @@ public Path process(Path inputJar) throws IOException { for (Path e : server.launcherBinary.coreLibs) { reader.getCp().add(new JarFile(e.toFile())); } - ; context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true); // map for guard diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java index 76f182dd..8607f8f5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/SignDirCommand.java @@ -34,7 +34,7 @@ public void invoke(String... args) throws Exception { verifyArgs(args, 1); Path targetDir = Paths.get(args[0]); if (!IOHelper.isDir(targetDir)) - throw new IllegalArgumentException(String.format("%s not directory", targetDir.toString())); + throw new IllegalArgumentException(String.format("%s not directory", targetDir)); Optional task = server.launcherBinary.getTaskByClass(SignJarTask.class); if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found"); IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java index baa751ff..052c5601 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java @@ -20,7 +20,7 @@ public class UpdatesManager { private final LaunchServer server; private final Logger logger = LogManager.getLogger(); private volatile Map updatesDirMap; - private Path cacheFile; + private final Path cacheFile; public UpdatesManager(LaunchServer server) { this.server = server; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java index b3a8e860..2c0a9513 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyWebAPIHandler.java @@ -78,8 +78,8 @@ default Map getParamsFromUri(String uri) { String sub = uri.substring(ind + 1); String[] result = sub.split("&"); Map map = new HashMap<>(); - for (int i = 0; i < result.length; ++i) { - String c = URLDecoder.decode(result[i], Charset.defaultCharset()); + for (String s : result) { + String c = URLDecoder.decode(s, Charset.defaultCharset()); int index = c.indexOf("="); if (index <= 0) { continue; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java index 1bbd3173..5f4b1f3e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreResponse.java @@ -89,7 +89,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { }); } if (needUserInfo && client.isAuth) { - sendResult(new RestoreRequestEvent(CurrentUserResponse.collectUserInfoFromClient(client), invalidTokens)); + sendResult(new RestoreRequestEvent(CurrentUserResponse.collectUserInfoFromClient(server, client), invalidTokens)); } else { sendResult(new RestoreRequestEvent(invalidTokens)); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java index a41b43a1..6d3530c4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/RestoreSessionResponse.java @@ -46,7 +46,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception { WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class); frameHandler.setClient(rClient[0]); if (needUserInfo) { - sendResult(new RestoreSessionRequestEvent(CurrentUserResponse.collectUserInfoFromClient(rClient[0]))); + sendResult(new RestoreSessionRequestEvent(CurrentUserResponse.collectUserInfoFromClient(server, rClient[0]))); } else { sendResult(new RestoreSessionRequestEvent()); } diff --git a/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java b/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java index 33895dc4..f6d8e839 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java +++ b/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java @@ -1,8 +1,6 @@ package pro.gravit.launcher; import pro.gravit.launcher.events.ExtendedTokenRequestEvent; -import pro.gravit.launcher.events.request.AuthRequestEvent; -import pro.gravit.launcher.events.request.ErrorRequestEvent; import pro.gravit.launcher.events.request.SecurityReportRequestEvent; import pro.gravit.launcher.request.Request; import pro.gravit.launcher.request.WebSocketEvent; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java index fb2fbaf8..3e327dd4 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java @@ -141,7 +141,7 @@ public final LauncherModule preInit() { * @return true if adding a handler was successful */ protected boolean registerEvent(EventHandler handle, Class tClass) { - EventEntity eventEntity = new EventEntity(handle, tClass); + EventEntity eventEntity = new EventEntity<>(handle, tClass); eventList.add(eventEntity); return true; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 8f107c9a..4afa0682 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -4,8 +4,8 @@ import pro.gravit.launcher.hasher.FileNameMatcher; import pro.gravit.launcher.profiles.optional.OptionalDepend; import pro.gravit.launcher.profiles.optional.OptionalFile; -import pro.gravit.launcher.profiles.optional.OptionalTrigger; import pro.gravit.launcher.profiles.optional.OptionalType; +import pro.gravit.launcher.profiles.optional.triggers.OptionalTrigger; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.VerifyHelper; @@ -376,12 +376,10 @@ public void verify() { if (s == null) throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.dependenciesFile", f.name)); } - if (f.triggers != null) { - for (OptionalTrigger trigger : f.triggers) { + if (f.triggersList != null) { + for (OptionalTrigger trigger : f.triggersList) { if (trigger == null) throw new IllegalArgumentException(String.format("Found null entry in updateOptional.%s.triggers", f.name)); - if (trigger.type == null) - throw new IllegalArgumentException(String.format("trigger.type must not be null in updateOptional.%s.triggers", f.name)); } } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java index ec04d18b..f059c99f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java @@ -23,8 +23,8 @@ public abstract class Request implements WebSocketRequ private static Map extendedTokens; private static String authId; private static long tokenExpiredTime; - private static List extendedTokenCallbacks = new ArrayList<>(4); - private static List> oauthChangeHandlers = new ArrayList<>(4); + private static final List extendedTokenCallbacks = new ArrayList<>(4); + private static final List> oauthChangeHandlers = new ArrayList<>(4); @LauncherNetworkAPI public final UUID requestUUID = UUID.randomUUID(); private transient final AtomicBoolean started = new AtomicBoolean(false); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java index 4399dcab..d53b889d 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java @@ -77,7 +77,7 @@ public static String rawFormat(LogHelper.Level level, String dateTime, boolean s } public static String formatVersion(String product) { - return String.format("GravitLauncher (fork sashok724's Launcher) %s v%s", product, Version.getVersion().toString()); + return String.format("GravitLauncher (fork sashok724's Launcher) %s v%s", product, Version.getVersion()); } public static String formatLicense(String product) { 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 74fc155b..5b576ca2 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JavaHelper.java @@ -47,7 +47,7 @@ public static boolean tryAddModule(List paths, String moduleName, StringBu Path result = tryFindModule(path, moduleName); if (result != null) { if (args.length() != 0) args.append(File.pathSeparatorChar); - args.append(result.toAbsolutePath().toString()); + args.append(result.toAbsolutePath()); return true; } } diff --git a/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java b/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java index 5778ae74..91137902 100644 --- a/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java +++ b/LauncherCore/src/main/java11/pro/gravit/utils/Downloader.java @@ -72,9 +72,7 @@ public static Downloader downloadList(List files, Str downloader.future = downloader.downloadFiles(files, baseURL, targetDir, callback, executor, threads); if (closeExecutor) { ExecutorService finalExecutor = executor; - downloader.future = downloader.future.thenAccept(e -> { - finalExecutor.shutdownNow(); - }); + downloader.future = downloader.future.thenAccept(e -> finalExecutor.shutdownNow()); } return downloader; }