Skip to content

Commit

Permalink
Get MojangProfile username from the request (#60)
Browse files Browse the repository at this point in the history
* Update MojangProfileAPI.java

* ✨Improved the name fetching

---------

Co-authored-by: Mariusz Matyszczak <[email protected]>
  • Loading branch information
bumpyJake and MarcusSlover authored Dec 19, 2024
1 parent bf08d62 commit 6493734
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ public static void clean(@NotNull UUID uuid) {
} catch (IllegalArgumentException e) {
throw new RuntimeException("Could not parse UUID from Mojang API response", e);
}
if (!json.has("name")) {
throw new RuntimeException("Invalid response from Mojang API");
}
String name = json.get("name").getAsString();

// Create the profile
MojangProfile mojangProfile = new MojangProfile(uuid, username, System.currentTimeMillis());
MojangProfile mojangProfile = new MojangProfile(uuid, name, System.currentTimeMillis());

// Cache the profile
CACHED_PROFILE_MAP.put(uuid, mojangProfile);
Expand Down

0 comments on commit 6493734

Please sign in to comment.