mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Catch exceptions during skin request
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
3674fcc97d
commit
446e4a64b7
@ -26,16 +26,20 @@ public record PlayerSkin(String textures, String signature) {
|
|||||||
public static @Nullable PlayerSkin fromUuid(@NotNull String uuid) {
|
public static @Nullable PlayerSkin fromUuid(@NotNull String uuid) {
|
||||||
final JsonObject jsonObject = MojangUtils.fromUuid(uuid);
|
final JsonObject jsonObject = MojangUtils.fromUuid(uuid);
|
||||||
if (jsonObject == null) return null;
|
if (jsonObject == null) return null;
|
||||||
final JsonArray propertiesArray = jsonObject.get("properties").getAsJsonArray();
|
try {
|
||||||
for (JsonElement jsonElement : propertiesArray) {
|
final JsonArray propertiesArray = jsonObject.get("properties").getAsJsonArray();
|
||||||
final JsonObject propertyObject = jsonElement.getAsJsonObject();
|
for (JsonElement jsonElement : propertiesArray) {
|
||||||
final String name = propertyObject.get("name").getAsString();
|
final JsonObject propertyObject = jsonElement.getAsJsonObject();
|
||||||
if (!name.equals("textures")) continue;
|
final String name = propertyObject.get("name").getAsString();
|
||||||
final String textureValue = propertyObject.get("value").getAsString();
|
if (!name.equals("textures")) continue;
|
||||||
final String signatureValue = propertyObject.get("signature").getAsString();
|
final String textureValue = propertyObject.get("value").getAsString();
|
||||||
return new PlayerSkin(textureValue, signatureValue);
|
final String signatureValue = propertyObject.get("signature").getAsString();
|
||||||
|
return new PlayerSkin(textureValue, signatureValue);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,9 +52,13 @@ public record PlayerSkin(String textures, String signature) {
|
|||||||
public static @Nullable PlayerSkin fromUsername(@NotNull String username) {
|
public static @Nullable PlayerSkin fromUsername(@NotNull String username) {
|
||||||
final JsonObject jsonObject = MojangUtils.fromUsername(username);
|
final JsonObject jsonObject = MojangUtils.fromUsername(username);
|
||||||
if (jsonObject == null) return null;
|
if (jsonObject == null) return null;
|
||||||
final String uuid = jsonObject.get("id").getAsString();
|
try {
|
||||||
// Retrieve the skin data from the mojang uuid
|
final String uuid = jsonObject.get("id").getAsString();
|
||||||
return fromUuid(uuid);
|
// Retrieve the skin data from the mojang uuid
|
||||||
|
return fromUuid(uuid);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user