Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more detailed error messages #1087

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.hysky.skyblocker.skyblock.profileviewer.inventory.InventoryPage;
import de.hysky.skyblocker.skyblock.profileviewer.skills.SkillsPage;
import de.hysky.skyblocker.skyblock.profileviewer.slayers.SlayersPage;
import de.hysky.skyblocker.utils.ApiAuthentication;
import de.hysky.skyblocker.utils.ApiUtils;
import de.hysky.skyblocker.utils.Http;
import de.hysky.skyblocker.utils.ProfileUtils;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class ProfileViewerScreen extends Screen {
private JsonObject hypixelProfile;
private JsonObject playerProfile;
private boolean profileNotFound = false;
private String errorMessage = "No Profile";

private int activePage = 0;
private static final String[] PAGE_NAMES = {"Skills", "Slayers", "Dungeons", "Inventories", "Collections"};
Expand Down Expand Up @@ -121,7 +123,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
profileViewerPages[activePage].markWidgetsAsVisible();
profileViewerPages[activePage].render(context, mouseX, mouseY, delta, rootX + 93, rootY + 7);
} else {
context.drawText(textRenderer, profileNotFound ? "No Profile" : "Loading...", rootX + 180, rootY + 80, Color.WHITE.getRGB(), true);
context.drawCenteredTextWithShadow(textRenderer, profileNotFound ? errorMessage : "Loading...", rootX + 200, rootY + 80, Color.WHITE.getRGB());
}
}

Expand All @@ -144,6 +146,7 @@ private CompletableFuture<Void> fetchPlayerData(String username) {
this.playerProfile = hypixelProfile.getAsJsonObject("members").get(ApiUtils.name2Uuid(username)).getAsJsonObject();
}
} catch (Exception e) {
this.errorMessage = ApiAuthentication.getToken() == null ? "Invalid Skyblocker token" : "Skyblock profile not found";
this.profileNotFound = true;
LOGGER.warn("[Skyblocker Profile Viewer] Error while looking for profile", e);
}
Expand All @@ -153,7 +156,9 @@ private CompletableFuture<Void> fetchPlayerData(String username) {
String stringifiedUuid = ApiUtils.name2Uuid(username);

if (stringifiedUuid.isEmpty()) {
// "Player not found" doesn't fit on the screen lol
this.playerName = "User not found";
this.errorMessage = "Player UUID not found";
this.profileNotFound = true;
}

Expand Down Expand Up @@ -181,7 +186,9 @@ public boolean isInvisibleTo(PlayerEntity player) {
};
entity.setCustomNameVisible(false);
}).exceptionally(ex -> {
// "Player not found" doesn't fit on the screen lol
this.playerName = "User not found";
this.errorMessage = "Player skin not found";
this.profileNotFound = true;
return null;
}).join();
Expand Down
Loading