@@ -200,10 +200,16 @@ public SimpleItem setOwningPlayer(OfflinePlayer offlinePlayer){
200200 * @return this SimpleItem
201201 */
202202 public SimpleItem setSkin (SkinTexture skinTexture ){
203+ if (skinTexture == null )
204+ return this ;
205+ if (skinTexture .getUrl () == null || skinTexture .getUrl ().equals ("null" ))
206+ return this ;
207+ if (!(this .item .getItemMeta () instanceof SkullMeta ))
208+ return this ;
203209 SkullMeta meta = ((SkullMeta )this .item .getItemMeta ());
204210 if (meta != null ){
205- GameProfile gameProfile = new GameProfile (UUID .nameUUIDFromBytes ( "Steve" . getBytes () ), "" );
206- byte [] skinBytes = Base64 .encodeBase64 (("{textures:{SKIN:{url:\" " + skinTexture .getUrl () + " \" }}}" ).getBytes ());
211+ GameProfile gameProfile = new GameProfile (UUID .randomUUID ( ), "" );
212+ byte [] skinBytes = Base64 .encodeBase64 (String . format ("{textures:{SKIN:{url:\" %s \" }}}" , skinTexture .getUrl ()).getBytes ());
207213 gameProfile .getProperties ().put ("textures" , new Property ("textures" , new String (skinBytes )));
208214
209215 try {
@@ -226,22 +232,7 @@ public SimpleItem setSkin(SkinTexture skinTexture){
226232 * @return this SimpleItem
227233 */
228234 public SimpleItem setSkin (String textureURL ){
229- SkullMeta meta = ((SkullMeta )this .item .getItemMeta ());
230- if (meta != null ){
231- GameProfile gameProfile = new GameProfile (UUID .nameUUIDFromBytes ("Steve" .getBytes ()), "" );
232- byte [] skinBytes = Base64 .encodeBase64 (("{textures:{SKIN:{url:\" " + textureURL + "\" }}}" ).getBytes ());
233- gameProfile .getProperties ().put ("textures" , new Property ("textures" , new String (skinBytes )));
234-
235- try {
236- Field profile = meta .getClass ().getDeclaredField ("profile" );
237- profile .setAccessible (true );
238- profile .set (meta , gameProfile );
239- }catch (IllegalAccessException | NoSuchFieldException e ) {
240- e .printStackTrace ();
241- }
242- this .item .setItemMeta (meta );
243- }
244- return this ;
235+ return setSkin (SpigotPlugin .i .getSkinManager ().getSkin (textureURL ));
245236 }
246237
247238 /**
0 commit comments