@@ -76,36 +76,35 @@ public static ItemStack color(ItemStack is, int r, int g, int b) {
7676 return is ;
7777 }
7878
79-
80- public static ItemStack createHead (String data , int amount , String name , String lore ) {
79+ public ItemStack createHead (String data , int amount , String name , String lore ) {
8180 ItemStack item = new ItemStack (Material .PLAYER_HEAD , amount );
82- ItemMeta meta = item .getItemMeta ();
83- if (!lore .isEmpty ()) {
81+ SkullMeta headMeta = (SkullMeta ) item .getItemMeta ();
82+ GameProfile profile = new GameProfile (id , "Arceon" );
83+ item .setAmount (amount );
84+ profile .getProperties ().put ("textures" , new Property ("textures" , String .valueOf (data )));
85+ try {
86+ PlayerProfile playerProfile = Bukkit .getServer ().createPlayerProfile (UUID .randomUUID (), "BuildersUtils" );
87+ PlayerTextures texture = playerProfile .getTextures ();
88+ String url = null ;
89+ byte [] decoded = Base64 .getDecoder ().decode (data );
90+ try {
91+ url = new String (decoded , StandardCharsets .UTF_8 );
92+ } catch (Exception ignored ) {}
93+ url = url .replace ("{\" textures\" :{\" SKIN\" :{\" url\" :\" " , "" ).replace ("\" }}}" , "" );
94+ texture .setSkin (new URL (url ));
95+ headMeta .setOwnerProfile (playerProfile );
96+ } catch (Exception ignored ) {
97+ }
98+ if (!lore .isEmpty ()) {
8499 String [] loreListArray = lore .split ("__" );
85100 List <String > loreList = new ArrayList <>();
86101 for (String s : loreListArray ) {
87102 loreList .add (s .replace ('&' , ChatColor .COLOR_CHAR ));
88103 }
89- meta .setLore (loreList );
104+ headMeta .setLore (loreList );
90105 }
91106 if (!name .isEmpty ()) {
92- meta .setDisplayName (name .replace ('&' , ChatColor .COLOR_CHAR ));
93- }
94- item .setItemMeta (meta );
95- SkullMeta headMeta = (SkullMeta ) item .getItemMeta ();
96- GameProfile profile = new GameProfile (UUID .randomUUID (), "BuildersUtils" );
97- profile .getProperties ().put ("textures" , new Property ("textures" , data ));
98- Field profileField ;
99- try {
100- profileField = headMeta .getClass ().getDeclaredField ("profile" );
101- profileField .setAccessible (true );
102- if (profileField .getType () == GameProfile .class ) {
103- profileField .set (headMeta , profile );
104- } else {
105- Class <?> resolvableProfileClass = Class .forName ("net.minecraft.world.item.component.ResolvableProfile" );
106- profileField .set (headMeta , resolvableProfileClass .getConstructor (GameProfile .class ).newInstance (profile ));
107- }
108- } catch (Exception ignored ) {
107+ headMeta .setDisplayName (name .replace ('&' , ChatColor .COLOR_CHAR ));
109108 }
110109 item .setItemMeta (headMeta );
111110 return item ;
0 commit comments