[FIX] Фикс бага с ошибкой при восстановлении сессии

This commit is contained in:
Gravit 2019-04-07 16:55:52 +07:00
parent 54c7526a66
commit a540bdcf48
4 changed files with 40 additions and 23 deletions

View file

@ -7,6 +7,7 @@
import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface; import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.utils.helper.LogHelper;
import java.util.UUID; import java.util.UUID;
@ -28,7 +29,13 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent(); BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
result.playerProfiles = new PlayerProfile[list.length]; result.playerProfiles = new PlayerProfile[list.length];
for (int i = 0; i < list.length; ++i) { for (int i = 0; i < list.length; ++i) {
UUID uuid = client.auth.handler.usernameToUUID(list[i].username); UUID uuid;
if(client.auth == null)
{
LogHelper.warning("Client auth is null. Using default.");
uuid = LaunchServer.server.config.getAuthProviderPair().handler.usernameToUUID(list[i].username);
}
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); result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider);
} }
service.sendObject(ctx, result); service.sendObject(ctx, result);

View file

@ -48,7 +48,13 @@ public String getType() {
@Override @Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
String username = client.auth.handler.uuidToUsername(uuid); String username;
if(client.auth == null)
{
LogHelper.warning("Client auth is null. Using default.");
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))); service.sendObject(ctx, new ProfileByUUIDRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
} }
} }

View file

@ -6,6 +6,7 @@
import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.Client;
import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.WebSocketService;
import ru.gravit.launchserver.websocket.json.JsonResponseInterface; import ru.gravit.launchserver.websocket.json.JsonResponseInterface;
import ru.gravit.utils.helper.LogHelper;
import java.util.UUID; import java.util.UUID;
@ -22,7 +23,13 @@ public String getType() {
@Override @Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
UUID uuid = client.auth.handler.usernameToUUID(username); UUID uuid;
if(client.auth == null)
{
LogHelper.warning("Client auth is null. Using default.");
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))); service.sendObject(ctx, new ProfileByUsernameRequestEvent(getProfile(LaunchServer.server, uuid, username, this.client, client.auth.textureProvider)));
} }
} }

View file

@ -468,8 +468,6 @@ public static void main(String... args) throws Throwable {
// Start client with WatchService monitoring // Start client with WatchService monitoring
boolean digest = !profile.isUpdateFastCheck(); boolean digest = !profile.isUpdateFastCheck();
LogHelper.debug("Restore sessions"); LogHelper.debug("Restore sessions");
if(Launcher.getConfig().isNettyEnabled)
{
RestoreSessionRequest request = new RestoreSessionRequest(Request.getSession()); RestoreSessionRequest request = new RestoreSessionRequest(Request.getSession());
request.request(); request.request();
LegacyRequestBridge.service.reconnectCallback = () -> LegacyRequestBridge.service.reconnectCallback = () ->
@ -488,7 +486,6 @@ public static void main(String... args) throws Throwable {
LogHelper.error(e); LogHelper.error(e);
} }
}; };
}
LogHelper.debug("Starting JVM and client WatchService"); LogHelper.debug("Starting JVM and client WatchService");
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher(); FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.getClientUpdateMatcher(); FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();