[FIX] AuthManager NPE

This commit is contained in:
Gravita 2021-09-12 17:52:10 +07:00
parent 9e7dedffc9
commit f0ae4cbb12
2 changed files with 12 additions and 0 deletions

View file

@ -286,6 +286,9 @@ public void invoke(String... args) throws Exception {
public User checkServer(Client client, String username, String serverID) throws IOException {
User user = getUserByUsername(username);
if (user == null) {
return null;
}
if (user.getUsername().equals(username) && user.getServerId().equals(serverID)) {
return user;
}

View file

@ -235,6 +235,9 @@ public PlayerProfile getPlayerProfile(Client client) {
PlayerProfile playerProfile;
if (client.useOAuth) {
User user = client.getUser();
if (user == null) {
return null;
}
playerProfile = getPlayerProfile(client.auth, user);
if (playerProfile != null) return playerProfile;
}
@ -253,6 +256,9 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username, Cl
UUID uuid = null;
if (pair.isUseCore()) {
User user = pair.core.getUserByUsername(username);
if (user == null) {
return null;
}
PlayerProfile playerProfile = getPlayerProfile(pair, user);
uuid = user.getUUID();
if (playerProfile != null) return playerProfile;
@ -280,6 +286,9 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr
String username = null;
if (pair.isUseCore()) {
User user = pair.core.getUserByUUID(uuid);
if (user == null) {
return null;
}
PlayerProfile playerProfile = getPlayerProfile(pair, user);
username = user.getUsername();
if (playerProfile != null) return playerProfile;