Skip to content

Commit

Permalink
fix base64 apply
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Sep 18, 2024
1 parent 592d6f3 commit 048b080
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -212,7 +213,7 @@ public void setSkullByURL(SkullMeta meta, URL url) {
@Override
public void setSkullByBase64(SkullMeta meta, byte[] base64) {
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
gameProfile.getProperties().put("textures", new Property("textures", Base64.getEncoder().encodeToString(base64)));
gameProfile.getProperties().put("textures", new Property("textures", new String(base64, StandardCharsets.UTF_8)));
setSkullByGameProfile(meta, gameProfile);
}

Expand Down Expand Up @@ -270,7 +271,7 @@ public void setSkullByURL(SkullMeta meta, URL url) {
@Override
public void setSkullByBase64(SkullMeta meta, byte[] base64) {
try {
String decoded = new String(Base64.getDecoder().decode(base64));
String decoded = new String(base64, StandardCharsets.UTF_8);
JsonObject json = new Gson().fromJson(decoded, JsonObject.class);
String url = json.getAsJsonObject("textures").getAsJsonObject("SKIN").get("url").getAsString();
setSkullByURL(meta, url);
Expand Down

0 comments on commit 048b080

Please sign in to comment.