Skip to content

Commit

Permalink
1.4 Added getProfileByUuid
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward authored Apr 21, 2021
1 parent bdf12bd commit 9d5a0e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.dpkgsoft</groupId>
<artifactId>mojang</artifactId>
<version>1.3</version>
<version>1.4</version>

<build>
<plugins>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/dpkgsoft/mojang/MojangAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ public static Profile[] getProfiles(String[] playerNames) throws APIException {
}
}

public static Profile getProfileByUuid(String uuid) throws APIException {
try {
String data = Utils.get(SESSION_ENDPOINT + "session/minecraft/profile/" + uuid);
if (new JSONObject(data).has("error")) {
throw new APIException(400);
}
JSONObject json = new JSONObject(data);
return new Profile(json.getString("id"), json.getString("name"));
} catch (IOException e) {
throw new APIException(e.getMessage(), 1);
}
}

public static TexturesRequest getTextures(String uuid) throws APIException {
try {
String data = Utils.get(SESSION_ENDPOINT + "session/minecraft/profile/" + uuid + "?unsigned=false");
Expand Down

0 comments on commit 9d5a0e1

Please sign in to comment.