diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java index 6aa80294..28dfee1f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/Response.java @@ -5,7 +5,8 @@ import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launchserver.LaunchServer; -import ru.gravit.launchserver.response.update.*; +import ru.gravit.launchserver.response.update.LauncherResponse; +import ru.gravit.launchserver.response.update.LegacyLauncherResponse; import ru.gravit.launchserver.socket.Client; import ru.gravit.utils.helper.LogHelper; diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 5282fd5d..65392935 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -12,7 +12,6 @@ import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.auth.RestoreSessionRequest; -import ru.gravit.launcher.request.update.LegacyLauncherRequest; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java index 7596add2..d6e1ee5b 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/FunctionalBridge.java @@ -11,7 +11,6 @@ import ru.gravit.launcher.managers.HasherManager; import ru.gravit.launcher.managers.HasherStore; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.update.LegacyLauncherRequest; import ru.gravit.launcher.request.websockets.RequestInterface; import ru.gravit.launcher.serialize.signed.SignedObjectHolder; @@ -44,21 +43,6 @@ public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, S }; } - @LauncherAPI - public static LegacyLauncherRequest.Result offlineLauncherRequest() throws IOException { - if (settings.lastDigest == null || settings.lastProfiles.isEmpty()) { - Request.requestError("Запуск в оффлайн-режиме невозможен"); - } - - // Verify launcher signature - //TODO: TO DIGEST - //SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, - // settings.lastDigest, Launcher.getConfig().publicKey); - - // Return last sign and profiles - return new LegacyLauncherRequest.Result(null, settings.lastDigest, settings.lastProfiles); - } - @LauncherAPI public static void makeJsonRequest(RequestInterface request, Runnable callback) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java index 20729067..20ca7393 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java @@ -13,7 +13,10 @@ import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.profiles.optional.OptionalFile; -import ru.gravit.launcher.request.*; +import ru.gravit.launcher.request.PingRequest; +import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.RequestException; +import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.auth.AuthRequest; import ru.gravit.launcher.request.auth.CheckServerRequest; import ru.gravit.launcher.request.auth.JoinServerRequest; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java index 699c0022..1813e3dc 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/PingRequest.java @@ -1,22 +1,10 @@ package ru.gravit.launcher.request; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.SerializeLimits; - -import java.io.IOException; - public final class PingRequest extends Request { - @LauncherAPI - public PingRequest() { - this(null); + @Override + protected Void requestDo() throws Exception { + return null; } - @LauncherAPI - public PingRequest(LauncherConfig config) { - super(config); - } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java index 77b91f6e..a6774a41 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/Request.java @@ -1,15 +1,8 @@ package ru.gravit.launcher.request; -import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.SecurityHelper; -import java.io.IOException; -import java.net.Socket; import java.util.concurrent.atomic.AtomicBoolean; public abstract class Request { @@ -28,37 +21,15 @@ public static void requestError(String message) throws RequestException { throw new RequestException(message); } - @LauncherAPI - protected transient final LauncherConfig config; - private transient final AtomicBoolean started = new AtomicBoolean(false); - @LauncherAPI - protected Request() { - this(null); - } - - @LauncherAPI - protected Request(LauncherConfig config) { - this.config = config == null ? Launcher.getConfig() : config; - } - - @LauncherAPI - protected final void readError(HInput input) throws IOException { - String error = input.readString(0); - if (!error.isEmpty()) - requestError(error); - } - @LauncherAPI public R request() throws Exception { if (!started.compareAndSet(false, true)) throw new IllegalStateException("Request already started"); - return requestWebSockets(); + return requestDo(); } - protected R requestWebSockets() throws Exception { - return null; - } + protected abstract R requestDo() throws Exception; } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java index 3e6445d8..7f4d4016 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java @@ -1,20 +1,14 @@ package ru.gravit.launcher.request.auth; -import ru.gravit.launcher.*; +import ru.gravit.launcher.HWID; +import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.events.request.AuthRequestEvent; -import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; - public final class AuthRequest extends Request implements RequestInterface { @LauncherNetworkAPI private final String login; @@ -36,8 +30,7 @@ public enum ConnectTypes { } @LauncherAPI - public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid) { - super(config); + public AuthRequest(String login, byte[] password, HWID hwid) { this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = password.clone(); this.hwid = hwid; @@ -48,8 +41,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw } @LauncherAPI - public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String auth_id) { - super(config); + public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) { this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = password.clone(); this.hwid = hwid; @@ -60,8 +52,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw } @LauncherAPI - public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText, String auth_id) { - super(config); + public AuthRequest(String login, byte[] password, HWID hwid, String customText, String auth_id) { this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = password.clone(); this.hwid = hwid; @@ -71,11 +62,6 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw authType = ConnectTypes.CLIENT; } - @LauncherAPI - public AuthRequest(String login, byte[] password, HWID hwid) { - this(null, login, password, hwid); - } - public AuthRequest(String login, byte[] encryptedPassword, String auth_id, ConnectTypes authType) { this.login = login; this.encryptedPassword = encryptedPassword; @@ -87,15 +73,10 @@ public AuthRequest(String login, byte[] encryptedPassword, String auth_id, Conne } @Override - public AuthRequestEvent requestWebSockets() throws Exception { + public AuthRequestEvent requestDo() throws Exception { return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this); } - @LauncherAPI - public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) { - this(null, login, password, hwid, auth_id); - } - @Override public String getType() { return "auth"; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java index fd77eb36..39a64279 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/CheckServerRequest.java @@ -1,24 +1,13 @@ package ru.gravit.launcher.request.auth; -import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.events.request.CheckServerRequestEvent; -import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; -import ru.gravit.launcher.request.ResultInterface; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; -import java.io.IOException; - public final class CheckServerRequest extends Request implements RequestInterface { @LauncherNetworkAPI private final String username; @@ -26,19 +15,13 @@ public final class CheckServerRequest extends Request i private final String serverID; @LauncherAPI - public CheckServerRequest(LauncherConfig config, String username, String serverID) { - super(config); + public CheckServerRequest(String username, String serverID) { this.username = VerifyHelper.verifyUsername(username); this.serverID = VerifyHelper.verifyServerID(serverID); } - @LauncherAPI - public CheckServerRequest(String username, String serverID) { - this(null, username, serverID); - } - @Override - public CheckServerRequestEvent requestWebSockets() throws Exception + public CheckServerRequestEvent requestDo() throws Exception { return (CheckServerRequestEvent) LegacyRequestBridge.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java index e52cea3d..c649c025 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/JoinServerRequest.java @@ -1,16 +1,11 @@ package ru.gravit.launcher.request.auth; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.events.request.JoinServerRequestEvent; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; @@ -27,22 +22,17 @@ public final class JoinServerRequest extends Request imp private final String serverID; @LauncherAPI - public JoinServerRequest(LauncherConfig config, String username, String accessToken, String serverID) { - super(config); + public JoinServerRequest(String username, String accessToken, String serverID) { this.username = VerifyHelper.verifyUsername(username); this.accessToken = SecurityHelper.verifyToken(accessToken); this.serverID = VerifyHelper.verifyServerID(serverID); } @Override - public JoinServerRequestEvent requestWebSockets() throws IOException, InterruptedException { + public JoinServerRequestEvent requestDo() throws IOException, InterruptedException { return (JoinServerRequestEvent) LegacyRequestBridge.sendRequest(this); } - @LauncherAPI - public JoinServerRequest(String username, String accessToken, String serverID) { - this(null, username, accessToken, serverID); - } @Override public String getType() { return "joinServer"; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java index f6c6001b..bb9b890e 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/RestoreSessionRequest.java @@ -1,13 +1,10 @@ package ru.gravit.launcher.request.auth; import ru.gravit.launcher.LauncherNetworkAPI; -import ru.gravit.launcher.events.request.AuthRequestEvent; import ru.gravit.launcher.events.request.RestoreSessionRequestEvent; import ru.gravit.launcher.request.Request; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; import java.io.IOException; @@ -19,7 +16,7 @@ public RestoreSessionRequest(long session) { this.session = session; } @Override - public RestoreSessionRequestEvent requestWebSockets() throws IOException, InterruptedException { + public RestoreSessionRequestEvent requestDo() throws IOException, InterruptedException { return (RestoreSessionRequestEvent) LegacyRequestBridge.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java index 75b70e5b..c749edfa 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/SetProfileRequest.java @@ -1,30 +1,24 @@ package ru.gravit.launcher.request.auth; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.events.request.SetProfileRequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.SerializeLimits; public class SetProfileRequest extends Request implements RequestInterface { private transient ClientProfile profile; @LauncherNetworkAPI public String client; - public SetProfileRequest(LauncherConfig config, ClientProfile profile) { - super(config); + public SetProfileRequest(ClientProfile profile) { this.profile = profile; this.client = profile.getTitle(); } @Override - public SetProfileRequestEvent requestWebSockets() throws Exception { + public SetProfileRequestEvent requestDo() throws Exception { return (SetProfileRequestEvent) LegacyRequestBridge.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java index 20632f8d..2fad0c61 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LauncherRequest.java @@ -2,23 +2,18 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.downloader.ListDownloader; import ru.gravit.launcher.events.request.LauncherRequestEvent; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -35,7 +30,7 @@ public final class LauncherRequest extends Request impleme public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe"); @LauncherAPI - public static void update(LauncherConfig config, LauncherRequestEvent result) throws IOException { + public static void update(LauncherRequestEvent result) throws IOException { List args = new ArrayList<>(8); args.add(IOHelper.resolveJavaBin(null).toString()); if (LogHelper.isDebugEnabled()) @@ -70,21 +65,15 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th throw new AssertionError("Why Launcher wasn't restarted?!"); } - @LauncherAPI - public LauncherRequest() { - this(null); - } - @Override - public LauncherRequestEvent requestWebSockets() throws Exception { + public LauncherRequestEvent requestDo() throws Exception { LauncherRequestEvent result = (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this); - if (result.needUpdate) update(config, result); + if (result.needUpdate) update(result); return result; } @LauncherAPI - public LauncherRequest(LauncherConfig config) { - super(config); + public LauncherRequest() { Path launcherPath = IOHelper.getCodeSource(LauncherRequest.class); try { digest = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA512, launcherPath); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java deleted file mode 100644 index b4e64cfd..00000000 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/LegacyLauncherRequest.java +++ /dev/null @@ -1,87 +0,0 @@ -package ru.gravit.launcher.request.update; - -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.profiles.ClientProfile; -import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; -import ru.gravit.launcher.request.update.LegacyLauncherRequest.Result; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.utils.helper.IOHelper; -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; - -import java.io.IOException; -import java.nio.file.Path; -import java.security.SignatureException; -import java.security.interfaces.RSAPublicKey; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public final class LegacyLauncherRequest extends Request { - public static final class Result { - @LauncherAPI - public final List profiles; - private final byte[] binary; - private final byte[] sign; - - public Result(byte[] binary, byte[] sign, List profiles) { - this.binary = binary == null ? null : binary.clone(); - this.sign = sign.clone(); - this.profiles = Collections.unmodifiableList(profiles); - } - - @LauncherAPI - public byte[] getBinary() { - return binary == null ? null : binary.clone(); - } - - @LauncherAPI - public byte[] getSign() { - return sign.clone(); - } - } - - @LauncherAPI - public static final Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class); - - @LauncherAPI - public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe"); - - @LauncherAPI - public static void update(LauncherConfig config, Result result) throws SignatureException, IOException { - SecurityHelper.verifySign(result.binary, result.sign, config.publicKey); - - // Prepare process builder to start new instance (java -jar works for Launch4J's EXE too) - List args = new ArrayList<>(8); - args.add(IOHelper.resolveJavaBin(null).toString()); - if (LogHelper.isDebugEnabled()) - args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); - args.add("-jar"); - args.add(BINARY_PATH.toString()); - ProcessBuilder builder = new ProcessBuilder(args.toArray(new String[0])); - builder.inheritIO(); - - // Rewrite and start new instance - IOHelper.write(BINARY_PATH, result.binary); - builder.start(); - - // Kill current instance - JVMHelper.RUNTIME.exit(255); - throw new AssertionError("Why Launcher wasn't restarted?!"); - } - - @LauncherAPI - public LegacyLauncherRequest() { - this(null); - } - - @LauncherAPI - public LegacyLauncherRequest(LauncherConfig config) { - super(config); - } -} diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java index 3722219a..550f146a 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/ProfilesRequest.java @@ -1,34 +1,14 @@ package ru.gravit.launcher.request.update; -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.events.request.ProfilesRequestEvent; -import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; - -import java.util.ArrayList; -import java.util.List; public final class ProfilesRequest extends Request implements RequestInterface { - @LauncherAPI - public ProfilesRequest() { - this(null); - } - - @LauncherAPI - public ProfilesRequest(LauncherConfig config) { - super(config); - } - @Override - public ProfilesRequestEvent requestWebSockets() throws Exception { + public ProfilesRequestEvent requestDo() throws Exception { return (ProfilesRequestEvent) LegacyRequestBridge.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java index 229cfd26..131269c3 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateListRequest.java @@ -1,32 +1,14 @@ package ru.gravit.launcher.request.update; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.events.request.UpdateListRequestEvent; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.utils.helper.IOHelper; - -import java.io.IOException; -import java.util.HashSet; public final class UpdateListRequest extends Request implements RequestInterface { - @LauncherAPI - public UpdateListRequest() { - this(null); - } - - @LauncherAPI - public UpdateListRequest(LauncherConfig config) { - super(config); - } @Override - public UpdateListRequestEvent requestWebSockets() throws Exception { + public UpdateListRequestEvent requestDo() throws Exception { return (UpdateListRequestEvent) LegacyRequestBridge.sendRequest(this); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java index 777149d8..25258cf9 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java @@ -2,7 +2,6 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.downloader.ListDownloader; import ru.gravit.launcher.events.request.UpdateRequestEvent; @@ -11,33 +10,23 @@ import ru.gravit.launcher.hasher.HashedEntry; import ru.gravit.launcher.hasher.HashedFile; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.UpdateAction; import ru.gravit.launcher.request.update.UpdateRequest.State.Callback; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; -import ru.gravit.launcher.serialize.SerializeLimits; -import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; -import ru.gravit.utils.helper.SecurityHelper; -import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm; -import java.io.EOFException; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.security.MessageDigest; -import java.security.SignatureException; import java.time.Duration; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.List; import java.util.Map.Entry; -import java.util.zip.InflaterInputStream; +import java.util.Objects; +import java.util.Queue; public final class UpdateRequest extends Request implements RequestInterface { @@ -200,7 +189,7 @@ private static void fillActionsQueue(Queue queue, HashedDir mismat } @Override - public UpdateRequestEvent requestWebSockets() throws Exception { + public UpdateRequestEvent requestDo() throws Exception { LogHelper.debug("Start update request"); UpdateRequestEvent e = (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this); LogHelper.debug("Start update"); @@ -243,19 +232,13 @@ public UpdateRequestEvent requestWebSockets() throws Exception { private transient Instant startTime; @LauncherAPI - public UpdateRequest(LauncherConfig config, String dirName, Path dir, FileNameMatcher matcher, boolean digest) { - super(config); + public UpdateRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest) { this.dirName = IOHelper.verifyFileName(dirName); this.dir = Objects.requireNonNull(dir, "dir"); this.matcher = matcher; this.digest = digest; } - @LauncherAPI - public UpdateRequest(String dirName, Path dir, FileNameMatcher matcher, boolean digest) { - this(null, dirName, dir, matcher, digest); - } - private void deleteExtraDir(Path subDir, HashedDir subHDir, boolean flag) throws IOException { for (Entry mapEntry : subHDir.map().entrySet()) { String name = mapEntry.getKey(); diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java index d28b823e..f1c80a91 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/BatchProfileByUsernameRequest.java @@ -1,16 +1,11 @@ package ru.gravit.launcher.request.uuid; import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.events.request.BatchProfileByUsernameRequestEvent; -import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; -import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.websockets.LegacyRequestBridge; import ru.gravit.launcher.request.websockets.RequestInterface; -import ru.gravit.launcher.serialize.HInput; -import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.VerifyHelper; @@ -28,8 +23,7 @@ class Entry { private final Entry[] list; @LauncherAPI - public BatchProfileByUsernameRequest(LauncherConfig config, String... usernames) throws IOException { - super(config); + public BatchProfileByUsernameRequest(String... usernames) throws IOException { this.list = new Entry[usernames.length]; for(int i=0;i