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"; + } }