diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java index 83a50d35..11e4b684 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java @@ -234,7 +234,8 @@ public CheckServerReport checkServer(Client client, String username, String serv if (client.auth == null) return null; if (client.auth.isUseCore()) { User user = client.auth.core.checkServer(client, username, serverID); - return user == null ? null : CheckServerReport.ofUser(user, getPlayerProfile(user)); + if (user == null) return null; + else return CheckServerReport.ofUser(user, getPlayerProfile(client.auth, user)); } else { UUID uuid = client.auth.handler.checkServer(username, serverID); return uuid == null ? null : CheckServerReport.ofUUID(uuid, getPlayerProfile(client.auth, uuid)); @@ -255,7 +256,7 @@ public PlayerProfile getPlayerProfile(Client client) { PlayerProfile playerProfile; if (client.useOAuth) { User user = client.getUser(); - playerProfile = getPlayerProfile(user); + playerProfile = getPlayerProfile(client.auth, user); if (playerProfile != null) return playerProfile; } if (client.auth.textureProvider != null) { @@ -273,7 +274,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username, Cl UUID uuid = null; if (pair.isUseCore()) { User user = pair.core.getUserByUsername(username); - PlayerProfile playerProfile = getPlayerProfile(user); + PlayerProfile playerProfile = getPlayerProfile(pair, user); uuid = user.getUUID(); if (playerProfile != null) return playerProfile; } else { @@ -300,7 +301,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr String username = null; if (pair.isUseCore()) { User user = pair.core.getUserByUUID(uuid); - PlayerProfile playerProfile = getPlayerProfile(user); + PlayerProfile playerProfile = getPlayerProfile(pair, user); username = user.getUsername(); if (playerProfile != null) return playerProfile; } else { @@ -319,11 +320,11 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr return new PlayerProfile(uuid, username, null, null); } - public PlayerProfile getPlayerProfile(User user) { + public PlayerProfile getPlayerProfile(AuthProviderPair pair, User user) { if (user instanceof UserSupportTextures) { return new PlayerProfile(user.getUUID(), user.getUsername(), ((UserSupportTextures) user).getSkinTexture(), ((UserSupportTextures) user).getCloakTexture()); } - return null; + return getPlayerProfile(user.getUUID(), user.getUsername(), "", pair.textureProvider); } private PlayerProfile getPlayerProfile(UUID uuid, String username, String client, TextureProvider textureProvider) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java index ac289125..4eb257fd 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/CheckServerResponse.java @@ -34,13 +34,13 @@ public void execute(ChannelHandlerContext ctx, Client pClient) { if (report != null) { result.playerProfile = report.playerProfile; result.uuid = report.uuid; - logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile.username, result.uuid, serverID); + logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile == null ? null : result.playerProfile.username, result.uuid, serverID); } } catch (AuthException | HookException e) { sendError(e.getMessage()); return; } catch (Exception e) { - logger.error(e); + logger.error("Internal authHandler error", e); sendError("Internal authHandler error"); return; } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index f8a4dd89..a93d4840 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -140,13 +140,19 @@ public void run(String... args) throws Throwable { if (config.logFile != null) LogHelper.addOutput(IOHelper.newWriter(Paths.get(config.logFile), true)); { if (config.saveSession) { + boolean needRestore = false; if (config.oauth != null) { Request.setOAuth(config.auth_id, config.oauth, config.oauthExpireTime); - } else { + needRestore = true; + } else if (config.session != null) { Request.setSession(config.session); + needRestore = true; + } else { + auth(); } try { - Request.restore(); + if (needRestore) + Request.restore(); } catch (Exception e) { LogHelper.error(e); auth();