Skip to content

Commit fa76baa

Browse files
author
TheProgramSrc
committed
Changelog:
* Fixed error being thrown when checking for SkinTexture from Mojang.
1 parent 5962e4d commit fa76baa

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>4.1.2</version>
9+
<version>4.1.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/utils/skintexture/SkinTexture.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public static SkinTexture fromPlayer(Player player) {
6262
* @return the skin
6363
*/
6464
public static SkinTexture fromMojang(String playerName) {
65-
String uuid = (new JsonParser()).parse(getResponse("https://api.mojang.com/users/profiles/minecraft/" + playerName)).getAsJsonObject().get("id").getAsString();
65+
String response = getResponse("https://api.mojang.com/users/profiles/minecraft/" + playerName);
66+
if(response == null)
67+
return null;
68+
String uuid = (new JsonParser()).parse(getResponse(response)).getAsJsonObject().get("id").getAsString();
6669
String fullUUID = Utils.uuidToFullUUID(uuid);
6770
return fromMojang(UUID.fromString(fullUUID));
6871
}
@@ -73,7 +76,10 @@ public static SkinTexture fromMojang(String playerName) {
7376
* @return the skin
7477
*/
7578
public static SkinTexture fromMojang(UUID uuid) {
76-
JsonObject properties = (new JsonParser()).parse(getResponse("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "") + "?unsigned=false")).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
79+
String response = getResponse("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "") + "?unsigned=false");
80+
if(response == null)
81+
return null;
82+
JsonObject properties = (new JsonParser()).parse(response).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
7783
String value = properties.get("value").getAsString();
7884
return new SkinTexture(base64ToUrl(value));
7985
}

0 commit comments

Comments
 (0)