Fix SkullBuilder on 1.20.2

This commit is contained in:
NichtStudioCode 2023-10-09 18:42:28 +02:00
parent c55b6945cd
commit 86a9fb6ea1
3 changed files with 7 additions and 4 deletions

@ -22,7 +22,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

@ -56,7 +56,7 @@ public final class SkullBuilder extends AbstractItemBuilder<SkullBuilder> {
}
private void setGameProfile(@NotNull HeadTexture texture) {
gameProfile = new GameProfile(UUID.randomUUID(), null);
gameProfile = new GameProfile(UUID.randomUUID(), "InvUI");
PropertyMap propertyMap = gameProfile.getProperties();
propertyMap.put("textures", new Property("textures", texture.getTextureValue()));
}

@ -3,7 +3,6 @@ package xyz.xenondevs.invui.util;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.util.UUIDTypeAdapter;
import java.io.IOException;
import java.io.InputStreamReader;
@ -46,12 +45,16 @@ public class MojangApiUtils {
checkForError(jsonObject);
if (jsonObject.has("id")) {
String id = jsonObject.get("id").getAsString();
return UUIDTypeAdapter.fromString(id);
return fromUndashed(id);
}
return null;
}
private static UUID fromUndashed(String undashed) {
return UUID.fromString(undashed.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
}
private static void checkForError(JsonObject jsonObject) throws MojangApiException {
if (jsonObject.has("error") && jsonObject.has("errorMessage")) {
if (jsonObject.has("errorMessage"))