From 9a4b813bb762d54c7cbf65062ed110bc4da6ed4b Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 19 Oct 2019 23:43:25 +0700 Subject: [PATCH] [ANY] IDEA Inspect Code --- .../pro/gravit/launchserver/LaunchServer.java | 18 ++- .../launchserver/LaunchServerStarter.java | 2 +- .../launchserver/asm/ClassMetadataReader.java | 4 +- .../launchserver/auth/AuthProviderPair.java | 10 +- .../auth/handler/AuthHandler.java | 2 +- .../auth/handler/CachedAuthHandler.java | 4 +- .../auth/handler/HibernateAuthHandler.java | 10 +- .../auth/handler/JsonAuthHandler.java | 24 ++-- .../auth/handler/RequestAuthHandler.java | 4 +- .../launchserver/auth/hwid/HWIDHandler.java | 2 +- .../auth/hwid/JsonFileHWIDHandler.java | 18 ++- .../auth/hwid/JsonHWIDHandler.java | 18 +-- .../auth/hwid/MemoryHWIDHandler.java | 18 ++- .../auth/hwid/MysqlHWIDHandler.java | 10 +- .../permissions/ConfigPermissionsHandler.java | 4 +- .../HibernatePermissionsHandler.java | 2 +- .../JsonFilePermissionsHandler.java | 6 +- .../JsonLongFilePermissionsHandler.java | 8 +- .../auth/permissions/PermissionsHandler.java | 2 +- .../auth/protect/ProtectHandler.java | 2 +- .../auth/protect/StdProtectHandler.java | 2 +- .../auth/provider/AuthProvider.java | 2 +- .../auth/provider/HibernateAuthProvider.java | 2 +- .../auth/provider/JsonAuthProvider.java | 12 +- .../auth/provider/RejectAuthProvider.java | 2 +- .../auth/texture/TextureProvider.java | 2 +- .../binary/EXEL4JLauncherBinary.java | 4 +- .../binary/JARLauncherBinary.java | 6 +- .../binary/SimpleEXELauncherBinary.java | 2 +- .../command/dao/GetAllUsersCommand.java | 2 +- .../command/hash/IndexAssetCommand.java | 6 +- .../command/hash/UnindexAssetCommand.java | 2 +- .../command/install/CheckInstallCommand.java | 2 +- .../command/install/MultiCommand.java | 2 +- .../command/service/ClientsCommand.java | 2 +- .../command/service/GetModulusCommand.java | 2 +- .../service/GivePermissionsCommand.java | 2 +- .../components/AbstractLimiter.java | 12 +- .../components/AuthLimiterComponent.java | 2 +- .../components/CommandRemoverComponent.java | 4 +- .../launchserver/components/Component.java | 2 +- .../components/RegLimiterComponent.java | 2 +- .../config/LaunchServerConfig.java | 19 ++- .../pro/gravit/launchserver/dao/UserHWID.java | 4 +- .../dao/provider/DaoProvider.java | 2 +- .../manangers/CertificateManager.java | 4 +- .../launchserver/manangers/MirrorManager.java | 6 +- .../manangers/ReconfigurableManager.java | 2 +- .../manangers/SessionManager.java | 2 +- .../manangers/hook/AuthHookManager.java | 20 +-- .../impl/LaunchServerModulesManager.java | 2 +- .../gravit/launchserver/socket/Client.java | 2 +- .../launchserver/socket/WebSocketService.java | 8 +- .../handlers/NettyIpForwardHandler.java | 4 +- .../fileserver/FileServerHandler.java | 5 - .../admin/AddLogListenerResponse.java | 2 +- .../socket/response/auth/AuthResponse.java | 16 +-- .../response/auth/SetPasswordResponse.java | 2 +- .../profile/BatchProfileByUsername.java | 2 +- .../launchserver/StartLaunchServerTest.java | 11 +- .../launchserver/console/ExitCommand.java | 2 +- .../console/LogListenerCommand.java | 4 +- .../launcher/ClientLauncherWrapper.java | 2 +- .../gravit/launcher/NewLauncherSettings.java | 8 +- .../launcher/client/ClientLauncher.java | 8 +- .../client/ClientLauncherContext.java | 2 +- .../launcher/client/ClientModuleManager.java | 6 +- .../launcher/client/FunctionalBridge.java | 4 +- .../gravit/launcher/client/ServerPinger.java | 2 +- .../gravit/launcher/client/UserSettings.java | 2 +- .../client/events/ClientPreGuiPhase.java | 2 +- .../launcher/console/FeatureCommand.java | 2 +- .../console/admin/LogListenerCommand.java | 4 +- .../console/store/CopyStoreDirCommand.java | 4 +- .../console/store/LinkStoreDirCommand.java | 2 +- .../console/store/StoreListCommand.java | 2 +- .../gravit/launcher/gui/RuntimeProvider.java | 2 +- .../launcher/managers/ClientHookManager.java | 14 +- .../gravit/launcher/managers/HasherStore.java | 2 +- .../launcher/managers/SettingsManager.java | 2 +- .../gravit/launcher/patches/FMLPatcher.java | 2 +- .../gravit/launcher/utils/NativeJVMHalt.java | 2 +- .../gravit/launcher/ClientPermissions.java | 6 +- .../gravit/launcher/SecureAutogenConfig.java | 2 +- .../launcher/downloader/ListDownloader.java | 9 +- .../gravit/launcher/events/ControlEvent.java | 2 +- .../gravit/launcher/events/SignalEvent.java | 2 +- .../request/ExecCommandRequestEvent.java | 2 +- .../GetAvailabilityAuthRequestEvent.java | 6 +- .../request/GetSecureTokenRequestEvent.java | 2 +- .../request/JoinServerRequestEvent.java | 2 +- .../launcher/events/request/LogEvent.java | 2 +- .../ProfileByUsernameRequestEvent.java | 2 +- .../request/SetProfileRequestEvent.java | 2 +- .../events/request/UpdateRequestEvent.java | 4 +- .../VerifySecureTokenRequestEvent.java | 2 +- .../gravit/launcher/hwid/HWIDProvider.java | 2 +- .../managers/SimpleModulesConfigManager.java | 2 +- .../launcher/modules/LauncherModule.java | 2 +- .../launcher/modules/events/PreGsonPhase.java | 2 +- .../modules/impl/SimpleModuleManager.java | 2 +- .../launcher/profiles/ClientProfile.java | 128 ------------------ .../profiles/optional/OptionalFile.java | 4 +- .../gravit/launcher/request/PingRequest.java | 2 +- .../pro/gravit/launcher/request/Request.java | 2 +- .../request/admin/ExecCommandRequest.java | 2 +- .../launcher/request/auth/AuthRequest.java | 2 +- .../request/auth/RestoreSessionRequest.java | 2 +- .../request/auth/SetProfileRequest.java | 2 +- .../request/update/LauncherRequest.java | 4 +- .../request/update/UpdateRequest.java | 10 +- .../uuid/BatchProfileByUsernameRequest.java | 2 +- .../request/websockets/ClientJSONPoint.java | 12 +- .../websockets/ClientWebSocketService.java | 15 +- .../StandartClientWebSocketService.java | 2 +- .../request/websockets/WaitEventHandler.java | 2 +- .../websockets/WebSocketClientHandler.java | 8 +- .../launcher/managers/GarbageManager.java | 4 +- .../serialize/stream/StreamObject.java | 2 +- .../main/java/pro/gravit/utils/BiHookSet.java | 2 +- .../main/java/pro/gravit/utils/HookSet.java | 2 +- .../main/java/pro/gravit/utils/Version.java | 2 +- .../pro/gravit/utils/command/Command.java | 2 +- .../gravit/utils/command/CommandHandler.java | 8 +- .../utils/command/JLineCommandHandler.java | 6 +- .../utils/command/basic/ClearCommand.java | 2 +- .../utils/command/basic/DebugCommand.java | 2 +- .../gravit/utils/command/basic/GCCommand.java | 2 +- .../utils/command/basic/HelpCommand.java | 6 +- .../pro/gravit/utils/helper/JarHelper.java | 2 +- .../pro/gravit/utils/helper/LogHelper.java | 4 +- .../gravit/utils/helper/SecurityHelper.java | 3 +- .../utils/verify/LauncherTrustManager.java | 5 +- .../gravit/launcher/CommandHandlerTest.java | 4 +- .../pro/gravit/launcher/SerializeTest.java | 4 +- .../gravit/launcher/impl/Test2Command.java | 2 +- .../gravit/launcher/server/ServerAgent.java | 4 +- .../gravit/launcher/server/ServerWrapper.java | 12 +- modules | 2 +- 139 files changed, 319 insertions(+), 454 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index ebe28e43..8a191169 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -27,6 +27,7 @@ import java.util.Set; import java.util.Timer; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Stream; import org.bouncycastle.crypto.util.PrivateKeyFactory; import org.bouncycastle.operator.OperatorCreationException; @@ -153,7 +154,7 @@ public void invoke(String... args) throws Exception { reload(ReloadType.NO_COMPONENTS); break; default: - reload(ReloadType.FULL);; + reload(ReloadType.FULL); break; } } @@ -163,7 +164,7 @@ public void invoke(String... args) throws Exception { } - private final class ProfilesFileVisitor extends SimpleFileVisitor { + private static final class ProfilesFileVisitor extends SimpleFileVisitor { private final Collection result; private ProfilesFileVisitor(Collection result) { @@ -215,7 +216,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO // Server config public LaunchServerConfig config; - public LaunchServerRuntimeConfig runtime; + public final LaunchServerRuntimeConfig runtime; public final ECPublicKey publicKey; @@ -225,7 +226,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO public final JARLauncherBinary launcherBinary; - public Class launcherEXEBinaryClass; + public final Class launcherEXEBinaryClass; public final LauncherBinary launcherEXEBinary; // HWID ban + anti-brutforce @@ -263,7 +264,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO public final Timer taskPool; - public static Class defaultLauncherEXEBinaryClass = null; + public static final Class defaultLauncherEXEBinaryClass = null; public static class LaunchServerDirectories { @@ -402,10 +403,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La Files.createDirectory(profilesDir); syncProfilesDir(); - if (config.netty != null) - nettyServerSocketHandler = new NettyServerSocketHandler(this); - else - nettyServerSocketHandler = null; + nettyServerSocketHandler = new NettyServerSocketHandler(this); // post init modules modulesManager.invokeEvent(new LaunchServerPostInitPhase(this)); if (config.components != null) { @@ -548,7 +546,7 @@ public void syncUpdatesDir(Collection dirs) throws IOException { // Resolve name and verify is dir String name = IOHelper.getFileName(updateDir); if (!IOHelper.isDir(updateDir)) { - if (!IOHelper.isFile(updateDir) && Arrays.asList(".jar", ".exe", ".hash").stream().noneMatch(e -> updateDir.toString().endsWith(e))) + if (!IOHelper.isFile(updateDir) && Stream.of(".jar", ".exe", ".hash").noneMatch(e -> updateDir.toString().endsWith(e))) LogHelper.warning("Not update dir: '%s'", name); continue; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index e9619c7d..64397a3c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -43,7 +43,7 @@ import pro.gravit.utils.verify.LauncherTrustManager; public class LaunchServerStarter { - public static boolean allowUnsigned = Boolean.getBoolean("launchserver.allowUnsigned"); + public static final boolean allowUnsigned = Boolean.getBoolean("launchserver.allowUnsigned"); public static void main(String[] args) throws Exception { JVMHelper.checkStackTrace(LaunchServerStarter.class); JVMHelper.verifySystemProperties(LaunchServer.class, true); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java index 976bfb6d..52eed8b8 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ClassMetadataReader.java @@ -19,7 +19,7 @@ * чего угодно. Работает через поиск class-файлов в classpath. */ public class ClassMetadataReader implements Closeable { - private class CheckSuperClassVisitor extends ClassVisitor { + private static class CheckSuperClassVisitor extends ClassVisitor { String superClassName; @@ -108,7 +108,7 @@ public ArrayList getSuperClasses(String type) { @Override public void close() { - cp.stream().forEach(IOHelper::close); + cp.forEach(IOHelper::close); cp.clear(); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java index d70e022f..7e38da78 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java @@ -8,12 +8,12 @@ import pro.gravit.launchserver.auth.texture.TextureProvider; public class AuthProviderPair { - public AuthProvider provider; - public AuthHandler handler; - public TextureProvider textureProvider; - public String name; + public final AuthProvider provider; + public final AuthHandler handler; + public final TextureProvider textureProvider; + public final String name; public String displayName; - public boolean isDefault = true; + public final boolean isDefault = true; public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvider textureProvider, String name) { this.provider = provider; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/AuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/AuthHandler.java index 5845b80f..840d8a3e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/AuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/AuthHandler.java @@ -10,7 +10,7 @@ public abstract class AuthHandler implements AutoCloseable { - public static ProviderMap providers = new ProviderMap<>("AuthHandler"); + public static final ProviderMap providers = new ProviderMap<>("AuthHandler"); private static boolean registredHandl = false; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/CachedAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/CachedAuthHandler.java index 1639727a..4197360e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/CachedAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/CachedAuthHandler.java @@ -38,7 +38,7 @@ public Entry(UUID uuid, String username, String accessToken, String serverID) { } } - protected class EntryAndUsername { + protected static class EntryAndUsername { public Map entryCache; public Map usernameCache; } @@ -48,7 +48,7 @@ public Map getCommands() { Map commands = new HashMap<>(); commands.put("clear", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { long entryCacheSize = entryCache.size(); long usernamesCacheSize = usernamesCache.size(); entryCache.clear(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java index 883807e9..c165f78a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java @@ -7,21 +7,21 @@ public class HibernateAuthHandler extends CachedAuthHandler { @Override - protected Entry fetchEntry(String username) throws IOException { + protected Entry fetchEntry(String username) { User user = srv.config.dao.userService.findUserByUsername(username); if(user == null) return null; return new Entry(user.uuid, username, user.getAccessToken(), user.serverID); } @Override - protected Entry fetchEntry(UUID uuid) throws IOException { + protected Entry fetchEntry(UUID uuid) { User user = srv.config.dao.userService.findUserByUUID(uuid); if(user == null) return null; return new Entry(user.uuid, user.username, user.getAccessToken(), user.serverID); } @Override - protected boolean updateAuth(UUID uuid, String username, String accessToken) throws IOException { + protected boolean updateAuth(UUID uuid, String username, String accessToken) { User user = srv.config.dao.userService.findUserByUUID(uuid); user.setAccessToken(accessToken); srv.config.dao.userService.updateUser(user); @@ -29,7 +29,7 @@ protected boolean updateAuth(UUID uuid, String username, String accessToken) thr } @Override - protected boolean updateServerID(UUID uuid, String serverID) throws IOException { + protected boolean updateServerID(UUID uuid, String serverID) { User user = srv.config.dao.userService.findUserByUUID(uuid); user.serverID = serverID; srv.config.dao.userService.updateUser(user); @@ -37,7 +37,7 @@ protected boolean updateServerID(UUID uuid, String serverID) throws IOException } @Override - public void close() throws IOException { + public void close() { } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/JsonAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/JsonAuthHandler.java index 51cfc916..9ab78a41 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/JsonAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/JsonAuthHandler.java @@ -12,26 +12,26 @@ public class JsonAuthHandler extends CachedAuthHandler { public URL updateAuthUrl; public URL updateServerIdUrl; - public class EntryRequestByUsername { - public String username; + public static class EntryRequestByUsername { + public final String username; public EntryRequestByUsername(String username) { this.username = username; } } - public class EntryRequestByUUID { - public UUID uuid; + public static class EntryRequestByUUID { + public final UUID uuid; public EntryRequestByUUID(UUID uuid) { this.uuid = uuid; } } - public class UpdateAuthRequest { - public UUID uuid; - public String username; - public String accessToken; + public static class UpdateAuthRequest { + public final UUID uuid; + public final String username; + public final String accessToken; public UpdateAuthRequest(UUID uuid, String username, String accessToken) { this.uuid = uuid; @@ -40,9 +40,9 @@ public UpdateAuthRequest(UUID uuid, String username, String accessToken) { } } - public class UpdateServerIDRequest { - public UUID uuid; - public String serverID; + public static class UpdateServerIDRequest { + public final UUID uuid; + public final String serverID; public UpdateServerIDRequest(UUID uuid, String serverID) { this.uuid = uuid; @@ -50,7 +50,7 @@ public UpdateServerIDRequest(UUID uuid, String serverID) { } } - public class SuccessResponse { + public static class SuccessResponse { public boolean success; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/RequestAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/RequestAuthHandler.java index 2b7bfa47..c6812693 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/RequestAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/RequestAuthHandler.java @@ -16,8 +16,8 @@ public final class RequestAuthHandler extends CachedAuthHandler { private String updateAuth; private String updateServerID; - private String splitSymbol = ":"; - private String goodResponse = "OK"; + private final String splitSymbol = ":"; + private final String goodResponse = "OK"; @Override public void init(LaunchServer srv) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java index ae25e41c..b0754c1f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/HWIDHandler.java @@ -12,7 +12,7 @@ import pro.gravit.utils.helper.LogHelper; public abstract class HWIDHandler implements AutoCloseable, Reconfigurable { - public static ProviderMap providers = new ProviderMap<>("HWIDHandler"); + public static final ProviderMap providers = new ProviderMap<>("HWIDHandler"); private static boolean registredHandl = false; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java index d48868e5..ff831846 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonFileHWIDHandler.java @@ -18,8 +18,8 @@ import pro.gravit.utils.helper.LogHelper; public class JsonFileHWIDHandler extends HWIDHandler { - public class Entry { - public HWID hwid; + public static class Entry { + public final HWID hwid; public String username; public boolean isBanned = false; @@ -41,15 +41,18 @@ public int hashCode() { } } - public String filename = "hwids.json"; + public final String filename = "hwids.json"; public transient LinkedList list = new LinkedList<>(); - public String banMessage = "You banned"; + public final String banMessage = "You banned"; @Override public void ban(List hwid) { for (Entry e : list) { for (HWID banHWID : hwid) { - if (e.hwid.equals(banHWID)) e.isBanned = true; + if (e.hwid.equals(banHWID)) { + e.isBanned = true; + break; + } } } } @@ -101,7 +104,10 @@ public List getHwid(String username) { public void unban(List hwid) { for (Entry e : list) { for (HWID banHWID : hwid) { - if (e.hwid.equals(banHWID)) e.isBanned = false; + if (e.hwid.equals(banHWID)) { + e.isBanned = false; + break; + } } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java index 8bbcb277..abba10c6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/JsonHWIDHandler.java @@ -23,12 +23,12 @@ public final class JsonHWIDHandler extends HWIDHandler { private URL urlGet; private String apiKey; - public class banRequest { + public static class banRequest { public banRequest(OshiHWID hwid) { this.hwid = hwid; } - OshiHWID hwid; + final OshiHWID hwid; String apiKey; public banRequest(OshiHWID hwid, String apiKey) { @@ -37,14 +37,14 @@ public banRequest(OshiHWID hwid, String apiKey) { } } - public class checkRequest { + public static class checkRequest { public checkRequest(String username, OshiHWID hwid) { this.username = username; this.hwid = hwid; } - String username; - OshiHWID hwid; + final String username; + final OshiHWID hwid; String apiKey; public checkRequest(String username, OshiHWID hwid, String apiKey) { @@ -54,21 +54,21 @@ public checkRequest(String username, OshiHWID hwid, String apiKey) { } } - public class Result { + public static class Result { String error; } - public class BannedResult { + public static class BannedResult { boolean isBanned; String error; } - public class HWIDRequest { + public static class HWIDRequest { public HWIDRequest(String username) { this.username = username; } - String username; + final String username; String apiKey; public HWIDRequest(String username, String apiKey) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java index 21a719b7..16ed445b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MemoryHWIDHandler.java @@ -7,8 +7,8 @@ import pro.gravit.launcher.hwid.HWID; public class MemoryHWIDHandler extends HWIDHandler { - public class Entry { - public HWID hwid; + public static class Entry { + public final HWID hwid; public String username; public boolean isBanned = false; @@ -30,14 +30,17 @@ public int hashCode() { } } - public transient LinkedList list = new LinkedList<>(); - public String banMessage = "You banned"; + public final transient LinkedList list = new LinkedList<>(); + public final String banMessage = "You banned"; @Override public void ban(List hwid) { for (Entry e : list) { for (HWID banHWID : hwid) { - if (e.hwid.equals(banHWID)) e.isBanned = true; + if (e.hwid.equals(banHWID)) { + e.isBanned = true; + break; + } } } } @@ -79,7 +82,10 @@ public List getHwid(String username) { public void unban(List hwid) { for (Entry e : list) { for (HWID banHWID : hwid) { - if (e.hwid.equals(banHWID)) e.isBanned = false; + if (e.hwid.equals(banHWID)) { + e.isBanned = false; + break; + } } } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java index 7c5d6e06..3b9b63d4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/hwid/MysqlHWIDHandler.java @@ -37,10 +37,10 @@ public class MysqlHWIDHandler extends HWIDHandler { private String banMessage; - private boolean compareMode = false; + private final boolean compareMode = false; //Using queryHWID "queryHwids": "SELECT * FROM `users_hwids` WHERE `totalMemory` = ? or `serialNumber` = ? or `HWDiskSerial` = ? or `processorID` = ? or `MACAddr` = ?" - private int compare = 50; //При наборе схожести в 50 очков - private boolean oneCompareMode = false; + private final int compare = 50; //При наборе схожести в 50 очков + private final boolean oneCompareMode = false; /* //Добавить поля hwid в базу с пользователями @@ -151,7 +151,7 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI db_hwid.serialNumber = set.getString(hwidFieldSerialNumber); db_hwid.processorID = set.getString(hwidFieldProcessorID); db_hwid.HWDiskSerial = set.getString(hwidFieldHWDiskSerial); - db_hwid.totalMemory = Long.valueOf(set.getString(hwidFieldTotalMemory)); + db_hwid.totalMemory = Long.parseLong(set.getString(hwidFieldTotalMemory)); db_hwid.macAddr = set.getString(hwidFieldMAC); if (LogHelper.isDevEnabled()) { LogHelper.dev("Compare HWID: %s vs %s", hwid.toString(), db_hwid.toString()); @@ -238,7 +238,7 @@ public List getHwid(String username) { ResultSet rs = s.executeQuery(); if (rs.next()) { OshiHWID oshiHWID = new OshiHWID(); - oshiHWID.totalMemory = Long.valueOf(rs.getString(hwidFieldTotalMemory)); + oshiHWID.totalMemory = Long.parseLong(rs.getString(hwidFieldTotalMemory)); oshiHWID.serialNumber = rs.getString(hwidFieldSerialNumber); oshiHWID.HWDiskSerial = rs.getString(hwidFieldHWDiskSerial); oshiHWID.processorID = rs.getString(hwidFieldProcessorID); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java index 8b892f85..c5b1772e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/ConfigPermissionsHandler.java @@ -3,8 +3,8 @@ import pro.gravit.launcher.ClientPermissions; public class ConfigPermissionsHandler extends PermissionsHandler { - public boolean isAdmin = false; - public boolean isServer = false; + public final boolean isAdmin = false; + public final boolean isServer = false; @Override public ClientPermissions getPermissions(String username) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java index 2e1be761..a49d8755 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/HibernatePermissionsHandler.java @@ -21,7 +21,7 @@ public void setPermissions(String username, ClientPermissions permissions) { } @Override - public void close() throws Exception { + public void close() { } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java index fc779fb3..71702349 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonFilePermissionsHandler.java @@ -21,7 +21,7 @@ import pro.gravit.utils.helper.LogHelper; public class JsonFilePermissionsHandler extends PermissionsHandler implements Reconfigurable { - public String filename = "permissions.json"; + public final String filename = "permissions.json"; public static Map map; @@ -47,14 +47,14 @@ public Map getCommands() { Map commands = new HashMap<>(); SubCommand reload = new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { reload(); } }; commands.put("reload", reload); commands.put("save", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { Path path = Paths.get(filename); if (!IOHelper.exists(path)) { try (Writer writer = IOHelper.newWriter(path)) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java index 1649303c..c9dbae21 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/JsonLongFilePermissionsHandler.java @@ -21,8 +21,8 @@ import pro.gravit.utils.helper.LogHelper; public class JsonLongFilePermissionsHandler extends PermissionsHandler implements Reconfigurable { - public String filename = "permissions.json"; - public long defaultPerms = 0L; + public final String filename = "permissions.json"; + public final long defaultPerms = 0L; public static Map map; @@ -48,14 +48,14 @@ public Map getCommands() { Map commands = new HashMap<>(); SubCommand reload = new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { reload(); } }; commands.put("reload", reload); commands.put("save", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { Path path = Paths.get(filename); if (!IOHelper.exists(path)) { try (Writer writer = IOHelper.newWriter(path)) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/PermissionsHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/PermissionsHandler.java index 9062da26..73fe7968 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/PermissionsHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/permissions/PermissionsHandler.java @@ -5,7 +5,7 @@ import pro.gravit.utils.ProviderMap; public abstract class PermissionsHandler implements AutoCloseable { - public static ProviderMap providers = new ProviderMap<>("PermissionsHandler"); + public static final ProviderMap providers = new ProviderMap<>("PermissionsHandler"); protected transient LaunchServer srv; private static boolean registredHandl = false; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java index 9cd5a200..5707c281 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java @@ -4,7 +4,7 @@ import pro.gravit.utils.ProviderMap; public abstract class ProtectHandler { - public static ProviderMap providers = new ProviderMap<>("ProtectHandler"); + public static final ProviderMap providers = new ProviderMap<>("ProtectHandler"); private static boolean registredHandl = false; 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 1c197296..acee9429 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 @@ -4,7 +4,7 @@ import pro.gravit.utils.helper.SecurityHelper; public class StdProtectHandler extends ProtectHandler { - public boolean checkSecure = true; + public final boolean checkSecure = true; @Override public String generateSecureToken(AuthResponse.AuthContext context) { return SecurityHelper.randomStringToken(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java index aeb7abf3..b10cef06 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java @@ -8,7 +8,7 @@ import pro.gravit.utils.ProviderMap; public abstract class AuthProvider implements AutoCloseable { - public static ProviderMap providers = new ProviderMap<>("AuthProvider"); + public static final ProviderMap providers = new ProviderMap<>("AuthProvider"); private static boolean registredProv = false; protected transient LaunchServer srv = null; public static AuthProviderResult authError(String message) throws AuthException { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java index 7f696a0d..14102dff 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java @@ -36,7 +36,7 @@ public AuthProviderResult auth(String login, AuthRequest.AuthPasswordInterface p } @Override - public void close() throws IOException { + public void close() { } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java index cb509465..be1064f5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/JsonAuthProvider.java @@ -14,17 +14,17 @@ import pro.gravit.utils.helper.SecurityHelper; public final class JsonAuthProvider extends AuthProvider { - private static Gson gson = new Gson(); + private static final Gson gson = new Gson(); private URL url; private String apiKey; - public class authResult { + public static class authResult { String username; String error; long permissions; } - public class authRequest { + public static class authRequest { public authRequest(String username, String password, String ip) { this.username = username; this.password = password; @@ -38,9 +38,9 @@ public authRequest(String username, String password, String ip, String apiKey) { this.apiKey = apiKey; } - String username; - String password; - String ip; + final String username; + final String password; + final String ip; String apiKey; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java index 1d2874a9..2c9e50e5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/RejectAuthProvider.java @@ -45,7 +45,7 @@ public Map getCommands() { Map commands = new HashMap<>(); commands.put("message", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { message = args[0]; LogHelper.info("New reject message: %s", message); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/TextureProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/TextureProvider.java index 96a20bc1..c0c037a2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/TextureProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/TextureProvider.java @@ -7,7 +7,7 @@ import pro.gravit.utils.ProviderMap; public abstract class TextureProvider implements AutoCloseable { - public static ProviderMap providers = new ProviderMap<>("TextureProvider"); + public static final ProviderMap providers = new ProviderMap<>("TextureProvider"); private static boolean registredProv = false; public static void registerProviders() { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/EXEL4JLauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/EXEL4JLauncherBinary.java index bba780f3..9570404c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/EXEL4JLauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/EXEL4JLauncherBinary.java @@ -114,8 +114,8 @@ private void setConfig() { ConfigPersister.getInstance().setAntConfig(config, null); } - private static String VERSION = Version.getVersion().getVersionString(); - private static int BUILD = Version.getVersion().build; + private static final String VERSION = Version.getVersion().getVersionString(); + private static final int BUILD = Version.getVersion().build; public static String formatVars(String mask) { return String.format(mask, VERSION, BUILD); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java index 724bcb16..0c20f5c7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java @@ -25,9 +25,9 @@ public final class JARLauncherBinary extends LauncherBinary { public final Path runtimeDir; public final Path guardDir; public final Path buildDir; - public List tasks; - public List coreLibs; - public List addonLibs; + public final List tasks; + public final List coreLibs; + public final List addonLibs; public JARLauncherBinary(LaunchServer server) throws IOException { super(server, resolve(server, ".jar")); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java index 006c9fb0..83a6db4b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/SimpleEXELauncherBinary.java @@ -9,7 +9,7 @@ import pro.gravit.utils.helper.LogHelper; public class SimpleEXELauncherBinary extends LauncherBinary { - public Path exeTemplate; + public final Path exeTemplate; public SimpleEXELauncherBinary(LaunchServer server) { super(server, LauncherBinary.resolve(server, ".exe")); exeTemplate = server.dir.resolve("SimpleTemplate.exe"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java index c0664aca..6ef93227 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/dao/GetAllUsersCommand.java @@ -21,7 +21,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { int count = 0; for(User user : server.config.dao.userService.findAllUsers()) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/IndexAssetCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/IndexAssetCommand.java index 1e8404ee..40545c66 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/IndexAssetCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/IndexAssetCommand.java @@ -21,17 +21,17 @@ import pro.gravit.utils.helper.SecurityHelper.DigestAlgorithm; public final class IndexAssetCommand extends Command { - private static Gson gson = new Gson(); + private static final Gson gson = new Gson(); public static class IndexObject { - long size; + final long size; public IndexObject(long size, String hash) { this.size = size; this.hash = hash; } - String hash; + final String hash; } private static final class IndexAssetVisitor extends SimpleFileVisitor { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/UnindexAssetCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/UnindexAssetCommand.java index 49839739..89ab3f2d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/UnindexAssetCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/UnindexAssetCommand.java @@ -17,7 +17,7 @@ import pro.gravit.utils.helper.LogHelper; public final class UnindexAssetCommand extends Command { - private static JsonParser parser = new JsonParser(); + private static final JsonParser parser = new JsonParser(); public UnindexAssetCommand(LaunchServer server) { super(server); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/CheckInstallCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/CheckInstallCommand.java index 31d7a992..44d085a6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/CheckInstallCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/CheckInstallCommand.java @@ -21,7 +21,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { LogHelper.info("Check install success"); JVMHelper.RUNTIME.exit(0); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/MultiCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/MultiCommand.java index c5ddcd48..396cbc8c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/MultiCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/install/MultiCommand.java @@ -19,7 +19,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { for (String arg : args) { server.commandHandler.eval(arg, false); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java index b373e7fd..49c0b5e7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ClientsCommand.java @@ -24,7 +24,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { WebSocketService service = server.nettyServerSocketHandler.nettyServer.service; service.channels.forEach((channel -> { WebSocketFrameHandler frameHandler = channel.pipeline().get(WebSocketFrameHandler.class); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GetModulusCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GetModulusCommand.java index dc2c3d82..f5e06ad4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GetModulusCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GetModulusCommand.java @@ -19,7 +19,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { //LogHelper.info("You publickey modulus: %s", server.publicKey.getModulus().toString(16)); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GivePermissionsCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GivePermissionsCommand.java index ebaa9615..6539617d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GivePermissionsCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/GivePermissionsCommand.java @@ -26,7 +26,7 @@ public void invoke(String... args) throws Exception { String username = args[0]; ClientPermissions permissions = server.config.permissionsHandler.getPermissions(username); String permission = args[1]; - boolean isEnabled = Boolean.valueOf(args[2]); + boolean isEnabled = Boolean.parseBoolean(args[2]); switch (permission) { case "admin": { permissions.canAdmin = isEnabled; 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 44742e0b..399f9927 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AbstractLimiter.java @@ -14,14 +14,14 @@ public abstract class AbstractLimiter extends Component implements NeedGarbageCollection, Reconfigurable { public int rateLimit; public int rateLimitMillis; - public List exclude = new ArrayList<>(); + public final List exclude = new ArrayList<>(); @Override public Map getCommands() { Map commands = new HashMap<>(); commands.put("gc", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { long size = map.size(); garbageCollection(); LogHelper.info("Cleared %d entity", size); @@ -29,7 +29,7 @@ public void invoke(String... args) throws Exception { }); commands.put("clear", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { long size = map.size(); map.clear(); LogHelper.info("Cleared %d entity", size); @@ -51,7 +51,7 @@ public void invoke(String... args) throws Exception { }); commands.put("clearExclude", new SubCommand() { @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { exclude.clear(); } }); @@ -67,7 +67,7 @@ public void garbageCollection() { map.entrySet().removeIf((e) -> e.getValue().time + rateLimitMillis < time); } - class LimitEntry + static class LimitEntry { long time; int trys; @@ -82,7 +82,7 @@ public LimitEntry() { trys = 0; } } - protected transient Map map = new HashMap<>(); + protected final transient Map map = new HashMap<>(); public boolean check(T address) { if(exclude.contains(address)) return true; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java index 5b01de0e..23f78c1b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/AuthLimiterComponent.java @@ -32,7 +32,7 @@ public boolean preAuthHook(AuthResponse.AuthContext context, Client client) { public String message; @Override - public void close() throws Exception { + public void close() { srv.authHookManager.preHook.unregisterHook(this::preAuthHook); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/CommandRemoverComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/CommandRemoverComponent.java index 3332444e..a2c31bb5 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/CommandRemoverComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/CommandRemoverComponent.java @@ -7,8 +7,8 @@ import pro.gravit.utils.command.Command; public class CommandRemoverComponent extends Component implements AutoCloseable { - public String[] removeList = new String[]{}; - public transient Map commandsList = new HashMap<>(); + public final String[] removeList = new String[]{}; + public final transient Map commandsList = new HashMap<>(); private transient LaunchServer server = null; @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java index b4789057..e1d61b26 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/Component.java @@ -4,7 +4,7 @@ import pro.gravit.utils.ProviderMap; public abstract class Component { - public static ProviderMap providers = new ProviderMap<>(); + public static final ProviderMap providers = new ProviderMap<>(); private static boolean registredComp = false; public static void registerComponents() { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java index 4fbdd053..6840041a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/RegLimiterComponent.java @@ -39,7 +39,7 @@ public boolean registerHook(AuthHookManager.RegContext context) } @Override - public void close() throws Exception { + public void close() { launchServer.authHookManager.registraion.unregisterHook(this::registerHook); } } 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 7f7e01f5..85e1be7e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -44,7 +44,7 @@ public LaunchServerConfig setLaunchServer(LaunchServer server) { public String binaryName; - public boolean copyBinaries = true; + public final boolean copyBinaries = true; public LauncherConfig.LauncherEnvironment env; @@ -75,7 +75,7 @@ public AuthProviderPair getAuthProviderPair() { return pair; } } - return null; + throw new IllegalStateException("Default AuthProviderPair not found"); } public HWIDHandler hwidHandler; @@ -146,16 +146,13 @@ public void init(LaunchServer.ReloadType type) { } if(components != null) { - components.forEach((k,v) -> { - server.registerObject("component.".concat(k), v); - }); + components.forEach((k,v) -> server.registerObject("component.".concat(k), v)); } server.registerObject("permissionsHandler", permissionsHandler); server.registerObject("hwidHandler", hwidHandler); if(!type.equals(LaunchServer.ReloadType.NO_AUTH)) { - for (int i = 0; i < auth.length; ++i) { - AuthProviderPair pair = auth[i]; + for (AuthProviderPair pair : auth) { server.registerObject("auth.".concat(pair.name).concat(".provider"), pair.provider); server.registerObject("auth.".concat(pair.name).concat(".handler"), pair.handler); server.registerObject("auth.".concat(pair.name).concat(".texture"), pair.textureProvider); @@ -258,10 +255,10 @@ public static class NettyConfig { public String downloadURL; public String launcherEXEURL; public String address; - public Map bindings = new HashMap<>(); + public final Map bindings = new HashMap<>(); public NettyPerformanceConfig performance; public NettyBindAddress[] binds; - public LogLevel logLevel = LogLevel.DEBUG; + public final LogLevel logLevel = LogLevel.DEBUG; } public static class NettyPerformanceConfig { @@ -271,8 +268,8 @@ public static class NettyPerformanceConfig { } public static class NettyBindAddress { - public String address; - public int port; + public final String address; + public final int port; public NettyBindAddress(String address, int port) { this.address = address; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java index a68298bc..49561182 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/UserHWID.java @@ -14,7 +14,7 @@ @Entity @Table(name = "users_hwids") public class UserHWID implements HWID { - private transient Supplier oshiSupp = () -> { + private final transient Supplier oshiSupp = () -> { OshiHWID hwid = new OshiHWID(); hwid.HWDiskSerial = this.HWDiskSerial; hwid.macAddr = this.macAddr; @@ -28,7 +28,7 @@ public class UserHWID implements HWID { @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; - public long totalMemory = 0; + public final long totalMemory = 0; public String serialNumber; public String HWDiskSerial; public String processorID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java index ab5586cd..5bd61018 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/dao/provider/DaoProvider.java @@ -6,7 +6,7 @@ import pro.gravit.utils.ProviderMap; public abstract class DaoProvider { - public static ProviderMap providers = new ProviderMap<>("DaoProvider"); + public static final ProviderMap providers = new ProviderMap<>("DaoProvider"); public UserDAO userDAO; public UserService userService; public static void registerProviders() diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java index 69b76a4a..1987163a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/CertificateManager.java @@ -57,8 +57,8 @@ public class CertificateManager { public LauncherTrustManager trustManager; - public int validDays = 60; - public int minusHours = 6; + public final int validDays = 60; + public final int minusHours = 6; public String orgName; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/MirrorManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/MirrorManager.java index 592a5fc6..d52684e2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/MirrorManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/MirrorManager.java @@ -15,7 +15,7 @@ public class MirrorManager { public static class Mirror { - String baseUrl; + final String baseUrl; boolean enabled; Mirror(String url) { @@ -34,7 +34,7 @@ public URL getURL(String mask, Object... args) throws MalformedURLException { } } - protected ArrayList list = new ArrayList<>(); + protected final ArrayList list = new ArrayList<>(); private Mirror defaultMirror; public void addMirror(String mirror) { @@ -44,7 +44,7 @@ public void addMirror(String mirror) { list.add(m); } - public void addMirror(String mirror, boolean enabled) throws MalformedURLException { + public void addMirror(String mirror, boolean enabled) { Mirror m = new Mirror(mirror); m.enabled = enabled; if (defaultMirror == null && enabled) defaultMirror = m; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java index a949847e..f0cbd9fd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/ReconfigurableManager.java @@ -10,7 +10,7 @@ import pro.gravit.utils.helper.VerifyHelper; public class ReconfigurableManager { - private class ReconfigurableVirtualCommand extends Command { + private static class ReconfigurableVirtualCommand extends Command { public ReconfigurableVirtualCommand(Map childs) { super(childs); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java index 8e25b32f..f8d8b395 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/SessionManager.java @@ -14,7 +14,7 @@ public class SessionManager implements NeedGarbageCollection { public static final long SESSION_TIMEOUT = 3 * 60 * 60 * 1000; // 3 часа public static final boolean GARBAGE_SERVER = Boolean.parseBoolean(System.getProperty("launcher.garbageSessionsServer", "false")); - private Map clientSet = new HashMap<>(128); + private final Map clientSet = new HashMap<>(128); public boolean addClient(Client client) { 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 739d4eda..65a09dab 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 @@ -9,17 +9,17 @@ import pro.gravit.utils.HookSet; public class AuthHookManager { - public BiHookSet preHook = new BiHookSet<>(); - public BiHookSet postHook = new BiHookSet<>(); - public BiHookSet checkServerHook = new BiHookSet<>(); - public BiHookSet joinServerHook = new BiHookSet<>(); - public BiHookSet setProfileHook = new BiHookSet<>(); + public final BiHookSet preHook = new BiHookSet<>(); + public final BiHookSet postHook = new BiHookSet<>(); + public final BiHookSet checkServerHook = new BiHookSet<>(); + public final BiHookSet joinServerHook = new BiHookSet<>(); + public final BiHookSet setProfileHook = new BiHookSet<>(); public static class RegContext { - public String login; - public String password; - public String ip; - public boolean trustContext; + public final String login; + public final String password; + public final String ip; + public final boolean trustContext; public RegContext(String login, String password, String ip, boolean trustContext) { this.login = login; this.password = password; @@ -27,5 +27,5 @@ public RegContext(String login, String password, String ip, boolean trustContext this.trustContext = trustContext; } } - public HookSet registraion = new HookSet<>(); + public final HookSet registraion = new HookSet<>(); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java index aeb68e84..c63e3b92 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerModulesManager.java @@ -11,7 +11,7 @@ import pro.gravit.utils.verify.LauncherTrustManager; public class LaunchServerModulesManager extends SimpleModuleManager { - public LaunchServerCoreModule coreModule; + public final LaunchServerCoreModule coreModule; public LaunchServerModulesManager(Path modulesDir, Path configDir, LauncherTrustManager trustManager) { super(modulesDir, configDir, trustManager); coreModule = new LaunchServerCoreModule(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java index 13e60a5d..b368953c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/Client.java @@ -10,7 +10,7 @@ public class Client { public long session; public String auth_id; public long timestamp; - public Type type; + public final Type type; public ClientProfile profile; public boolean isAuth; public boolean checkSign; 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 6749d352..0c4fc268 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -36,12 +36,12 @@ public class WebSocketService { public final ChannelGroup channels; - public static ProviderMap providers = new ProviderMap<>(); + public static final ProviderMap providers = new ProviderMap<>(); public static class WebSocketRequestContext { - public WebSocketServerResponse response; - public Client client; - public String ip; + public final WebSocketServerResponse response; + public final Client client; + public final String ip; public WebSocketRequestContext(WebSocketServerResponse response, Client client, String ip) { this.response = response; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java index ec74df6b..e1991e64 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyIpForwardHandler.java @@ -11,7 +11,7 @@ import pro.gravit.utils.helper.LogHelper; public class NettyIpForwardHandler extends MessageToMessageDecoder { - private NettyConnectContext context; + private final NettyConnectContext context; public NettyIpForwardHandler(NettyConnectContext context) { super(); @@ -19,7 +19,7 @@ public NettyIpForwardHandler(NettyConnectContext context) { } @Override - protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List out) { if (msg instanceof ReferenceCounted) { ((ReferenceCounted) msg).retain(); } 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 ff3e6b19..fd2f0695 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 @@ -88,11 +88,6 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr return; } - if (path == null) { - sendError(ctx, FORBIDDEN); - return; - } - File file = base.resolve(path).toFile(); if ((file.isHidden() && !showHiddenFiles) || !file.exists()) { sendError(ctx, NOT_FOUND); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java index 1a7ec741..5a54843c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/admin/AddLogListenerResponse.java @@ -7,7 +7,7 @@ import pro.gravit.utils.helper.LogHelper; public class AddLogListenerResponse extends SimpleResponse { - public LogHelper.OutputTypes outputType = LogHelper.OutputTypes.PLAIN; + public final LogHelper.OutputTypes outputType = LogHelper.OutputTypes.PLAIN; @Override public String getType() { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index 7d03fb55..896a6806 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -30,7 +30,7 @@ import pro.gravit.utils.helper.VerifyHelper; public class AuthResponse extends SimpleResponse { - public transient static Random random = new SecureRandom(); + public final transient static Random random = new SecureRandom(); public String login; public String client; public String customText; @@ -139,14 +139,14 @@ public AuthContext(Client client, String login, String customText, String profil this.ip = ip; this.authType = authType; } - public String login; + public final String login; @Deprecated public int password_length; //Use AuthProvider for get password - public String profileName; - public HWID hwid; - public String customText; - public String ip; - public ConnectTypes authType; - public Client client; + public final String profileName; + public final HWID hwid; + public final String customText; + public final String ip; + public final ConnectTypes authType; + public final Client client; } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java index 93f2fb26..c77758a4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/SetPasswordResponse.java @@ -16,7 +16,7 @@ public String getType() { } @Override - public void execute(ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) { if(( oldPassword == null && username == null ) || newPassword == null) { sendError("Request invalid"); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java index 9e8e58a2..ee1c5e8e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/profile/BatchProfileByUsername.java @@ -10,7 +10,7 @@ import pro.gravit.utils.helper.LogHelper; public class BatchProfileByUsername extends SimpleResponse { - class Entry { + static class Entry { String username; String client; } diff --git a/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java b/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java index 3b04e1b6..825ce546 100644 --- a/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java +++ b/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java @@ -49,22 +49,22 @@ public static void prepare() throws Exception .setCertificateManager(new CertificateManager()) .setLaunchServerConfigManager(new LaunchServer.LaunchServerConfigManager() { @Override - public LaunchServerConfig readConfig() throws IOException { + public LaunchServerConfig readConfig() { return null; } @Override - public LaunchServerRuntimeConfig readRuntimeConfig() throws IOException { + public LaunchServerRuntimeConfig readRuntimeConfig() { return null; } @Override - public void writeConfig(LaunchServerConfig config) throws IOException { + public void writeConfig(LaunchServerConfig config) { } @Override - public void writeRuntimeConfig(LaunchServerRuntimeConfig config) throws IOException { + public void writeRuntimeConfig(LaunchServerRuntimeConfig config) { } }) @@ -73,8 +73,7 @@ public void writeRuntimeConfig(LaunchServerRuntimeConfig config) throws IOExcept launchServer = builder.build(); } @Test - public void start() throws Exception - { + public void start() { launchServer.run(); } } diff --git a/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/ExitCommand.java b/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/ExitCommand.java index f9c84c04..01be5427 100644 --- a/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/ExitCommand.java +++ b/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/ExitCommand.java @@ -17,7 +17,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { System.exit(0); } } diff --git a/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java b/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java index 4de6d4ee..adef0b69 100644 --- a/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java +++ b/LaunchServerConsole/src/main/java/pro/gravit/launchserver/console/LogListenerCommand.java @@ -8,9 +8,9 @@ import pro.gravit.utils.helper.LogHelper; public class LogListenerCommand extends Command { - public class LogListenerRequest implements WebSocketRequest { + public static class LogListenerRequest implements WebSocketRequest { @LauncherNetworkAPI - public LogHelper.OutputTypes outputType; + public final LogHelper.OutputTypes outputType; public LogListenerRequest(LogHelper.OutputTypes outputType) { this.outputType = outputType; diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index aaeba1ec..e5b08c99 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -21,7 +21,7 @@ public class ClientLauncherWrapper { public static final String WAIT_PROCESS_PROPERTY = "launcher.waitProcess"; public static final String NO_JAVA9_CHECK_PROPERTY = "launcher.noJava9Check"; public static boolean waitProcess = Boolean.getBoolean(WAIT_PROCESS_PROPERTY); - public static boolean noJava9check = Boolean.getBoolean(NO_JAVA9_CHECK_PROPERTY); + public static final boolean noJava9check = Boolean.getBoolean(NO_JAVA9_CHECK_PROPERTY); public static void main(String[] arguments) throws IOException, InterruptedException { LogHelper.printVersion("Launcher"); diff --git a/Launcher/src/main/java/pro/gravit/launcher/NewLauncherSettings.java b/Launcher/src/main/java/pro/gravit/launcher/NewLauncherSettings.java index f8db286d..4947649d 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/NewLauncherSettings.java +++ b/Launcher/src/main/java/pro/gravit/launcher/NewLauncherSettings.java @@ -48,11 +48,11 @@ public class NewLauncherSettings { public static class HashedStoreEntry { @LauncherAPI - public HashedDir hdir; + public final HashedDir hdir; @LauncherAPI - public String name; + public final String name; @LauncherAPI - public String fullPath; + public final String fullPath; @LauncherAPI public transient boolean needSave = false; @@ -64,7 +64,7 @@ public HashedStoreEntry(HashedDir hdir, String name, String fullPath) { } @LauncherAPI - public transient List lastHDirs = new ArrayList<>(16); + public final transient List lastHDirs = new ArrayList<>(16); @LauncherAPI public void putHDir(String name, Path path, HashedDir dir) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index ea3a684b..64cfd348 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -596,12 +596,12 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, private ClientLauncher() { } - public static interface ParamsAPI { + public interface ParamsAPI { ParamContainer read() throws Exception; - void write(ParamContainer p) throws Exception; + void write(ParamContainer p); } - public static ParamsAPI container = new ParamsAPI() { + public static final ParamsAPI container = new ParamsAPI() { @Override public ParamContainer read() throws Exception { ParamContainer p; @@ -614,7 +614,7 @@ public ParamContainer read() throws Exception { return p; } @Override - public void write(ParamContainer p) throws Exception { + public void write(ParamContainer p) { setWriteParamsThread(CommonHelper.newThread("Client params writter", true, () -> { try { diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherContext.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherContext.java index 9865c312..84a96aa4 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherContext.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherContext.java @@ -9,7 +9,7 @@ public class ClientLauncherContext { public Path javaBin; - public List args = new LinkedList<>(); + public final List args = new LinkedList<>(); public String pathLauncher; public ProcessBuilder builder; public ClientProfile clientProfile; diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java index 1d5ba556..859c3644 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientModuleManager.java @@ -16,17 +16,17 @@ public ClientModuleManager() { } @Override - public void autoload() throws IOException { + public void autoload() { throw new UnsupportedOperationException(); } @Override - public void autoload(Path dir) throws IOException { + public void autoload(Path dir) { throw new UnsupportedOperationException(); } @Override - public LauncherModule loadModule(Path file) throws IOException { + public LauncherModule loadModule(Path file) { throw new UnsupportedOperationException(); } diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java index c6f9aefc..b6c19774 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/FunctionalBridge.java @@ -26,11 +26,11 @@ public class FunctionalBridge { @LauncherAPI - public static ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(0); + public static final ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(0); @LauncherAPI public static OshiHWIDProvider hwidProvider; @LauncherAPI - public static AtomicReference hwid = new AtomicReference<>(); + public static final AtomicReference hwid = new AtomicReference<>(); @LauncherAPI public static Thread getHWID = null; diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ServerPinger.java b/Launcher/src/main/java/pro/gravit/launcher/client/ServerPinger.java index 5a64e524..fc8ecd48 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ServerPinger.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ServerPinger.java @@ -22,7 +22,7 @@ import pro.gravit.utils.helper.VerifyHelper; public final class ServerPinger { - private JsonParser parser = new JsonParser(); + private final JsonParser parser = new JsonParser(); public static final class Result { @LauncherAPI diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/UserSettings.java b/Launcher/src/main/java/pro/gravit/launcher/client/UserSettings.java index 6504d459..1f6fb9b5 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/UserSettings.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/UserSettings.java @@ -3,5 +3,5 @@ import pro.gravit.utils.ProviderMap; public class UserSettings { - public static ProviderMap providers = new ProviderMap<>(); + public static final ProviderMap providers = new ProviderMap<>(); } diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/events/ClientPreGuiPhase.java b/Launcher/src/main/java/pro/gravit/launcher/client/events/ClientPreGuiPhase.java index ebbad380..b7077cdd 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/events/ClientPreGuiPhase.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/events/ClientPreGuiPhase.java @@ -4,7 +4,7 @@ import pro.gravit.launcher.modules.LauncherModule; public class ClientPreGuiPhase extends LauncherModule.Event { - public RuntimeProvider runtimeProvider; + public final RuntimeProvider runtimeProvider; public ClientPreGuiPhase(RuntimeProvider runtimeProvider) { this.runtimeProvider = runtimeProvider; diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/FeatureCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/FeatureCommand.java index 743ca647..78a27999 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/console/FeatureCommand.java +++ b/Launcher/src/main/java/pro/gravit/launcher/console/FeatureCommand.java @@ -18,7 +18,7 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { verifyArgs(args, 2); - boolean enabled = Boolean.valueOf(args[1]); + boolean enabled = Boolean.parseBoolean(args[1]); switch (args[0]) { case "store": { SettingsManager.settings.featureStore = enabled; diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java index 8610fa07..8e80354d 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java +++ b/Launcher/src/main/java/pro/gravit/launcher/console/admin/LogListenerCommand.java @@ -8,9 +8,9 @@ import pro.gravit.utils.helper.LogHelper; public class LogListenerCommand extends Command { - public class LogListenerRequest implements WebSocketRequest { + public static class LogListenerRequest implements WebSocketRequest { @LauncherNetworkAPI - public LogHelper.OutputTypes outputType; + public final LogHelper.OutputTypes outputType; public LogListenerRequest(LogHelper.OutputTypes outputType) { this.outputType = outputType; diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/store/CopyStoreDirCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/store/CopyStoreDirCommand.java index ebdc11a5..2f23c878 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/console/store/CopyStoreDirCommand.java +++ b/Launcher/src/main/java/pro/gravit/launcher/console/store/CopyStoreDirCommand.java @@ -24,8 +24,8 @@ public String getUsageDescription() { public void invoke(String... args) throws Exception { verifyArgs(args, 2); int ind = 1; - int index = Integer.valueOf(args[0]); - boolean overwrite = Boolean.valueOf(args[1]); + int index = Integer.parseInt(args[0]); + boolean overwrite = Boolean.parseBoolean(args[1]); for (NewLauncherSettings.HashedStoreEntry e : SettingsManager.settings.lastHDirs) { if (ind == index) { LogHelper.info("Copy [%d] FullPath: %s name: %s", ind, e.fullPath, e.name); diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/store/LinkStoreDirCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/store/LinkStoreDirCommand.java index ff915858..b2ab24b7 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/console/store/LinkStoreDirCommand.java +++ b/Launcher/src/main/java/pro/gravit/launcher/console/store/LinkStoreDirCommand.java @@ -25,7 +25,7 @@ public String getUsageDescription() { public void invoke(String... args) throws Exception { verifyArgs(args, 1); int ind = 1; - int index = Integer.valueOf(args[0]); + int index = Integer.parseInt(args[0]); for (NewLauncherSettings.HashedStoreEntry e : SettingsManager.settings.lastHDirs) { if (ind == index) { LogHelper.info("Copy [%d] FullPath: %s name: %s", ind, e.fullPath, e.name); diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/store/StoreListCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/store/StoreListCommand.java index be1bad46..3ed81fc7 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/console/store/StoreListCommand.java +++ b/Launcher/src/main/java/pro/gravit/launcher/console/store/StoreListCommand.java @@ -17,7 +17,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { int ind = 1; for (NewLauncherSettings.HashedStoreEntry e : SettingsManager.settings.lastHDirs) { LogHelper.info("[%d] FullPath: %s name: %s", ind, e.fullPath, e.name); diff --git a/Launcher/src/main/java/pro/gravit/launcher/gui/RuntimeProvider.java b/Launcher/src/main/java/pro/gravit/launcher/gui/RuntimeProvider.java index ab31d734..398b0886 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/gui/RuntimeProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/gui/RuntimeProvider.java @@ -5,5 +5,5 @@ public interface RuntimeProvider { void preLoad() throws Exception; - void init(boolean clientInstance) throws Exception; + void init(boolean clientInstance); } diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/ClientHookManager.java b/Launcher/src/main/java/pro/gravit/launcher/managers/ClientHookManager.java index 3758d281..c273a983 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/ClientHookManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/ClientHookManager.java @@ -8,13 +8,13 @@ import pro.gravit.utils.HookSet; public class ClientHookManager { - public static HookSet initGuiHook = new HookSet<>(); - public static HookSet paramsInputHook = new HookSet<>(); - public static HookSet paramsOutputHook = new HookSet<>(); + public static final HookSet initGuiHook = new HookSet<>(); + public static final HookSet paramsInputHook = new HookSet<>(); + public static final HookSet paramsOutputHook = new HookSet<>(); - public static HookSet clientLaunchHook = new HookSet<>(); - public static HookSet clientLaunchFinallyHook = new HookSet<>(); + public static final HookSet clientLaunchHook = new HookSet<>(); + public static final HookSet clientLaunchFinallyHook = new HookSet<>(); - public static BiHookSet preStartHook = new BiHookSet<>(); - public static BiHookSet postStartHook = new BiHookSet<>(); + public static final BiHookSet preStartHook = new BiHookSet<>(); + public static final BiHookSet postStartHook = new BiHookSet<>(); } diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/HasherStore.java b/Launcher/src/main/java/pro/gravit/launcher/managers/HasherStore.java index 348a4ad5..10b6f3e6 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/HasherStore.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/HasherStore.java @@ -18,7 +18,7 @@ public class HasherStore { public Map store; - public class HasherStoreEnity { + public static class HasherStoreEnity { @LauncherAPI public HashedDir hdir; @LauncherAPI diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/SettingsManager.java b/Launcher/src/main/java/pro/gravit/launcher/managers/SettingsManager.java index fcc5a95c..c2525be2 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/SettingsManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/SettingsManager.java @@ -19,7 +19,7 @@ import pro.gravit.utils.helper.LogHelper; public class SettingsManager extends JsonConfigurable { - public class StoreFileVisitor extends SimpleFileVisitor { + public static class StoreFileVisitor extends SimpleFileVisitor { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { diff --git a/Launcher/src/main/java/pro/gravit/launcher/patches/FMLPatcher.java b/Launcher/src/main/java/pro/gravit/launcher/patches/FMLPatcher.java index 0e060700..3fdf9ff5 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/patches/FMLPatcher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/patches/FMLPatcher.java @@ -33,7 +33,7 @@ public static void apply() { } } - public static void exit(final int code) throws Throwable { + public static void exit(final int code) { for (MethodHandle mh : MHS) try { mh.invoke(code); diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/NativeJVMHalt.java b/Launcher/src/main/java/pro/gravit/launcher/utils/NativeJVMHalt.java index d2d248a7..ef5a5083 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/utils/NativeJVMHalt.java +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/NativeJVMHalt.java @@ -14,7 +14,7 @@ public NativeJVMHalt(int haltCode) { System.out.println("JVM exit code " + haltCode); } - public int haltCode; + public final int haltCode; public native void aaabbb38C_D(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java index fc6bbe6e..f9aabbf1 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java @@ -13,11 +13,11 @@ public class ClientPermissions { @LauncherAPI public boolean canServer; @LauncherAPI - public boolean canUSR1; + public final boolean canUSR1; @LauncherAPI - public boolean canUSR2; + public final boolean canUSR2; @LauncherAPI - public boolean canUSR3; + public final boolean canUSR3; @LauncherAPI public boolean canBot; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java index b72e5cb9..a56ff76d 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java @@ -3,7 +3,7 @@ import java.nio.charset.StandardCharsets; public class SecureAutogenConfig { - public byte[][] certificates; + public final byte[][] certificates; public SecureAutogenConfig() { //Пока не реализован SecureLauncherConfigurator diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java index e81c258f..a9eeaa36 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/downloader/ListDownloader.java @@ -9,6 +9,7 @@ import java.net.URL; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; @@ -52,8 +53,8 @@ public interface DownloadTotalCallback { } public static class DownloadTask { - public String apply; - public long size; + public final String apply; + public final long size; public DownloadTask(String apply, long size) { this.apply = apply; @@ -65,7 +66,7 @@ public void download(String base, List applies, Path dstDirFile, D try (CloseableHttpClient httpclient = HttpClients.custom().setUserAgent(IOHelper.USER_AGENT) .setRedirectStrategy(new LaxRedirectStrategy()) .build()) { - applies.sort((a,b) -> Long.compare(a.size, b.size)); + applies.sort(Comparator.comparingLong(a -> a.size)); List> toExec = new ArrayList<>(); URI baseUri = new URI(base); String scheme = baseUri.getScheme(); @@ -106,7 +107,7 @@ public void download(String base, List applies, Path dstDirFile, D } } - public void downloadZip(String base, List applies, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback, boolean fullDownload) throws IOException, URISyntaxException { + public void downloadZip(String base, List applies, Path dstDirFile, DownloadCallback callback, DownloadTotalCallback totalCallback, boolean fullDownload) throws IOException { /*try (CloseableHttpClient httpclient = HttpClients.custom() .setRedirectStrategy(new LaxRedirectStrategy()) .build()) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java index 56253752..e83367f9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/ControlEvent.java @@ -15,5 +15,5 @@ public ControlEvent(ControlCommand signal) { this.signal = signal; } - public ControlCommand signal; + public final ControlCommand signal; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java index e759f3b6..eef9e7fd 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/SignalEvent.java @@ -5,7 +5,7 @@ //Используется, что бы послать короткое сообщение, которое вмещается в int public class SignalEvent { @LauncherNetworkAPI - public int signal; + public final int signal; public SignalEvent(int signal) { this.signal = signal; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ExecCommandRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ExecCommandRequestEvent.java index 988c2d5a..cdcfa4ff 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ExecCommandRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ExecCommandRequestEvent.java @@ -10,7 +10,7 @@ public String getType() { } @LauncherNetworkAPI - public boolean success; + public final boolean success; public ExecCommandRequestEvent(boolean success) { this.success = success; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java index 5af4000d..2a69291b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java @@ -8,9 +8,9 @@ public class GetAvailabilityAuthRequestEvent extends RequestEvent { public static class AuthAvailability { @LauncherNetworkAPI - public String name; + public final String name; @LauncherNetworkAPI - public String displayName; + public final String displayName; public AuthAvailability(String name, String displayName) { this.name = name; @@ -19,7 +19,7 @@ public AuthAvailability(String name, String displayName) { } @LauncherNetworkAPI - public List list; + public final List list; public GetAvailabilityAuthRequestEvent(List list) { this.list = list; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetSecureTokenRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetSecureTokenRequestEvent.java index d5741678..e221b76c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetSecureTokenRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetSecureTokenRequestEvent.java @@ -5,7 +5,7 @@ public class GetSecureTokenRequestEvent extends RequestEvent { @LauncherNetworkAPI - public String secureToken; + public final String secureToken; @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java index 59dbbbc9..4f9d15cb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/JoinServerRequestEvent.java @@ -15,7 +15,7 @@ public JoinServerRequestEvent(boolean allow) { } @LauncherNetworkAPI - public boolean allow; + public final boolean allow; @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java index db2f6f35..c93bddbc 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/LogEvent.java @@ -10,7 +10,7 @@ public String getType() { } @LauncherNetworkAPI - public String string; + public final String string; public LogEvent(String string) { this.string = string; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java index afad9278..84ceb288 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java @@ -13,7 +13,7 @@ public class ProfileByUsernameRequestEvent extends RequestEvent { @LauncherNetworkAPI public String error; @LauncherNetworkAPI - public PlayerProfile playerProfile; + public final PlayerProfile playerProfile; public ProfileByUsernameRequestEvent(PlayerProfile playerProfile) { this.playerProfile = playerProfile; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java index 98d090b1..ed6f8afe 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/SetProfileRequestEvent.java @@ -11,7 +11,7 @@ public class SetProfileRequestEvent extends RequestEvent { @SuppressWarnings("unused") private static final UUID uuid = UUID.fromString("08c0de9e-4364-4152-9066-8354a3a48541"); @LauncherNetworkAPI - public ClientProfile newProfile; + public final ClientProfile newProfile; public SetProfileRequestEvent(ClientProfile newProfile) { this.newProfile = newProfile; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java index 5f997795..ce917b3b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/UpdateRequestEvent.java @@ -6,11 +6,11 @@ public class UpdateRequestEvent extends RequestEvent { @LauncherNetworkAPI - public HashedDir hdir; + public final HashedDir hdir; @LauncherNetworkAPI public String url; @LauncherNetworkAPI - public boolean zip; + public final boolean zip; @LauncherNetworkAPI public boolean fullDownload; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java index 3f74c2d9..12a6e7bb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java @@ -5,7 +5,7 @@ public class VerifySecureTokenRequestEvent extends RequestEvent { @LauncherAPI - public boolean success; + public final boolean success; @Override public String getType() { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java index 0b924e73..28dd6db2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/hwid/HWIDProvider.java @@ -3,7 +3,7 @@ import pro.gravit.utils.ProviderMap; public class HWIDProvider { - public static ProviderMap hwids = new ProviderMap<>(); + public static final ProviderMap hwids = new ProviderMap<>(); public static void registerHWIDs() { hwids.register("oshi", OshiHWID.class); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/managers/SimpleModulesConfigManager.java b/LauncherAPI/src/main/java/pro/gravit/launcher/managers/SimpleModulesConfigManager.java index a5379675..0bea294b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/managers/SimpleModulesConfigManager.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/managers/SimpleModulesConfigManager.java @@ -10,7 +10,7 @@ import pro.gravit.utils.helper.LogHelper; public class SimpleModulesConfigManager implements ModulesConfigManager { - public Path configDir; + public final Path configDir; public SimpleModulesConfigManager(Path configDir) { this.configDir = configDir; 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 c6c15472..838cb1dd 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java @@ -7,7 +7,7 @@ public abstract class LauncherModule { private LauncherModulesContext context; @SuppressWarnings("rawtypes") - private Map, EventHandler> eventMap = new HashMap<>(); + private final Map, EventHandler> eventMap = new HashMap<>(); protected LauncherModulesManager modulesManager; protected final LauncherModuleInfo moduleInfo; protected ModulesConfigManager modulesConfigManager; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/events/PreGsonPhase.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/events/PreGsonPhase.java index 6e1acd11..25dcb4cb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/events/PreGsonPhase.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/events/PreGsonPhase.java @@ -5,7 +5,7 @@ import pro.gravit.launcher.modules.LauncherModule; public class PreGsonPhase extends LauncherModule.Event { - public GsonBuilder gsonBuilder; + public final GsonBuilder gsonBuilder; public PreGsonPhase(GsonBuilder gsonBuilder) { this.gsonBuilder = gsonBuilder; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java index 237a6a9e..fe15f5ac 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java @@ -42,7 +42,7 @@ public class SimpleModuleManager implements LauncherModulesManager { protected LauncherInitContext initContext; protected LauncherTrustManager.CheckMode checkMode = LauncherTrustManager.CheckMode.WARN_IN_NOT_SIGNED; - protected PublicURLClassLoader classLoader = new PublicURLClassLoader(new URL[]{}); + protected final PublicURLClassLoader classLoader = new PublicURLClassLoader(new URL[]{}); protected final class ModulesVisitor extends SimpleFileVisitor { private ModulesVisitor() { 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 3bb4c443..3e477c69 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -445,133 +445,5 @@ public void verify() { } } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((assetDir == null) ? 0 : assetDir.hashCode()); - result = prime * result + ((assetIndex == null) ? 0 : assetIndex.hashCode()); - result = prime * result + ((classPath == null) ? 0 : classPath.hashCode()); - result = prime * result + ((clientArgs == null) ? 0 : clientArgs.hashCode()); - result = prime * result + ((dir == null) ? 0 : dir.hashCode()); - result = prime * result + ((jvmArgs == null) ? 0 : jvmArgs.hashCode()); - result = prime * result + ((mainClass == null) ? 0 : mainClass.hashCode()); - result = prime * result + ((serverAddress == null) ? 0 : serverAddress.hashCode()); - result = prime * result + serverPort; - result = prime * result + sortIndex; - result = prime * result + ((title == null) ? 0 : title.hashCode()); - result = prime * result + ((info == null) ? 0 : info.hashCode()); - result = prime * result + ((update == null) ? 0 : update.hashCode()); - result = prime * result + ((updateExclusions == null) ? 0 : updateExclusions.hashCode()); - result = prime * result + (updateFastCheck ? 1231 : 1237); - result = prime * result + ((updateOptional == null) ? 0 : updateOptional.hashCode()); - result = prime * result + ((updateShared == null) ? 0 : updateShared.hashCode()); - result = prime * result + ((updateVerify == null) ? 0 : updateVerify.hashCode()); - result = prime * result + (useWhitelist ? 1231 : 1237); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - result = prime * result + ((whitelist == null) ? 0 : whitelist.hashCode()); - return result; - } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ClientProfile other = (ClientProfile) obj; - if (assetDir == null) { - if (other.assetDir != null) - return false; - } else if (!assetDir.equals(other.assetDir)) - return false; - if (assetIndex == null) { - if (other.assetIndex != null) - return false; - } else if (!assetIndex.equals(other.assetIndex)) - return false; - if (classPath == null) { - if (other.classPath != null) - return false; - } else if (!classPath.equals(other.classPath)) - return false; - if (clientArgs == null) { - if (other.clientArgs != null) - return false; - } else if (!clientArgs.equals(other.clientArgs)) - return false; - if (dir == null) { - if (other.dir != null) - return false; - } else if (!dir.equals(other.dir)) - return false; - if (jvmArgs == null) { - if (other.jvmArgs != null) - return false; - } else if (!jvmArgs.equals(other.jvmArgs)) - return false; - if (mainClass == null) { - if (other.mainClass != null) - return false; - } else if (!mainClass.equals(other.mainClass)) - return false; - if (serverAddress == null) { - if (other.serverAddress != null) - return false; - } else if (!serverAddress.equals(other.serverAddress)) - return false; - if (serverPort != other.serverPort) - return false; - if (sortIndex != other.sortIndex) - return false; - if (title == null) { - if (other.title != null) - return false; - } else if (!title.equals(other.title)) - return false; - if (info == null) { - if (other.info != null) - return false; - } else if (!info.equals(other.info)) - return false; - if (update == null) { - if (other.update != null) - return false; - } else if (!update.equals(other.update)) - return false; - if (updateExclusions == null) { - if (other.updateExclusions != null) - return false; - } else if (!updateExclusions.equals(other.updateExclusions)) - return false; - if (updateFastCheck != other.updateFastCheck) - return false; - if (updateOptional == null) { - if (other.updateOptional != null) - return false; - } else if (!updateOptional.equals(other.updateOptional)) - return false; - if (updateShared == null) { - if (other.updateShared != null) - return false; - } else if (!updateShared.equals(other.updateShared)) - return false; - if (updateVerify == null) { - if (other.updateVerify != null) - return false; - } else if (!updateVerify.equals(other.updateVerify)) - return false; - if (useWhitelist != other.useWhitelist) - return false; - if (version == null) { - if (other.version != null) - return false; - } else if (!version.equals(other.version)) - return false; - if (whitelist == null) { - return other.whitelist == null; - } else return whitelist.equals(other.whitelist); - } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java index 8dfffc8c..e949a1a7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/optional/OptionalFile.java @@ -17,7 +17,7 @@ public class OptionalFile { @LauncherAPI public boolean mark; @LauncherAPI - public boolean visible = true; + public final boolean visible = true; @LauncherAPI public String name; @LauncherAPI @@ -35,7 +35,7 @@ public class OptionalFile { @LauncherAPI public boolean isPreset; @LauncherAPI - public long permissions = 0L; + public final long permissions = 0L; @LauncherAPI public transient Set dependenciesCount; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java index cabe6414..b911b957 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/PingRequest.java @@ -5,7 +5,7 @@ public final class PingRequest extends Request { @Override - protected WebSocketEvent requestDo(StandartClientWebSocketService service) throws Exception { + protected WebSocketEvent requestDo(StandartClientWebSocketService service) { return null; } 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 5c8dd4e9..4b70c0a0 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/Request.java @@ -13,7 +13,7 @@ public abstract class Request implements WebSocketRequest { private static long session = SecurityHelper.secureRandom.nextLong(); @LauncherNetworkAPI - public UUID requestUUID = UUID.randomUUID(); + public final UUID requestUUID = UUID.randomUUID(); public static StandartClientWebSocketService service; public static void setSession(long session) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java index c3345f0b..802bd43b 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/admin/ExecCommandRequest.java @@ -7,7 +7,7 @@ public class ExecCommandRequest extends Request implements WebSocketRequest { @LauncherAPI - public String cmd; + public final String cmd; public ExecCommandRequest(String cmd) { this.cmd = cmd; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java index 868a39b2..e74c2e57 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java @@ -12,7 +12,7 @@ import pro.gravit.utils.helper.VerifyHelper; public final class AuthRequest extends Request implements WebSocketRequest { - public static ProviderMap providers = new ProviderMap<>(); + public static final ProviderMap providers = new ProviderMap<>(); public interface AuthPasswordInterface { boolean check(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java index 5e15bfbc..6be0e757 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/RestoreSessionRequest.java @@ -7,7 +7,7 @@ public class RestoreSessionRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI - public long session; + public final long session; public RestoreSessionRequest(long session) { this.session = session; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java index 0cc7d943..3c72b502 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/SetProfileRequest.java @@ -8,7 +8,7 @@ public class SetProfileRequest extends Request implements WebSocketRequest { @LauncherNetworkAPI - public String client; + public final String client; public SetProfileRequest(ClientProfile profile) { this.client = profile.getTitle(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java index 16273a2f..52072559 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/LauncherRequest.java @@ -24,9 +24,9 @@ public final class LauncherRequest extends Request impleme @LauncherNetworkAPI public byte[] digest; @LauncherNetworkAPI - public String secureHash; + public final String secureHash; @LauncherNetworkAPI - public String secureSalt; + public final String secureSalt; @LauncherNetworkAPI public int launcher_type = EXE_BINARY ? 2 : 1; @LauncherAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java index 7a45d41a..164cefdb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/update/UpdateRequest.java @@ -28,17 +28,17 @@ public final class UpdateRequest extends Request implements WebSocketRequest { public interface UpdateController { - void preUpdate(UpdateRequest request, UpdateRequestEvent e) throws IOException; + void preUpdate(UpdateRequest request, UpdateRequestEvent e); - void preDiff(UpdateRequest request, UpdateRequestEvent e) throws IOException; + void preDiff(UpdateRequest request, UpdateRequestEvent e); void postDiff(UpdateRequest request, UpdateRequestEvent e, HashedDir.Diff diff) throws IOException; - void preDownload(UpdateRequest request, UpdateRequestEvent e, List adds) throws IOException; + void preDownload(UpdateRequest request, UpdateRequestEvent e, List adds); - void postDownload(UpdateRequest request, UpdateRequestEvent e) throws IOException; + void postDownload(UpdateRequest request, UpdateRequestEvent e); - void postUpdate(UpdateRequest request, UpdateRequestEvent e) throws IOException; + void postUpdate(UpdateRequest request, UpdateRequestEvent e); } private static UpdateController controller; 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 e304e7a9..486ac94a 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 @@ -12,7 +12,7 @@ import pro.gravit.utils.helper.VerifyHelper; public final class BatchProfileByUsernameRequest extends Request implements WebSocketRequest { - class Entry { + static class Entry { @LauncherNetworkAPI String username; @LauncherNetworkAPI diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java index f45619d5..06003341 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientJSONPoint.java @@ -31,7 +31,7 @@ public abstract class ClientJSONPoint { protected Channel ch; private static final EventLoopGroup group = new NioEventLoopGroup(); protected WebSocketClientHandler webSocketClientHandler; - protected Bootstrap bootstrap = new Bootstrap(); + protected final Bootstrap bootstrap = new Bootstrap(); protected boolean ssl = false; protected int port; public boolean isClosed; @@ -61,7 +61,7 @@ public ClientJSONPoint(URI uri) throws SSLException { .channel(NioSocketChannel.class) .handler(new ChannelInitializer() { @Override - public void initChannel(SocketChannel ch) throws Exception { + public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc(), uri.getHost(), port)); @@ -88,11 +88,11 @@ public ChannelFuture send(String text) { return ch.writeAndFlush(new TextWebSocketFrame(text), ch.voidPromise()); } - abstract void onMessage(String message) throws Exception; + abstract void onMessage(String message); - abstract void onDisconnect() throws Exception; + abstract void onDisconnect(); - abstract void onOpen() throws Exception; + abstract void onOpen(); public void close() throws InterruptedException { //System.out.println("WebSocket Client sending close"); @@ -105,7 +105,7 @@ public void close() throws InterruptedException { //group.shutdownGracefully(); } - public void eval(final String text) throws IOException { + public void eval(final String text) { ch.writeAndFlush(new TextWebSocketFrame(text), ch.voidPromise()); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index 8b7743d4..3204a344 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.lang.reflect.Type; import java.net.URI; +import java.net.URISyntaxException; import java.util.HashSet; import javax.net.ssl.SSLException; @@ -26,8 +27,8 @@ public class ClientWebSocketService extends ClientJSONPoint { public OnCloseCallback onCloseCallback; public final Boolean onConnect; public ReconnectCallback reconnectCallback; - public static ProviderMap results = new ProviderMap<>(); - public static ProviderMap requests = new ProviderMap<>(); + public static final ProviderMap results = new ProviderMap<>(); + public static final ProviderMap requests = new ProviderMap<>(); private HashSet handlers; public ClientWebSocketService(String address) throws SSLException { @@ -47,11 +48,9 @@ public static void appendTypeAdapters(GsonBuilder builder) private static URI createURL(String address) { try { - URI u = new URI(address); - return u; - } catch (Throwable e) { - LogHelper.error(e); - return null; + return new URI(address); + } catch (URISyntaxException e) { + throw new RuntimeException(e); } } @@ -70,7 +69,7 @@ void onDisconnect() { } @Override - void onOpen() throws Exception { + void onOpen() { synchronized (onConnect) { onConnect.notifyAll(); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java index 554eedd3..b8609e73 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StandartClientWebSocketService.java @@ -17,7 +17,7 @@ import pro.gravit.utils.helper.LogHelper; public class StandartClientWebSocketService extends ClientWebSocketService { - public WaitEventHandler waitEventHandler = new WaitEventHandler(); + public final WaitEventHandler waitEventHandler = new WaitEventHandler(); public StandartClientWebSocketService(String address) throws SSLException { super(address); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java index 860454cd..ed3021bb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WaitEventHandler.java @@ -9,7 +9,7 @@ import pro.gravit.utils.helper.LogHelper; public class WaitEventHandler implements ClientWebSocketService.EventHandler { - public Set requests = ConcurrentHashMap.newKeySet(); + public final Set requests = ConcurrentHashMap.newKeySet(); @Override public void process(WebSocketEvent result) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java index 61a58a3c..00aef7c2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -34,7 +34,7 @@ public ChannelFuture handshakeFuture() { } @Override - public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { + public void handlerAdded(final ChannelHandlerContext ctx) { handshakeFuture = ctx.newPromise(); } @@ -42,9 +42,7 @@ public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { public void channelActive(final ChannelHandlerContext ctx) throws Exception { handshaker.handshake(ctx.channel()); clientJSONPoint.onOpen(); - ctx.executor().scheduleWithFixedDelay(() -> { - ctx.channel().writeAndFlush(new PingWebSocketFrame()); - }, 20L, 20L, TimeUnit.SECONDS); + ctx.executor().scheduleWithFixedDelay(() -> ctx.channel().writeAndFlush(new PingWebSocketFrame()), 20L, 20L, TimeUnit.SECONDS); } @Override @@ -93,7 +91,7 @@ else if (frame instanceof BinaryWebSocketFrame) { } @Override - public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception { + public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) { LogHelper.error(cause); if (!handshakeFuture.isDone()) { diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/managers/GarbageManager.java b/LauncherCore/src/main/java/pro/gravit/launcher/managers/GarbageManager.java index 7810f5e4..66ba4e08 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/managers/GarbageManager.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/managers/GarbageManager.java @@ -9,8 +9,8 @@ public class GarbageManager { static class Entry { - NeedGarbageCollection invoke; - long timer; + final NeedGarbageCollection invoke; + final long timer; public Entry(NeedGarbageCollection invoke, long timer) { this.invoke = invoke; diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/serialize/stream/StreamObject.java b/LauncherCore/src/main/java/pro/gravit/launcher/serialize/stream/StreamObject.java index dfd6979e..8be1c5fd 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/serialize/stream/StreamObject.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/serialize/stream/StreamObject.java @@ -14,7 +14,7 @@ public abstract class StreamObject { @FunctionalInterface public interface Adapter { @LauncherAPI - O convert(HInput input) throws IOException; + O convert(HInput input); } @LauncherAPI diff --git a/LauncherCore/src/main/java/pro/gravit/utils/BiHookSet.java b/LauncherCore/src/main/java/pro/gravit/utils/BiHookSet.java index a636b6e8..4bd24018 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/BiHookSet.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/BiHookSet.java @@ -4,7 +4,7 @@ import java.util.Set; public class BiHookSet { - public Set> list = new HashSet<>(); + public final Set> list = new HashSet<>(); @FunctionalInterface public interface Hook { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/HookSet.java b/LauncherCore/src/main/java/pro/gravit/utils/HookSet.java index 59cbbce2..fe975d64 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/HookSet.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/HookSet.java @@ -4,7 +4,7 @@ import java.util.Set; public class HookSet { - public Set> list = new HashSet<>(); + public final Set> list = new HashSet<>(); @FunctionalInterface public interface Hook { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/Version.java b/LauncherCore/src/main/java/pro/gravit/utils/Version.java index c1d02845..ff26cc93 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/Version.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/Version.java @@ -106,7 +106,7 @@ public enum Type { public static final Map unModTypes = Collections.unmodifiableMap(types); static { - Arrays.asList(values()).stream().forEach(type -> types.put(type.name().substring(0, type.name().length() < 3 ? type.name().length() : 3).toLowerCase(Locale.ENGLISH), type)); + Arrays.asList(values()).forEach(type -> types.put(type.name().substring(0, type.name().length() < 3 ? type.name().length() : 3).toLowerCase(Locale.ENGLISH), type)); } } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java index 29cf52d8..ad65920f 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/Command.java @@ -15,7 +15,7 @@ public abstract class Command { /** * List of available subcommands */ - public Map childCommands; + public final Map childCommands; public Command() { childCommands = new HashMap<>(); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java index ca743a9b..65df9c1e 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/CommandHandler.java @@ -14,8 +14,8 @@ public abstract class CommandHandler implements Runnable { private final CommandCategory baseCategory = new BaseCommandCategory(); public static class Category { - public CommandCategory category; - public String name; + public final CommandCategory category; + public final String name; public String description; public Category(CommandCategory category, String name) { @@ -155,10 +155,8 @@ public List getCategories() { /** * If supported, sends a bell signal to the console - * @throws IOException - * Internal Error */ - public abstract void bell() throws IOException; + public abstract void bell(); /** diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java index e7284c9e..ef3151a0 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/JLineCommandHandler.java @@ -74,18 +74,18 @@ public JLineCommandHandler() throws IOException { } @Override - public void bell() throws IOException { + public void bell() { terminal.puts(InfoCmp.Capability.bell); //reader.beep(); } @Override - public void clear() throws IOException { + public void clear() { terminal.puts(InfoCmp.Capability.clear_screen); } @Override - public String readLine() throws IOException { + public String readLine() { try { return reader.readLine(); } catch (UserInterruptException e) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/ClearCommand.java b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/ClearCommand.java index 840a5f7f..700e955f 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/ClearCommand.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/ClearCommand.java @@ -5,7 +5,7 @@ import pro.gravit.utils.helper.LogHelper; public final class ClearCommand extends Command { - private CommandHandler handler; + private final CommandHandler handler; public ClearCommand(CommandHandler handler) { this.handler = handler; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/DebugCommand.java b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/DebugCommand.java index b8080c52..c192acee 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/DebugCommand.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/DebugCommand.java @@ -15,7 +15,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { boolean newValue, newTraceValue; if (args.length >= 1) { newValue = Boolean.parseBoolean(args[0]); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/GCCommand.java b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/GCCommand.java index 1faf7e55..81da6add 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/GCCommand.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/GCCommand.java @@ -17,7 +17,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { LogHelper.subInfo("Performing full GC"); JVMHelper.fullGC(); GarbageManager.gc(); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java index 95f00723..d6b167b0 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/basic/HelpCommand.java @@ -12,7 +12,7 @@ import pro.gravit.utils.helper.LogHelper; public final class HelpCommand extends Command { - private CommandHandler handler; + private final CommandHandler handler; public static void printCommand(String name, Command command) { String args = command.getArgsDescription(); @@ -34,9 +34,7 @@ public static void printCommand(String name, Command command) { public static void printSubCommandsHelp(String base, Command command) { - command.childCommands.forEach((k, v) -> { - printCommand(base.concat(" ").concat(k), v); - }); + command.childCommands.forEach((k, v) -> printCommand(base.concat(" ").concat(k), v)); } public static void printSubCommandsHelp(String name, String[] args, Command command) throws CommandException diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/JarHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/JarHelper.java index 93f3470e..ece54976 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JarHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JarHelper.java @@ -15,7 +15,7 @@ public interface ZipWalkCallback { @FunctionalInterface public interface JarWalkCallback { - void process(ZipInputStream input, ZipEntry e, String fullClassName, String clazz) throws IOException; + void process(ZipInputStream input, ZipEntry e, String fullClassName, String clazz); } public static void zipWalk(ZipInputStream input, ZipWalkCallback callback) throws IOException { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/LogHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/LogHelper.java index 694c56db..4c9b1d05 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/LogHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/LogHelper.java @@ -43,8 +43,8 @@ public final class LogHelper { private static final AtomicBoolean DEV_ENABLED = new AtomicBoolean(Boolean.getBoolean(DEV_PROPERTY)); public static class OutputEnity { - public Output output; - public OutputTypes type; + public final Output output; + public final OutputTypes type; public OutputEnity(Output output, OutputTypes type) { this.output = output; diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/SecurityHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/SecurityHelper.java index c1e04ab9..194d8094 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/SecurityHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/SecurityHelper.java @@ -451,8 +451,7 @@ private SecurityHelper() { //AES public static byte[] encrypt(String seed, byte[] cleartext) throws Exception { byte[] rawKey = getRawKey(seed.getBytes()); - byte[] result = encrypt(rawKey, cleartext); - return result; + return encrypt(rawKey, cleartext); } public static byte[] encrypt(String seed, String cleartext) throws Exception { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/verify/LauncherTrustManager.java b/LauncherCore/src/main/java/pro/gravit/utils/verify/LauncherTrustManager.java index 3cfe00b5..17fb58f5 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/verify/LauncherTrustManager.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/verify/LauncherTrustManager.java @@ -45,7 +45,7 @@ public enum CheckMode public interface CertificateChecker { - void check(X509Certificate cert, X509Certificate signer) throws CertificateException, SecurityException; + void check(X509Certificate cert, X509Certificate signer) throws SecurityException; } public void checkCertificate(X509Certificate[] certs, CertificateChecker checker) throws CertificateException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { @@ -56,8 +56,7 @@ public void checkCertificate(X509Certificate[] certs, CertificateChecker checker if(trustCache.contains(cert)) { //Добавляем в кеш все проверенные сертификаты - for(int j=0;j < i;++j) - trustCache.add(certs[j]); + trustCache.addAll(Arrays.asList(certs).subList(0, i)); return; } X509Certificate signer = (i+1 < certs.length) ? certs[i+1] : null; diff --git a/LauncherCore/src/test/java/pro/gravit/launcher/CommandHandlerTest.java b/LauncherCore/src/test/java/pro/gravit/launcher/CommandHandlerTest.java index 539f2eb6..a12b43b9 100644 --- a/LauncherCore/src/test/java/pro/gravit/launcher/CommandHandlerTest.java +++ b/LauncherCore/src/test/java/pro/gravit/launcher/CommandHandlerTest.java @@ -31,7 +31,7 @@ public void failNumberTest() throws Exception { try { cmd.invoke("test1"); Assertions.fail("CommandException not throw"); - } catch (CommandException e) + } catch (CommandException ignored) { } @@ -48,7 +48,7 @@ public void categoryTest() throws Exception try { commandHandler.evalNative("test2", false); Assertions.fail("CommandException not throw"); - } catch (CommandException e) + } catch (CommandException ignored) { } diff --git a/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java b/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java index e0add501..bab3dff3 100644 --- a/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java +++ b/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java @@ -20,7 +20,7 @@ public interface TestInterface } public static class MyTestClass implements TestInterface { - public String a; + public final String a; public MyTestClass(String a) { this.a = a; @@ -33,7 +33,7 @@ public String get() { } public static class MyTestClass2 implements TestInterface { - public String b; + public final String b; public MyTestClass2(String a) { this.b = a; diff --git a/LauncherCore/src/test/java/pro/gravit/launcher/impl/Test2Command.java b/LauncherCore/src/test/java/pro/gravit/launcher/impl/Test2Command.java index 229efac9..e1a6595b 100644 --- a/LauncherCore/src/test/java/pro/gravit/launcher/impl/Test2Command.java +++ b/LauncherCore/src/test/java/pro/gravit/launcher/impl/Test2Command.java @@ -14,7 +14,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { } } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java index 8534bcdc..79aac34a 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerAgent.java @@ -45,8 +45,8 @@ public static long getObjSize(Object obj) { return inst.getObjectSize(obj); } - public static Boolean isAutoloadLibraries = Boolean.getBoolean(System.getProperty("serverwrapper,agentlibrariesload", "false")); - public static Boolean isAgentProxy = Boolean.getBoolean(System.getProperty("serverwrapper,agentproxy", "false")); + public static final Boolean isAutoloadLibraries = Boolean.getBoolean(System.getProperty("serverwrapper,agentlibrariesload", "false")); + public static final Boolean isAgentProxy = Boolean.getBoolean(System.getProperty("serverwrapper,agentproxy", "false")); public static void premain(String agentArgument, Instrumentation instrumentation) { LogHelper.debug("Server Agent"); diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 42602a1f..e6135e10 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -39,11 +39,11 @@ public class ServerWrapper extends JsonConfigurable { public ClientPermissions permissions; public static ServerWrapper wrapper; - public static Path modulesDir = Paths.get(System.getProperty("serverwrapper.modulesDir", "modules")); - public static Path modulesConfigDir = Paths.get(System.getProperty("serverwrapper.modulesConfigDir", "modules-config")); - public static Path configFile = Paths.get(System.getProperty("serverwrapper.configFile", "ServerWrapperConfig.json")); - public static Path publicKeyFile = Paths.get(System.getProperty("serverwrapper.publicKeyFile", "public.key")); - public static boolean disableSetup = Boolean.valueOf(System.getProperty("serverwrapper.disableSetup", "false")); + public static final Path modulesDir = Paths.get(System.getProperty("serverwrapper.modulesDir", "modules")); + public static final Path modulesConfigDir = Paths.get(System.getProperty("serverwrapper.modulesConfigDir", "modules-config")); + public static final Path configFile = Paths.get(System.getProperty("serverwrapper.configFile", "ServerWrapperConfig.json")); + public static final Path publicKeyFile = Paths.get(System.getProperty("serverwrapper.publicKeyFile", "public.key")); + public static final boolean disableSetup = Boolean.parseBoolean(System.getProperty("serverwrapper.disableSetup", "false")); public ServerWrapper(Type type, Path configPath) { super(type, configPath); @@ -255,7 +255,7 @@ public static final class Config { public String login; public String[] args; public String password; - public String auth_id = ""; + public final String auth_id = ""; public LauncherConfig.LauncherEnvironment env; } diff --git a/modules b/modules index 14389214..fdadbdfc 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 14389214577f16795ba9844905c2e3886a1ea6d4 +Subproject commit fdadbdfc3c6aae0a90e8c80cc971da47a5db82b0