Skip to content

Commit

Permalink
Fix SkullBuilder on 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NichtStudioCode committed Oct 9, 2023
1 parent c55b694 commit 86a9fb6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion invui-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 86a9fb6

Please sign in to comment.