From a540bdcf4839337176bb491ecda92320b36d9cb6 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 7 Apr 2019 16:55:52 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B3=D0=B0=20=D1=81=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=BF=D1=80=D0=B8=20=D0=B2=D0=BE=D1=81=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81?= =?UTF-8?q?=D0=B5=D1=81=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../json/profile/BatchProfileByUsername.java | 9 ++++- .../json/profile/ProfileByUUIDResponse.java | 8 +++- .../json/profile/ProfileByUsername.java | 9 ++++- .../launcher/client/ClientLauncher.java | 37 +++++++++---------- 4 files changed, 40 insertions(+), 23 deletions(-) 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();