@@ -79,8 +79,7 @@ private static void setSkull(SkullMeta meta, String skull) {
7979 }
8080
8181 if (BASE64_PATTERN .matcher (skull ).matches ()) {
82- Optional <byte []> base64 = Validate .getBase64 (skull );
83- base64 .ifPresent (bytes -> skullHandler .setSkullByBase64 (meta , bytes ));
82+ skullHandler .setSkullByBase64 (meta , skull );
8483 return ;
8584 }
8685
@@ -149,7 +148,7 @@ default void setSkullByURL(SkullMeta meta, String url) {
149148 }
150149 }
151150
152- void setSkullByBase64 (SkullMeta meta , byte [] base64 );
151+ void setSkullByBase64 (SkullMeta meta , String base64 );
153152
154153 String getSkullValue (SkullMeta meta );
155154 }
@@ -211,9 +210,12 @@ public void setSkullByURL(SkullMeta meta, URL url) {
211210 }
212211
213212 @ Override
214- public void setSkullByBase64 (SkullMeta meta , byte [] base64 ) {
215- GameProfile gameProfile = new GameProfile (UUID .randomUUID (), "" );
216- gameProfile .getProperties ().put ("textures" , new Property ("textures" , new String (base64 , StandardCharsets .UTF_8 )));
213+ public void setSkullByBase64 (SkullMeta meta , String base64 ) {
214+ GameProfile gameProfile = cache .computeIfAbsent (base64 , b -> {
215+ GameProfile profile = new GameProfile (UUID .randomUUID (), "" );
216+ profile .getProperties ().put ("textures" , new Property ("textures" , b ));
217+ return profile ;
218+ });
217219 setSkullByGameProfile (meta , gameProfile );
218220 }
219221
@@ -269,9 +271,9 @@ public void setSkullByURL(SkullMeta meta, URL url) {
269271 }
270272
271273 @ Override
272- public void setSkullByBase64 (SkullMeta meta , byte [] base64 ) {
274+ public void setSkullByBase64 (SkullMeta meta , String base64 ) {
273275 try {
274- String decoded = new String (base64 , StandardCharsets .UTF_8 );
276+ String decoded = new String (Base64 . getDecoder (). decode ( base64 ) , StandardCharsets .UTF_8 );
275277 JsonObject json = new Gson ().fromJson (decoded , JsonObject .class );
276278 String url = json .getAsJsonObject ("textures" ).getAsJsonObject ("SKIN" ).get ("url" ).getAsString ();
277279 setSkullByURL (meta , url );
0 commit comments