diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketService.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketService.java index 135c5759..d4e384a6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/WebSocketService.java @@ -16,6 +16,7 @@ import ru.gravit.launchserver.websocket.json.EchoResponse; import ru.gravit.launchserver.websocket.json.JsonResponseAdapter; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.launchserver.websocket.json.admin.AddLogListenerResponse; import ru.gravit.launchserver.websocket.json.admin.ExecCommandResponse; import ru.gravit.launchserver.websocket.json.auth.*; @@ -54,8 +55,15 @@ public WebSocketService(ChannelGroup channels, LaunchServer server, GsonBuilder void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client) { String request = frame.text(); JsonResponseInterface response = gson.fromJson(request, JsonResponseInterface.class); + if(response instanceof SimpleResponse) + { + SimpleResponse simpleResponse = (SimpleResponse) response; + simpleResponse.server = server; + simpleResponse.service = this; + simpleResponse.ctx = ctx; + } try { - response.execute(this, ctx, client); + response.execute(ctx, client); } catch (Exception e) { LogHelper.error(e); sendObject(ctx, new ExceptionResult(e)); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/EchoResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/EchoResponse.java index 763c3ab8..9643297d 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/EchoResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/EchoResponse.java @@ -6,7 +6,7 @@ import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.utils.helper.LogHelper; -public class EchoResponse implements JsonResponseInterface { +public class EchoResponse extends SimpleResponse { public final String echo; public EchoResponse(String echo) { @@ -19,9 +19,8 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) { + public void execute(ChannelHandlerContext ctx, Client client) { LogHelper.info("Echo: %s, isAuth %s", echo, client.isAuth ? "true" : "false"); service.sendObject(ctx, new EchoRequestEvent(echo)); } - } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/JsonResponseInterface.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/JsonResponseInterface.java index 6a5799f1..ae169826 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/JsonResponseInterface.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/JsonResponseInterface.java @@ -7,5 +7,5 @@ public interface JsonResponseInterface { String getType(); - void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception; + void execute(ChannelHandlerContext ctx, Client client) throws Exception; } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/SimpleResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/SimpleResponse.java index 0eb42c82..e15b8382 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/SimpleResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/SimpleResponse.java @@ -1,17 +1,39 @@ package ru.gravit.launchserver.websocket.json; import io.netty.channel.ChannelHandlerContext; +import ru.gravit.launcher.events.RequestEvent; +import ru.gravit.launcher.events.request.ErrorRequestEvent; +import ru.gravit.launcher.request.ResultInterface; +import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; -public class SimpleResponse implements JsonResponseInterface { - @Override - public String getType() { - return null; +import java.util.UUID; + +public abstract class SimpleResponse implements JsonResponseInterface { + public UUID requestUUID; + public transient LaunchServer server; + public transient WebSocketService service; + public transient ChannelHandlerContext ctx; + public void sendResult(RequestEvent result) + { + result.requestUUID = requestUUID; + service.sendObject(ctx, result); + } + public void sendResultAndClose(RequestEvent result) + { + result.requestUUID = requestUUID; + service.sendObjectAndClose(ctx, result); + } + public void sendError(String errorMessage) + { + ErrorRequestEvent event = new ErrorRequestEvent(errorMessage); + event.requestUUID = requestUUID; + service.sendObject(ctx, event); } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java index eaebab44..844ed685 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/AddLogListenerResponse.java @@ -5,10 +5,10 @@ import ru.gravit.launcher.events.request.LogEvent; import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; -import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.utils.helper.LogHelper; -public class AddLogListenerResponse implements JsonResponseInterface { +public class AddLogListenerResponse extends SimpleResponse { public LogHelper.OutputTypes outputType = LogHelper.OutputTypes.PLAIN; @Override @@ -17,13 +17,13 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { if (!client.isAuth) { - service.sendObject(ctx, new ErrorRequestEvent("Access denied")); + sendError("Access denied"); return; } if (!client.permissions.canAdmin) { - service.sendObject(ctx, new ErrorRequestEvent("Access denied")); + sendError("Access denied"); return; } if (client.logOutput != null) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java index 62c33bb3..6b79e2ce 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/admin/ExecCommandResponse.java @@ -7,8 +7,9 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; -public class ExecCommandResponse implements JsonResponseInterface { +public class ExecCommandResponse extends SimpleResponse { public String cmd; @Override @@ -17,12 +18,12 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) { + public void execute(ChannelHandlerContext ctx, Client client) { if (!client.isAuth || !client.permissions.canAdmin) { - service.sendObject(ctx, new ErrorRequestEvent("Access denied")); + sendError("Access denied"); return; } LaunchServer.server.commandHandler.eval(cmd, false); - service.sendObject(ctx, new ExecCommandRequestEvent(true)); + sendResult(new ExecCommandRequestEvent(true)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java index 5e9bedaf..89caf727 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/AuthResponse.java @@ -14,6 +14,7 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse; import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; @@ -27,7 +28,7 @@ import java.util.Random; import java.util.UUID; -public class AuthResponse implements JsonResponseInterface { +public class AuthResponse extends SimpleResponse { public transient static Random random = new SecureRandom(); public String login; public String client; @@ -58,7 +59,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client clientData) throws Exception { + public void execute(ChannelHandlerContext ctx, Client clientData) throws Exception { try { AuthRequestEvent result = new AuthRequestEvent(); String ip = IOHelper.getIP(ctx.channel().remoteAddress()); @@ -126,9 +127,9 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client result.playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, aresult.username, client, clientData.auth.textureProvider); LogHelper.debug("Auth: %s accessToken %s uuid: %s", login, result.accessToken, uuid.toString()); } - service.sendObject(ctx, result); + sendResult(result); } catch (AuthException | HWIDException e) { - service.sendObject(ctx, new ErrorRequestEvent(e.getMessage())); + sendError(e.getMessage()); } } public static class AuthContext { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/CheckServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/CheckServerResponse.java index 584b6e8e..e83d6744 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/CheckServerResponse.java @@ -8,10 +8,11 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse; import ru.gravit.utils.helper.LogHelper; -public class CheckServerResponse implements JsonResponseInterface { +public class CheckServerResponse extends SimpleResponse { public String serverID; public String username; public String client; @@ -22,7 +23,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client pClient) { + public void execute(ChannelHandlerContext ctx, Client pClient) { CheckServerRequestEvent result = new CheckServerRequestEvent(); try { result.uuid = pClient.auth.handler.checkServer(username, serverID); @@ -30,14 +31,14 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client result.playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, result.uuid, username, client, pClient.auth.textureProvider); LogHelper.debug("checkServer: %s uuid: %s serverID: %s", result.playerProfile.username, result.uuid.toString(), serverID); } catch (AuthException e) { - service.sendObject(ctx, new ErrorRequestEvent(e.getMessage())); + sendError(e.getMessage()); return; } catch (Exception e) { LogHelper.error(e); - service.sendObject(ctx, new ErrorRequestEvent("Internal authHandler error")); + sendError("Internal authHandler error"); return; } - service.sendObject(ctx, result); + sendResult(result); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java index 858277d1..64a32541 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/GetAvailabilityAuthResponse.java @@ -7,23 +7,24 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import java.util.ArrayList; import java.util.List; -public class GetAvailabilityAuthResponse implements JsonResponseInterface { +public class GetAvailabilityAuthResponse extends SimpleResponse { @Override public String getType() { return "getAvailabilityAuth"; } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { List list = new ArrayList<>(); for(AuthProviderPair pair : LaunchServer.server.config.auth) { list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName)); } - service.sendObject(ctx, new GetAvailabilityAuthRequestEvent(list)); + sendResult(new GetAvailabilityAuthRequestEvent(list)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java index 325727a9..03fc292c 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/JoinServerResponse.java @@ -8,9 +8,10 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.utils.helper.LogHelper; -public class JoinServerResponse implements JsonResponseInterface { +public class JoinServerResponse extends SimpleResponse { public String serverID; public String accessToken; public String username; @@ -21,7 +22,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) { + public void execute(ChannelHandlerContext ctx, Client client) { boolean success; try { if(client.auth == null) @@ -32,14 +33,14 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client else success = client.auth.handler.joinServer(username, accessToken, serverID); LogHelper.debug("joinServer: %s accessToken: %s serverID: %s", username, accessToken, serverID); } catch (AuthException e) { - service.sendObject(ctx, new ErrorRequestEvent(e.getMessage())); + sendError(e.getMessage()); return; } catch (Exception e) { LogHelper.error(e); - service.sendObject(ctx, new ErrorRequestEvent("Internal authHandler error")); + sendError("Internal authHandler error"); return; } - service.sendObject(ctx, new JoinServerRequestEvent(success)); + sendResult(new JoinServerRequestEvent(success)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/ProfilesResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/ProfilesResponse.java index 3d1d3fa3..4394154f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/ProfilesResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/ProfilesResponse.java @@ -8,21 +8,22 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import java.util.List; -public class ProfilesResponse implements JsonResponseInterface { +public class ProfilesResponse extends SimpleResponse { @Override public String getType() { return "profiles"; } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { if (!client.checkSign && !client.isAuth) { service.sendObject(ctx, new ErrorRequestEvent("Access denied")); return; } - service.sendObject(ctx, new ProfilesRequestEvent((List) LaunchServer.server.getProfiles())); + sendResult(new ProfilesRequestEvent(LaunchServer.server.getProfiles())); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java index 08f12c65..3c12ee00 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/RestoreSessionResponse.java @@ -9,8 +9,9 @@ import ru.gravit.launchserver.websocket.WebSocketFrameHandler; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; -public class RestoreSessionResponse implements JsonResponseInterface { +public class RestoreSessionResponse extends SimpleResponse { @LauncherNetworkAPI public long session; @Override @@ -19,14 +20,14 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { Client rClient = LaunchServer.server.sessionManager.getClient(session); if(rClient == null) { - service.sendObject(ctx, new ErrorRequestEvent("Session invalid")); + sendError("Session invalid"); } WebSocketFrameHandler frameHandler = ctx.pipeline().get(WebSocketFrameHandler.class); frameHandler.setClient(rClient); - service.sendObject(ctx, new RestoreSessionRequestEvent()); + sendResult(new RestoreSessionRequestEvent()); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java index 1472651f..ab01f37f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/auth/SetProfileResponse.java @@ -8,10 +8,11 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import java.util.Collection; -public class SetProfileResponse implements JsonResponseInterface { +public class SetProfileResponse extends SimpleResponse { public String client; @Override @@ -20,23 +21,23 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { if (!client.isAuth) { - service.sendObject(ctx, new ErrorRequestEvent("Access denied")); + sendError("Access denied"); return; } Collection profiles = LaunchServer.server.getProfiles(); for (ClientProfile p : profiles) { if (p.getTitle().equals(this.client)) { if (!p.isWhitelistContains(client.username)) { - service.sendObject(ctx, new ErrorRequestEvent(LaunchServer.server.config.whitelistRejectString)); + sendError(LaunchServer.server.config.whitelistRejectString); return; } client.profile = p; - service.sendObject(ctx, new SetProfileRequestEvent(p)); + sendResult(new SetProfileRequestEvent(p)); return; } } - service.sendObject(ctx, new ErrorRequestEvent("Profile not found")); + sendError("Profile not found"); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java index 2084920d..1d23aa4e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/BatchProfileByUsername.java @@ -7,11 +7,12 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.utils.helper.LogHelper; import java.util.UUID; -public class BatchProfileByUsername implements JsonResponseInterface { +public class BatchProfileByUsername extends SimpleResponse { class Entry { String username; String client; @@ -25,7 +26,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent(); result.playerProfiles = new PlayerProfile[list.length]; for (int i = 0; i < list.length; ++i) { @@ -38,6 +39,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client else uuid = client.auth.handler.usernameToUUID(list[i].username); result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider); } - service.sendObject(ctx, result); + sendResult(result); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java index b8daef3d..2a5b0b89 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUUIDResponse.java @@ -9,12 +9,13 @@ import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; import ru.gravit.launchserver.auth.texture.TextureProvider; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.utils.helper.LogHelper; import java.io.IOException; import java.util.UUID; -public class ProfileByUUIDResponse implements JsonResponseInterface { +public class ProfileByUUIDResponse extends SimpleResponse { public UUID uuid; public String client; @@ -47,7 +48,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { String username; if(client.auth == null) { @@ -55,6 +56,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client username = LaunchServer.server.config.getAuthProviderPair().handler.uuidToUsername(uuid); } else username = client.auth.handler.uuidToUsername(uuid); - service.sendObject(ctx, new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); + sendResult(new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java index d4fb4b43..bddfb0df 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/profile/ProfileByUsername.java @@ -6,13 +6,14 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.utils.helper.LogHelper; import java.util.UUID; import static ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse.getProfile; -public class ProfileByUsername implements JsonResponseInterface { +public class ProfileByUsername extends SimpleResponse { String username; String client; @@ -22,7 +23,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { UUID uuid; if(client.auth == null) { @@ -30,6 +31,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(username); } else uuid = client.auth.handler.usernameToUUID(username); - service.sendObject(ctx, new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); + sendResult(new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider))); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java index 034076d6..ebddfa74 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/GetSecureTokenResponse.java @@ -6,17 +6,18 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; -public class GetSecureTokenResponse implements JsonResponseInterface { +public class GetSecureTokenResponse extends SimpleResponse { @Override public String getType() { return "getSecureToken"; } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { String secureToken = LaunchServer.server.config.protectHandler.generateClientSecureToken(); client.verifyToken = secureToken; - service.sendObject(ctx, new GetSecureTokenRequestEvent(secureToken)); + sendResult(new GetSecureTokenRequestEvent(secureToken)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java index 64c91aa8..0c6d2172 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/secure/VerifySecureTokenResponse.java @@ -6,8 +6,9 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; -public class VerifySecureTokenResponse implements JsonResponseInterface { +public class VerifySecureTokenResponse extends SimpleResponse { public String secureToken; @Override @@ -16,9 +17,9 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { boolean success = LaunchServer.server.config.protectHandler.verifyClientSecureToken(secureToken, client.verifyToken); if(success) client.isSecure = true; - service.sendObject(ctx, new VerifySecureTokenRequestEvent(success)); + sendResult(new VerifySecureTokenRequestEvent(success)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/LauncherResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/LauncherResponse.java index d931c860..293a308e 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/LauncherResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/LauncherResponse.java @@ -7,12 +7,13 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import ru.gravit.utils.Version; import java.util.Arrays; import java.util.Base64; -public class LauncherResponse implements JsonResponseInterface { +public class LauncherResponse extends SimpleResponse { public Version version; public String hash; public byte[] digest; @@ -27,7 +28,7 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) { + public void execute(ChannelHandlerContext ctx, Client client) { byte[] bytes; if (hash != null) bytes = Base64.getDecoder().decode(hash); @@ -49,11 +50,11 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client if (hash == null) service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, EXE_URL)); if (Arrays.equals(bytes, hash)) { client.checkSign = true; - service.sendObject(ctx, new LauncherRequestEvent(false, EXE_URL)); + sendResult(new LauncherRequestEvent(false, EXE_URL)); } else { - service.sendObjectAndClose(ctx, new LauncherRequestEvent(true, EXE_URL)); + sendResultAndClose(new LauncherRequestEvent(true, EXE_URL)); } - } else service.sendObject(ctx, new ErrorRequestEvent("Request launcher type error")); + } else sendError("Request launcher type error"); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateListResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateListResponse.java index 78809d75..ea15b5ec 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateListResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateListResponse.java @@ -9,11 +9,12 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; import java.util.HashSet; import java.util.Map; -public class UpdateListResponse implements JsonResponseInterface { +public class UpdateListResponse extends SimpleResponse { @Override public String getType() { @@ -21,15 +22,15 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) { + public void execute(ChannelHandlerContext ctx, Client client) { if (!client.isAuth) { - service.sendObject(ctx, new ErrorRequestEvent("Access denied")); + sendError("Access denied"); return; } HashSet set = new HashSet<>(); for (Map.Entry> entry : LaunchServer.server.updatesDirMap.entrySet()) set.add(entry.getKey()); - service.sendObject(ctx, new UpdateListRequestEvent(set)); + sendResult(new UpdateListRequestEvent(set)); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java index 39f95004..4a051037 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/json/update/UpdateResponse.java @@ -10,8 +10,9 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.launchserver.websocket.json.SimpleResponse; -public class UpdateResponse implements JsonResponseInterface { +public class UpdateResponse extends SimpleResponse { public String dirName; @Override @@ -20,9 +21,9 @@ public String getType() { } @Override - public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { if (!client.isAuth || client.type != Client.Type.USER || client.profile == null) { - service.sendObject(ctx, new ErrorRequestEvent("Access denied")); + sendError("Access denied"); return; } if (!client.permissions.canAdmin) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/RequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/RequestEvent.java new file mode 100644 index 00000000..0c7869d7 --- /dev/null +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/RequestEvent.java @@ -0,0 +1,9 @@ +package ru.gravit.launcher.events; + +import ru.gravit.launcher.request.ResultInterface; + +import java.util.UUID; + +public abstract class RequestEvent implements ResultInterface { + public UUID requestUUID; +} diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java index 98bc520d..d47f9473 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/AuthRequestEvent.java @@ -2,13 +2,14 @@ import ru.gravit.launcher.ClientPermissions; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class AuthRequestEvent implements EventInterface, ResultInterface { +public class AuthRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74"); public AuthRequestEvent() { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java index 30a0d35c..97f3846a 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/BatchProfileByUsernameRequestEvent.java @@ -1,13 +1,14 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class BatchProfileByUsernameRequestEvent implements EventInterface, ResultInterface { +public class BatchProfileByUsernameRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("c1d6729e-be2c-48cc-b5ae-af8c012232c3"); @LauncherNetworkAPI public String error; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java index 02d2ad86..6ed8ee73 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/CheckServerRequestEvent.java @@ -1,13 +1,14 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class CheckServerRequestEvent implements EventInterface, ResultInterface { +public class CheckServerRequestEvent extends RequestEvent implements EventInterface { private static final UUID _uuid = UUID.fromString("8801d07c-51ba-4059-b61d-fe1f1510b28a"); @LauncherNetworkAPI public UUID uuid; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java index 3395d32a..ef914314 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/EchoRequestEvent.java @@ -1,12 +1,13 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class EchoRequestEvent implements ResultInterface, EventInterface { +public class EchoRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("0a1f820f-7cd5-47a5-ae0e-17492e0e1fe1"); @LauncherNetworkAPI public String echo; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java index d2e8b06b..dabe290c 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ErrorRequestEvent.java @@ -1,12 +1,13 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class ErrorRequestEvent implements ResultInterface, EventInterface { +public class ErrorRequestEvent extends RequestEvent implements EventInterface { public static UUID uuid = UUID.fromString("0af22bc7-aa01-4881-bdbb-dc62b3cdac96"); public ErrorRequestEvent(String error) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java index 0446d8a1..65536551 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ExecCommandRequestEvent.java @@ -1,9 +1,10 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; -public class ExecCommandRequestEvent implements ResultInterface { +public class ExecCommandRequestEvent extends RequestEvent { @Override public String getType() { return "cmdExec"; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java index db1517f5..ab1798e8 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java @@ -1,11 +1,12 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; import java.util.List; -public class GetAvailabilityAuthRequestEvent implements ResultInterface { +public class GetAvailabilityAuthRequestEvent extends RequestEvent { public static class AuthAvailability { @LauncherNetworkAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java index 35fece1e..27685edf 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/GetSecureTokenRequestEvent.java @@ -1,9 +1,10 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; -public class GetSecureTokenRequestEvent implements ResultInterface { +public class GetSecureTokenRequestEvent extends RequestEvent { @LauncherNetworkAPI public String secureToken; @Override diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java index 95483d07..0a65ede4 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/JoinServerRequestEvent.java @@ -1,12 +1,13 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class JoinServerRequestEvent implements EventInterface, ResultInterface { +public class JoinServerRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("2a12e7b5-3f4a-4891-a2f9-ea141c8e1995"); public JoinServerRequestEvent(boolean allow) { diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java index 24e57760..03544636 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/LauncherRequestEvent.java @@ -1,12 +1,13 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class LauncherRequestEvent implements EventInterface, ResultInterface { +public class LauncherRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("d54cc12a-4f59-4f23-9b10-f527fdd2e38f"); @LauncherNetworkAPI public String url; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java index c28f5d6d..5b374e48 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUUIDRequestEvent.java @@ -1,13 +1,14 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class ProfileByUUIDRequestEvent implements EventInterface, ResultInterface { +public class ProfileByUUIDRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("b9014cf3-4b95-4d38-8c5f-867f190a18a0"); @LauncherNetworkAPI public String error; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java index fcdfdffd..6a7ac737 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfileByUsernameRequestEvent.java @@ -1,13 +1,14 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class ProfileByUsernameRequestEvent implements EventInterface, ResultInterface { +public class ProfileByUsernameRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("06204302-ff6b-4779-b97d-541e3bc39aa1"); @LauncherNetworkAPI public String error; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java index 63fbbccf..c51ef256 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/ProfilesRequestEvent.java @@ -1,6 +1,7 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; @@ -8,7 +9,7 @@ import java.util.List; import java.util.UUID; -public class ProfilesRequestEvent implements EventInterface, ResultInterface { +public class ProfilesRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("2f26fbdf-598a-46dd-92fc-1699c0e173b1"); @LauncherNetworkAPI public List profiles; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java index 8a8e21be..2262b152 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/RestoreSessionRequestEvent.java @@ -1,8 +1,8 @@ package ru.gravit.launcher.events.request; -import ru.gravit.launcher.request.ResultInterface; +import ru.gravit.launcher.events.RequestEvent; -public class RestoreSessionRequestEvent implements ResultInterface { +public class RestoreSessionRequestEvent extends RequestEvent { @Override public String getType() { return "restoreSession"; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java index 2983d696..349705a4 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/SetProfileRequestEvent.java @@ -1,13 +1,14 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.UUID; -public class SetProfileRequestEvent implements ResultInterface, EventInterface { +public class SetProfileRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("08c0de9e-4364-4152-9066-8354a3a48541"); @LauncherNetworkAPI public ClientProfile newProfile; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java index b11e26d5..4079a4a2 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateListRequestEvent.java @@ -1,13 +1,14 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; import ru.gravit.utils.event.EventInterface; import java.util.HashSet; import java.util.UUID; -public class UpdateListRequestEvent implements EventInterface, ResultInterface { +public class UpdateListRequestEvent extends RequestEvent implements EventInterface { private static final UUID uuid = UUID.fromString("5fa836ae-6b61-401c-96ac-d8396f07ec6b"); @LauncherNetworkAPI public final HashSet dirs; diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java index c409dd8f..69523ff5 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java @@ -1,10 +1,11 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherNetworkAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.request.ResultInterface; -public class UpdateRequestEvent implements ResultInterface { +public class UpdateRequestEvent extends RequestEvent { @LauncherNetworkAPI public HashedDir hdir; @LauncherNetworkAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java index 5ad3fca1..7de245de 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/VerifySecureTokenRequestEvent.java @@ -1,9 +1,10 @@ package ru.gravit.launcher.events.request; import ru.gravit.launcher.LauncherAPI; +import ru.gravit.launcher.events.RequestEvent; import ru.gravit.launcher.request.ResultInterface; -public class VerifySecureTokenRequestEvent implements ResultInterface { +public class VerifySecureTokenRequestEvent extends RequestEvent { @LauncherAPI public boolean success; @Override