From 27ab69cd787992902b593bb2e8c1ce55f9e343d8 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 4 Apr 2019 14:02:42 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20profileByUUID/profileByUsernam?= =?UTF-8?q?e=20=D0=BD=D0=B0=20=D0=B2=D0=B5=D0=B1=D1=81=D0=BE=D0=BA=D0=B5?= =?UTF-8?q?=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket/websocket/WebSocketService.java | 6 +++ .../uuid/BatchProfileByUsernameRequest.java | 44 ++++++++++++++----- .../request/uuid/ProfileByUUIDRequest.java | 16 ++++++- .../uuid/ProfileByUsernameRequest.java | 16 ++++++- 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java index 9464fd04..899708aa 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/WebSocketService.java @@ -19,6 +19,9 @@ import ru.gravit.launchserver.socket.websocket.json.admin.AddLogListenerResponse; import ru.gravit.launchserver.socket.websocket.json.admin.ExecCommandResponse; import ru.gravit.launchserver.socket.websocket.json.auth.*; +import ru.gravit.launchserver.socket.websocket.json.profile.BatchProfileByUsername; +import ru.gravit.launchserver.socket.websocket.json.profile.ProfileByUUIDResponse; +import ru.gravit.launchserver.socket.websocket.json.profile.ProfileByUsername; import ru.gravit.launchserver.socket.websocket.json.update.LauncherResponse; import ru.gravit.launchserver.socket.websocket.json.update.UpdateListResponse; import ru.gravit.launchserver.socket.websocket.json.update.UpdateResponse; @@ -82,6 +85,9 @@ public void registerResponses() { registerResponse("addLogListener", AddLogListenerResponse.class); registerResponse("update", UpdateResponse.class); registerResponse("restoreSession", RestoreSessionResponse.class); + registerResponse("batchProfileByUsername", BatchProfileByUsername.class); + registerResponse("profileByUsername", ProfileByUsername.class); + registerResponse("profileByUUID", ProfileByUUIDResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { 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 471b184f..752b114c 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 @@ -2,10 +2,13 @@ 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; @@ -14,15 +17,27 @@ import java.io.IOException; -public final class BatchProfileByUsernameRequest extends Request { - private final String[] usernames; +public final class BatchProfileByUsernameRequest extends Request implements RequestInterface { + class Entry { + @LauncherNetworkAPI + String username; + @LauncherNetworkAPI + String client; + } + @LauncherNetworkAPI + private final Entry[] list; @LauncherAPI public BatchProfileByUsernameRequest(LauncherConfig config, String... usernames) throws IOException { super(config); - this.usernames = usernames.clone(); - IOHelper.verifyLength(this.usernames.length, SerializeLimits.MAX_BATCH_SIZE); - for (String username : this.usernames) + this.list = new Entry[usernames.length]; + for(int i=0;i { +public final class ProfileByUUIDRequest extends Request implements RequestInterface { + @LauncherNetworkAPI private final UUID uuid; @LauncherAPI @@ -29,6 +33,11 @@ public ProfileByUUIDRequest(UUID uuid) { this(null, uuid); } + @Override + public ProfileByUUIDRequestEvent requestWebSockets() throws IOException, InterruptedException { + return (ProfileByUUIDRequestEvent) LegacyRequestBridge.sendRequest(this); + } + @Override public Integer getLegacyType() { return RequestType.PROFILE_BY_UUID.getNumber(); @@ -43,4 +52,9 @@ protected ProfileByUUIDRequestEvent requestDo(HInput input, HOutput output) thro // Return profile return input.readBoolean() ? new ProfileByUUIDRequestEvent(new PlayerProfile(input)) : null; } + + @Override + public String getType() { + return "profileByUUID"; + } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java index a256b2ef..f3d7c4c6 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/uuid/ProfileByUsernameRequest.java @@ -3,10 +3,13 @@ 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.ProfileByUsernameRequestEvent; 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; @@ -14,7 +17,8 @@ import java.io.IOException; -public final class ProfileByUsernameRequest extends Request { +public final class ProfileByUsernameRequest extends Request implements RequestInterface { + @LauncherNetworkAPI private final String username; @LauncherAPI @@ -28,6 +32,11 @@ public ProfileByUsernameRequest(String username) { this(null, username); } + @Override + public ProfileByUsernameRequestEvent requestWebSockets() throws IOException, InterruptedException { + return (ProfileByUsernameRequestEvent) LegacyRequestBridge.sendRequest(this); + } + @Override public Integer getLegacyType() { return RequestType.PROFILE_BY_USERNAME.getNumber(); @@ -41,4 +50,9 @@ protected ProfileByUsernameRequestEvent requestDo(HInput input, HOutput output) // Return profile return input.readBoolean() ? new ProfileByUsernameRequestEvent(new PlayerProfile(input)) : null; } + + @Override + public String getType() { + return "profileByUsername"; + } }