mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-22 07:14:16 +03:00
[FEATURE] Портирован SetProfileResponse
This commit is contained in:
parent
52609413a2
commit
751048ab3e
2 changed files with 40 additions and 0 deletions
|
@ -20,6 +20,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
|
|||
if(!client.isAuth)
|
||||
{
|
||||
service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied"));
|
||||
return;
|
||||
}
|
||||
service.sendObject(ctx, new Result((List<ClientProfile>) LaunchServer.server.getProfiles()));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package ru.gravit.launchserver.socket.websocket.json.auth;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import ru.gravit.launcher.profiles.ClientProfile;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.launchserver.socket.websocket.WebSocketService;
|
||||
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class SetProfileResponse implements JsonResponseInterface {
|
||||
@Override
|
||||
public String getType() {
|
||||
return "setProfile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
|
||||
if(!client.isAuth)
|
||||
{
|
||||
service.sendObject(ctx, new WebSocketService.ErrorResult("Access denied"));
|
||||
return;
|
||||
}
|
||||
Collection<ClientProfile> profiles = LaunchServer.server.getProfiles();
|
||||
for (ClientProfile p : profiles) {
|
||||
if (p.getTitle().equals(client)) {
|
||||
if (!p.isWhitelistContains(client.username)) {
|
||||
service.sendObject(ctx, new WebSocketService.ErrorResult(LaunchServer.server.config.whitelistRejectString));
|
||||
return;
|
||||
}
|
||||
client.profile = p;
|
||||
service.sendObject(ctx, new WebSocketService.SuccessResult(getType()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
service.sendObject(ctx, new WebSocketService.ErrorResult("Profile not found"));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue