From 4b55674a988a2f2df4dbfde1842f21350da5838d Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Tue, 23 Apr 2024 01:09:39 -0400 Subject: [PATCH] Fallback to default icon for any errors whilst getting a server's favicon --- .../main/java/me/braydon/mc/service/MojangService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/API/src/main/java/me/braydon/mc/service/MojangService.java b/API/src/main/java/me/braydon/mc/service/MojangService.java index 1e9cc65..7d0f5b8 100644 --- a/API/src/main/java/me/braydon/mc/service/MojangService.java +++ b/API/src/main/java/me/braydon/mc/service/MojangService.java @@ -356,10 +356,13 @@ public final class MojangService { } catch (BadRequestException | ResourceNotFoundException ignored) { // Safely ignore these, we will use the default server icon } - if (icon == null) { // Use the default server icon - icon = DEFAULT_SERVER_ICON; + try { + assert icon != null; + return Base64.getDecoder().decode(icon); // Return the decoded favicon + } catch (Exception ex) { // Use the default server icon + log.error("Failed getting server favicon for %s:".formatted(hostname), ex); + return Base64.getDecoder().decode(DEFAULT_SERVER_ICON); } - return Base64.getDecoder().decode(icon); // Return the decoded favicon } /**