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 7b22e4d2..2084920d 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,6 +7,7 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.utils.helper.LogHelper; import java.util.UUID; @@ -28,7 +29,13 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent(); result.playerProfiles = new PlayerProfile[list.length]; 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); } service.sendObject(ctx, 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 5b9a4a44..b8daef3d 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 @@ -48,7 +48,13 @@ public String getType() { @Override 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))); } } 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 ea9a8f96..d4fb4b43 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,6 +6,7 @@ import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.websocket.WebSocketService; import ru.gravit.launchserver.websocket.json.JsonResponseInterface; +import ru.gravit.utils.helper.LogHelper; import java.util.UUID; @@ -22,7 +23,13 @@ public String getType() { @Override 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))); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 1f9ab3e3..62f8339c 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -468,27 +468,24 @@ public static void main(String... args) throws Throwable { // Start client with WatchService monitoring boolean digest = !profile.isUpdateFastCheck(); LogHelper.debug("Restore sessions"); - if(Launcher.getConfig().isNettyEnabled) + RestoreSessionRequest request = new RestoreSessionRequest(Request.getSession()); + request.request(); + LegacyRequestBridge.service.reconnectCallback = () -> { - RestoreSessionRequest request = new RestoreSessionRequest(Request.getSession()); - request.request(); - LegacyRequestBridge.service.reconnectCallback = () -> - { - LogHelper.debug("WebSocket connect closed. Try reconnect"); - try { - if (!LegacyRequestBridge.service.reconnectBlocking()) LogHelper.error("Error connecting"); - LogHelper.debug("Connect to %s", Launcher.getConfig().address); - } catch (InterruptedException e) { - e.printStackTrace(); - } - try { - RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession()); - request1.request(); - } catch (Exception e) { - LogHelper.error(e); - } - }; - } + LogHelper.debug("WebSocket connect closed. Try reconnect"); + try { + if (!LegacyRequestBridge.service.reconnectBlocking()) LogHelper.error("Error connecting"); + LogHelper.debug("Connect to %s", Launcher.getConfig().address); + } catch (InterruptedException e) { + e.printStackTrace(); + } + try { + RestoreSessionRequest request1 = new RestoreSessionRequest(Request.getSession()); + request1.request(); + } catch (Exception e) { + LogHelper.error(e); + } + }; LogHelper.debug("Starting JVM and client WatchService"); FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher(); FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();