From 86a9fb6ea13eada809b88d4711099aea5172594b Mon Sep 17 00:00:00 2001
From: NichtStudioCode <51272202+NichtStudioCode@users.noreply.github.com>
Date: Mon, 9 Oct 2023 18:42:28 +0200
Subject: [PATCH] Fix SkullBuilder on 1.20.2
---
invui-core/pom.xml | 2 +-
.../xyz/xenondevs/invui/item/builder/SkullBuilder.java | 2 +-
.../main/java/xyz/xenondevs/invui/util/MojangApiUtils.java | 7 +++++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/invui-core/pom.xml b/invui-core/pom.xml
index 90adb6d4..6fd31200 100644
--- a/invui-core/pom.xml
+++ b/invui-core/pom.xml
@@ -22,7 +22,7 @@
org.spigotmc
spigot-api
- 1.19.4-R0.1-SNAPSHOT
+ 1.20.2-R0.1-SNAPSHOT
provided
diff --git a/invui-core/src/main/java/xyz/xenondevs/invui/item/builder/SkullBuilder.java b/invui-core/src/main/java/xyz/xenondevs/invui/item/builder/SkullBuilder.java
index 6e7ea90f..f12d5ac2 100644
--- a/invui-core/src/main/java/xyz/xenondevs/invui/item/builder/SkullBuilder.java
+++ b/invui-core/src/main/java/xyz/xenondevs/invui/item/builder/SkullBuilder.java
@@ -56,7 +56,7 @@ public SkullBuilder(@NotNull HeadTexture headTexture) {
}
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()));
}
diff --git a/invui-core/src/main/java/xyz/xenondevs/invui/util/MojangApiUtils.java b/invui-core/src/main/java/xyz/xenondevs/invui/util/MojangApiUtils.java
index a0fbfd25..0588b4b6 100644
--- a/invui-core/src/main/java/xyz/xenondevs/invui/util/MojangApiUtils.java
+++ b/invui-core/src/main/java/xyz/xenondevs/invui/util/MojangApiUtils.java
@@ -3,7 +3,6 @@
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 static UUID getUuidAtTime(String name, long timestamp) throws IOException
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"))