diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index f0f7c790..81246ff8 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import pro.gravit.launcher.base.Launcher; import pro.gravit.launcher.base.events.RequestEvent; import pro.gravit.launcher.base.events.request.ProfilesRequestEvent; import pro.gravit.launcher.base.modules.events.ClosePhase; @@ -23,20 +22,16 @@ import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.SocketCommandServer; import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler; -import pro.gravit.launchserver.socket.response.auth.ProfilesResponse; import pro.gravit.launchserver.socket.response.auth.RestoreResponse; import pro.gravit.utils.command.Command; import pro.gravit.utils.command.CommandHandler; import pro.gravit.utils.command.SubCommand; import pro.gravit.utils.helper.CommonHelper; -import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.SecurityHelper; -import java.io.BufferedReader; import java.io.IOException; import java.nio.file.*; -import java.nio.file.attribute.BasicFileAttributes; import java.security.KeyStore; import java.time.Duration; import java.time.Instant; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index 34a6fd26..aec1c73e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -36,7 +36,6 @@ import java.nio.file.Path; import java.security.Security; import java.security.cert.CertificateException; -import java.util.ArrayList; import java.util.List; public class LaunchServerStarter { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java index bdb4a4c5..c965338b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java @@ -174,7 +174,7 @@ public AuthManager.AuthReport sudo(User user, boolean shadow) throws IOException } @Override - public User checkServer(Client client, String username, String serverID) throws IOException { + public User checkServer(Client client, String username, String serverID) { SQLUser user = (SQLUser) getUserByUsername(username); if (user == null) { return null; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java index 85dbd336..e29437ee 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java @@ -1,6 +1,5 @@ package pro.gravit.launchserver.auth.core; -import pro.gravit.launcher.base.ClientPermissions; import pro.gravit.launcher.base.request.secure.HardwareReportRequest; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.AuthProviderPair; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java index 3358ad9b..5f961791 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/RejectAuthCoreProvider.java @@ -41,12 +41,12 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c } @Override - public User checkServer(Client client, String username, String serverID) throws IOException { + public User checkServer(Client client, String username, String serverID) { return null; } @Override - public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException { + public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) { return false; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/SQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/SQLCoreProvider.java index 990840a0..0252db7d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/SQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/SQLCoreProvider.java @@ -11,9 +11,7 @@ import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware; import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware; import pro.gravit.launchserver.socket.Client; -import pro.gravit.utils.helper.IOHelper; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.sql.*; import java.util.Base64; @@ -85,7 +83,7 @@ protected SQLUser constructUser(ResultSet set) throws SQLException { set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), set.getLong(hardwareIdColumn)) : null; } - private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException, IOException { + private SQLUserHardware fetchHardwareInfo(ResultSet set) throws SQLException { HardwareReportRequest.HardwareInfo hardwareInfo = new HardwareReportRequest.HardwareInfo(); hardwareInfo.hwDiskId = set.getString("hwDiskId"); hardwareInfo.baseboardSerialNumber = set.getString("baseboardSerialNumber"); @@ -126,7 +124,7 @@ public UserHardware getHardwareInfoByPublicKey(byte[] publicKey) { return null; } } - } catch (SQLException | IOException throwables) { + } catch (SQLException throwables) { logger.error("SQL Error", throwables); return null; } @@ -149,7 +147,7 @@ public UserHardware getHardwareInfoByData(HardwareReportRequest.HardwareInfo inf } } } - } catch (SQLException | IOException throwables) { + } catch (SQLException throwables) { logger.error("SQL Error", throwables); } return null; @@ -170,7 +168,7 @@ public UserHardware getHardwareInfoById(String id) { return null; } } - } catch (SQLException | IOException throwables) { + } catch (SQLException throwables) { logger.error("SQL Error", throwables); return null; } @@ -294,7 +292,7 @@ protected AbstractSQLCoreProvider.SQLUserSession createSession(AbstractSQLCorePr } @Override - public UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException { + public UserSession extendedCheckServer(Client client, String username, String serverID) { AbstractSQLCoreProvider.SQLUser user = (AbstractSQLCoreProvider.SQLUser) getUserByUsername(username); if (user == null) { return null; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportExtendedCheckServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportExtendedCheckServer.java index a0eb8365..82a5042d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportExtendedCheckServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportExtendedCheckServer.java @@ -6,5 +6,5 @@ import java.io.IOException; public interface AuthSupportExtendedCheckServer { - UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException; + UserSession extendedCheckServer(Client client, String username, String serverID); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/OpenIDAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/OpenIDAuthCoreProvider.java index 77233f26..5cd8601f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/OpenIDAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/OpenIDAuthCoreProvider.java @@ -143,7 +143,7 @@ public void init(LaunchServer server, AuthProviderPair pair) { } @Override - public User checkServer(Client client, String username, String serverID) throws IOException { + public User checkServer(Client client, String username, String serverID) { var savedServerId = sqlSessionStore.getServerIdByUsername(username); if (!serverID.equals(savedServerId)) { return null; @@ -153,7 +153,7 @@ public User checkServer(Client client, String username, String serverID) throws } @Override - public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException { + public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) { User user; try { user = createUserFromMinecraftToken(accessToken); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/SQLServerSessionStore.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/SQLServerSessionStore.java index 6acebc5d..561e6e37 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/SQLServerSessionStore.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/openid/SQLServerSessionStore.java @@ -3,8 +3,6 @@ import pro.gravit.launchserver.auth.SQLSourceConfig; import pro.gravit.utils.helper.LogHelper; -import java.io.PrintWriter; -import java.io.StringWriter; import java.sql.SQLException; import java.util.UUID; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java index c735d0e0..9433d6cb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java @@ -4,9 +4,7 @@ import org.apache.logging.log4j.Logger; import pro.gravit.launchserver.binary.tasks.LauncherBuildTask; import pro.gravit.utils.helper.CommonHelper; -import pro.gravit.utils.helper.IOHelper; -import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index a336c439..242541d4 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -56,7 +56,7 @@ public final byte[] getDigest() { public void init() { } - public final boolean sync() throws IOException { + public final boolean sync() { try { var target = syncBinaryFile.toString(); var path = server.config.updatesProvider.download(null, List.of(target)).get(target); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java index 3b331e25..041825a1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadClientCommand.java @@ -13,7 +13,6 @@ import pro.gravit.utils.command.CommandException; import pro.gravit.utils.helper.IOHelper; -import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Path; import java.util.Collections; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/CloneProfileCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/CloneProfileCommand.java index 1b33cd43..4ca43720 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/CloneProfileCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/CloneProfileCommand.java @@ -2,17 +2,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import pro.gravit.launcher.base.Launcher; import pro.gravit.launcher.base.profiles.ClientProfile; import pro.gravit.launcher.base.profiles.ClientProfileBuilder; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.CommonHelper; import pro.gravit.utils.helper.IOHelper; import java.io.IOException; -import java.io.Reader; -import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java index f6a36659..66ffd76c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java @@ -5,9 +5,7 @@ import pro.gravit.launcher.base.profiles.ClientProfile; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.IOHelper; -import java.nio.file.Files; import java.util.UUID; public class DeleteProfileCommand extends Command { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/ListProfilesCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/ListProfilesCommand.java index 8eaa913e..62ba80e9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/ListProfilesCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/ListProfilesCommand.java @@ -22,7 +22,7 @@ public String getUsageDescription() { } @Override - public void invoke(String... args) throws Exception { + public void invoke(String... args) { for(var profile : server.getProfiles()) { logger.info("{} ({}) {}", profile.getTitle(), profile.getVersion().toString(), profile.isLimited() ? "limited" : ""); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/MakeProfileCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/MakeProfileCommand.java index 7a010c64..21e8448d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/MakeProfileCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/MakeProfileCommand.java @@ -2,14 +2,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import pro.gravit.launcher.base.Launcher; import pro.gravit.launcher.base.profiles.ClientProfile; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; import pro.gravit.launchserver.helper.MakeProfileHelper; -import pro.gravit.utils.helper.IOHelper; - -import java.io.Writer; public class MakeProfileCommand extends Command { private transient final Logger logger = LogManager.getLogger(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/SaveProfilesCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/SaveProfilesCommand.java index 9d796c1e..c14ad65d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/SaveProfilesCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/SaveProfilesCommand.java @@ -2,17 +2,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import pro.gravit.launcher.base.Launcher; import pro.gravit.launcher.base.profiles.ClientProfile; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; -import pro.gravit.utils.helper.IOHelper; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.UUID; public class SaveProfilesCommand extends Command { 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 ccd7a71c..c180c504 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -1,6 +1,5 @@ package pro.gravit.launchserver.config; -import io.netty.channel.epoll.Epoll; import io.netty.handler.logging.LogLevel; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java index 717c65a7..bd86fe0b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java @@ -1,20 +1,10 @@ package pro.gravit.launchserver.manangers; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import pro.gravit.launcher.core.hasher.HashedDir; -import pro.gravit.launcher.core.serialize.HInput; -import pro.gravit.launcher.core.serialize.HOutput; import pro.gravit.launchserver.LaunchServer; -import pro.gravit.launchserver.modules.events.LaunchServerUpdatesSyncEvent; -import pro.gravit.utils.helper.IOHelper; import java.io.IOException; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.*; -import java.util.stream.Stream; public class UpdatesManager { private final LaunchServer server; @@ -24,12 +14,12 @@ public UpdatesManager(LaunchServer server) { } @Deprecated - public void readUpdatesFromCache() throws IOException { + public void readUpdatesFromCache() { } @Deprecated - public void readUpdatesDir() throws IOException { + public void readUpdatesDir() { } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java index 987c78f1..181b6a1b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/LauncherNettyServer.java @@ -4,7 +4,6 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.EventLoopGroup; -import io.netty.channel.epoll.Epoll; import io.netty.channel.group.DefaultChannelGroup; import io.netty.channel.socket.SocketChannel; import io.netty.handler.codec.http.HttpObjectAggregator; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java index 5a13e460..9c337ebc 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/NettyObjectFactory.java @@ -5,10 +5,8 @@ import io.netty.channel.MultiThreadIoEventLoopGroup; import io.netty.channel.ServerChannel; import io.netty.channel.epoll.Epoll; -import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollIoHandler; import io.netty.channel.epoll.EpollServerSocketChannel; -import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioIoHandler; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.uring.IoUring; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketCommandServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketCommandServer.java index d6a04a38..5afb5f85 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketCommandServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/SocketCommandServer.java @@ -5,7 +5,6 @@ import pro.gravit.launchserver.config.log4j.LogAppender; import pro.gravit.utils.command.CommandHandler; -import java.io.IOException; import java.net.StandardProtocolFamily; import java.net.UnixDomainSocketAddress; import java.nio.ByteBuffer; @@ -64,29 +63,28 @@ public void run() { ByteBuffer buffer = ByteBuffer.allocate(1024); while (true) { SocketChannel channel = serverChannel.accept(); - channel.configureBlocking(true); - String command = null; - try { + try (channel) { + channel.configureBlocking(true); + String command = null; mark: while (true) { int bytesRead = channel.read(buffer); if (bytesRead < 0) { break; } - for (var i=0;i pre = new LinkedList<>(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java index 74390d36..90e0a1c9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/profiles/ClientProfile.java @@ -12,7 +12,6 @@ import java.lang.reflect.Type; import java.net.InetSocketAddress; -import java.nio.file.Path; import java.util.*; public final class ClientProfile implements Comparable { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestException.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestException.java index 429b0c73..52a83cab 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestException.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestException.java @@ -3,7 +3,6 @@ import java.io.IOException; public final class RequestException extends IOException { - private static final long serialVersionUID = 7558237657082664821L; public RequestException(String message) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestService.java index bad2ebd1..e6a5c3fe 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/RequestService.java @@ -6,7 +6,7 @@ public interface RequestService { CompletableFuture request(Request request) throws IOException; - void open() throws Exception; + void open(); void registerEventHandler(EventHandler handler); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java index ffdab6c6..618d51d2 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientJSONPoint.java @@ -33,7 +33,7 @@ public abstract class ClientJSONPoint implements WebSocket.Listener { private final Object sendSyncObject = new Object(); private volatile StringBuilder builder = new StringBuilder(); - public ClientJSONPoint(final String uri) throws SSLException { + public ClientJSONPoint(final String uri) { this(URI.create(uri)); } @@ -114,7 +114,7 @@ public void send(String text) { abstract void onOpen(); - public void close() throws InterruptedException { + public void close() { webSocket.abort(); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java index a3e3a345..8418dcd0 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/ClientWebSocketService.java @@ -33,7 +33,7 @@ public abstract class ClientWebSocketService extends ClientJSONPoint { public OnCloseCallback onCloseCallback; public ReconnectCallback reconnectCallback; - public ClientWebSocketService(String address) throws SSLException { + public ClientWebSocketService(String address) { super(createURL(address)); this.gson = Launcher.gsonManager.gson; this.onConnect = true; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/StdWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/StdWebSocketService.java index fe6dade9..b9651256 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/StdWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/base/request/websockets/StdWebSocketService.java @@ -40,11 +40,7 @@ public static CompletableFuture initWebSockets(String addre service.openAsync(() -> { future.complete(service); JVMHelper.RUNTIME.addShutdownHook(new Thread(() -> { - try { - service.close(); - } catch (InterruptedException e) { - LogHelper.error(e); - } + service.close(); })); }, future::completeExceptionally); return future; diff --git a/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java b/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java index 81ff8a28..9a65f240 100644 --- a/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java +++ b/LauncherAPI/src/test/java/pro/gravit/launcher/ClientVersionTest.java @@ -7,9 +7,9 @@ public class ClientVersionTest { @Test public void parseTest() { - Assertions.assertEquals(ClientProfile.Version.of("1.0.0").toCleanString(), "1.0.0"); - Assertions.assertEquals(ClientProfile.Version.of("1.0.0-1").toCleanString(), "1.0.0.1"); - Assertions.assertEquals(ClientProfile.Version.of("-----1.0.0").toCleanString(), "1.0.0"); + Assertions.assertEquals("1.0.0", ClientProfile.Version.of("1.0.0").toCleanString()); + Assertions.assertEquals("1.0.0.1", ClientProfile.Version.of("1.0.0-1").toCleanString()); + Assertions.assertEquals("1.0.0", ClientProfile.Version.of("-----1.0.0").toCleanString()); } @Test diff --git a/LauncherAPI/src/test/java/pro/gravit/launcher/ModulesTest.java b/LauncherAPI/src/test/java/pro/gravit/launcher/ModulesTest.java index 0f9ea313..9ca8c2e9 100644 --- a/LauncherAPI/src/test/java/pro/gravit/launcher/ModulesTest.java +++ b/LauncherAPI/src/test/java/pro/gravit/launcher/ModulesTest.java @@ -49,12 +49,12 @@ public void dependenciesTest() { moduleManager.loadModule(new Depend3Module()); moduleManager.loadModule(new MainModule()); moduleManager.initModules(null); - Assertions.assertEquals(moduleManager.getModule("depend1").getInitStatus(), LauncherModule.InitStatus.FINISH); - Assertions.assertEquals(moduleManager.getModule("depend2").getInitStatus(), LauncherModule.InitStatus.FINISH); - Assertions.assertEquals(moduleManager.getModule("depend3").getInitStatus(), LauncherModule.InitStatus.FINISH); - Assertions.assertEquals(moduleManager.getModule("internal").getInitStatus(), LauncherModule.InitStatus.FINISH); - Assertions.assertEquals(moduleManager.getModule("virtual").getInitStatus(), LauncherModule.InitStatus.FINISH); - Assertions.assertEquals(moduleManager.getModule("main").getInitStatus(), LauncherModule.InitStatus.FINISH); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend1").getInitStatus()); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend2").getInitStatus()); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("depend3").getInitStatus()); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("internal").getInitStatus()); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("virtual").getInitStatus()); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("main").getInitStatus()); } @Test @@ -62,7 +62,7 @@ public void cyclicTest() { moduleManager.loadModule(new CyclicDependModule()); moduleManager.loadModule(new Cyclic2DependModule()); moduleManager.initModules(null); - Assertions.assertEquals(moduleManager.getModule("cyclic1").getInitStatus(), LauncherModule.InitStatus.FINISH); - Assertions.assertEquals(moduleManager.getModule("cyclic2").getInitStatus(), LauncherModule.InitStatus.FINISH); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("cyclic1").getInitStatus()); + Assertions.assertEquals(LauncherModule.InitStatus.FINISH, moduleManager.getModule("cyclic2").getInitStatus()); } } diff --git a/LauncherAPI/src/test/java/pro/gravit/launcher/impl/Depend1Module.java b/LauncherAPI/src/test/java/pro/gravit/launcher/impl/Depend1Module.java index 99da57e2..cec095f2 100644 --- a/LauncherAPI/src/test/java/pro/gravit/launcher/impl/Depend1Module.java +++ b/LauncherAPI/src/test/java/pro/gravit/launcher/impl/Depend1Module.java @@ -16,10 +16,10 @@ public Depend1Module() { @Override public void init(LauncherInitContext initContext) { InternalModule module = modulesManager.getModule(InternalModule.class); - Assertions.assertEquals(module.getInitStatus(), InitStatus.FINISH); + Assertions.assertEquals(InitStatus.FINISH, module.getInitStatus()); Depend3Module module1 = modulesManager.getModule(Depend3Module.class); - Assertions.assertEquals(module1.getInitStatus(), InitStatus.FINISH); + Assertions.assertEquals(InitStatus.FINISH, module1.getInitStatus()); VirtualInterface virtualInterface = modulesManager.getModuleByInterface(VirtualInterface.class); - Assertions.assertEquals(((LauncherModule) virtualInterface).getInitStatus(), InitStatus.FINISH); + Assertions.assertEquals(InitStatus.FINISH, ((LauncherModule) virtualInterface).getInitStatus()); } } diff --git a/LauncherAPI/src/test/java/pro/gravit/launcher/impl/MainModule.java b/LauncherAPI/src/test/java/pro/gravit/launcher/impl/MainModule.java index e4993574..0b484477 100644 --- a/LauncherAPI/src/test/java/pro/gravit/launcher/impl/MainModule.java +++ b/LauncherAPI/src/test/java/pro/gravit/launcher/impl/MainModule.java @@ -17,8 +17,8 @@ public MainModule() { @Override public void init(LauncherInitContext initContext) { Depend1Module module = modulesManager.getModule(Depend1Module.class); - Assertions.assertEquals(module.getInitStatus(), InitStatus.FINISH); + Assertions.assertEquals(InitStatus.FINISH, module.getInitStatus()); Depend2Module module2 = modulesManager.getModule(Depend2Module.class); - Assertions.assertEquals(module2.getInitStatus(), InitStatus.FINISH); + Assertions.assertEquals(InitStatus.FINISH, module2.getInitStatus()); } } diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 6aad0739..65dcb764 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -124,7 +124,7 @@ private static void realMain(String[] args) throws Throwable { LogHelper.dev("Classpath entry %s", e); } } - List classpathURLs = classpath.stream().map(IOHelper::toURL).collect(Collectors.toList()); + List classpathURLs = classpath.stream().map(IOHelper::toURL).toList(); // Start client with WatchService monitoring RequestService service; if (params.offlineMode) { diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java b/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java index 343f7e80..93bbd315 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/core/hasher/HashedDir.java @@ -282,7 +282,7 @@ public enum WalkAction { @FunctionalInterface public interface WalkCallback { - WalkAction walked(String path, String name, HashedEntry entry) throws IOException; + WalkAction walked(String path, String name, HashedEntry entry); } public static class FindRecursiveResult { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/HookException.java b/LauncherCore/src/main/java/pro/gravit/utils/HookException.java index b345b0dd..296459a9 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/HookException.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/HookException.java @@ -1,7 +1,6 @@ package pro.gravit.utils; public class HookException extends RuntimeException { - private static final long serialVersionUID = -529141998961943161L; public HookException(String message) { super(message); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/command/CommandException.java b/LauncherCore/src/main/java/pro/gravit/utils/command/CommandException.java index 55fd8dc2..7d9df6b3 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/command/CommandException.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/command/CommandException.java @@ -1,7 +1,6 @@ package pro.gravit.utils.command; public final class CommandException extends Exception { - private static final long serialVersionUID = -6588814993972117772L; public CommandException(String message) { diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index f11f3567..4cbe775f 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -221,37 +221,39 @@ public static ArgsParseResult parseJavaArgs(List args) { continue; } } - if(arg.equals("--module-path") || arg.equals("-p")) { - prevArgType = PrevArgType.MODULE_PATH; - continue; - } - if(arg.equals("--classpath") || arg.equals("-cp")) { - prevArgType = PrevArgType.CLASSPATH; - continue; - } - if(arg.equals("--add-modules")) { - prevArgType = PrevArgType.ADD_MODULES; - continue; - } - if(arg.equals("--add-opens")) { - prevArgType = PrevArgType.ADD_OPENS; - continue; - } - if(arg.equals("--add-exports")) { - prevArgType = PrevArgType.ADD_EXPORTS; - continue; - } - if(arg.equals("--add-reads")) { - prevArgType = PrevArgType.ADD_READS; - continue; - } - if(arg.equals("--module") || arg.equals("-m")) { - prevArgType = PrevArgType.MODULE; - continue; - } - if(arg.equals("-jar")) { - prevArgType = PrevArgType.JAR; - continue; + switch (arg) { + case "--module-path", "-p" -> { + prevArgType = PrevArgType.MODULE_PATH; + continue; + } + case "--classpath", "-cp" -> { + prevArgType = PrevArgType.CLASSPATH; + continue; + } + case "--add-modules" -> { + prevArgType = PrevArgType.ADD_MODULES; + continue; + } + case "--add-opens" -> { + prevArgType = PrevArgType.ADD_OPENS; + continue; + } + case "--add-exports" -> { + prevArgType = PrevArgType.ADD_EXPORTS; + continue; + } + case "--add-reads" -> { + prevArgType = PrevArgType.ADD_READS; + continue; + } + case "--module", "-m" -> { + prevArgType = PrevArgType.MODULE; + continue; + } + case "-jar" -> { + prevArgType = PrevArgType.JAR; + continue; + } } jvmArgs.add(arg); } 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 1e516138..f0c1b460 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/JarHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/JarHelper.java @@ -83,7 +83,7 @@ public static byte[] getClassBytes(Class clazz, ClassLoader classLoader) thro return IOHelper.read(classLoader.getResourceAsStream(getClassFile(clazz))); } - public static InputStream getClassBytesStream(Class clazz) throws IOException { + public static InputStream getClassBytesStream(Class clazz) { return getClassBytesStream(clazz, clazz.getClassLoader()); } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java b/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java index b4865b8d..eea45c63 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/launch/BasicLaunch.java @@ -68,7 +68,7 @@ public void addTransformer(ClassTransformer transformer) { } instrumentation.addTransformer(new ClassFileTransformer() { @Override - public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { + public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) { if(transformer.filter(null, className)) { return transformer.transform(null, className, protectionDomain, classfileBuffer); } diff --git a/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java b/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java index 44c871d9..738a9314 100644 --- a/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java +++ b/LauncherCore/src/test/java/pro/gravit/launcher/SerializeTest.java @@ -30,8 +30,8 @@ public void main() { String json2 = gson.toJson(new MyTestClass2("BBBB"), TestInterface.class); TestInterface test1 = gson.fromJson(json, TestInterface.class); TestInterface test2 = gson.fromJson(json2, TestInterface.class); - Assertions.assertEquals(test1.get(), "AAAA"); - Assertions.assertEquals(test2.get(), "BBBB"); + Assertions.assertEquals("AAAA", test1.get()); + Assertions.assertEquals("BBBB", test2.get()); } public interface TestInterface { diff --git a/modules b/modules index aa5ab332..00b275f8 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit aa5ab332d65dd14ce5321453aa809e30b87a186d +Subproject commit 00b275f82f52b9bbfebe4649b8c96a438365aecd