Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #30 from Paddyk45/fix-null-avatar-1
Browse files Browse the repository at this point in the history
Fix null avatars
  • Loading branch information
DAMcraft authored Jan 24, 2024
2 parents 41a16bc + ebb0e9c commit 1b83045
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/de/damcraft/serverseeker/DiscordAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void handleCode(String code) {

Systems.get(ServerSeekerSystem.class).discordId = discordId;
Systems.get(ServerSeekerSystem.class).discordUsername = discordUsername;
Systems.get(ServerSeekerSystem.class).discordAvatarUrl = discordAvatarUrl;
Systems.get(ServerSeekerSystem.class).discordAvatarUrl = discordAvatarUrl == null ? "" : discordAvatarUrl;

callback.accept(apiKey, null);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/de/damcraft/serverseeker/DiscordAvatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ public DiscordAvatar(String url) {
}
String discordId = userInfo.discord_id;
String discordUsername = userInfo.discord_username;
String discordAvatarUrl = userInfo.discord_avatar_url;
String discordAvatarUrl = userInfo.discord_avatar_url == null ? "" : userInfo.discord_avatar_url;

Systems.get(ServerSeekerSystem.class).discordId = discordId;
Systems.get(ServerSeekerSystem.class).discordUsername = discordUsername;
Systems.get(ServerSeekerSystem.class).discordAvatarUrl = discordAvatarUrl;

stream = Http.get(discordAvatarUrl).sendInputStream();
}
if (stream == null) {
System.err.println("Failed to get avatar, are you Vero?");
return;
}
avatar = ImageIO.read(stream);
} catch (IOException e) {
e.printStackTrace();
Expand Down

0 comments on commit 1b83045

Please sign in to comment.