Помогите Создание головы с определенным скином

Cristalix

Активный участник
Пользователь
Баллы
76
Имя в Minecraft
Test
Я знаю что для того чтобы дать голове скин игрока нужно получить ее SkullMeta и установить владельца. Но вот у меня возник вопрос. Как дать голову игроку с определенным скином? Да и вообще где искать скины и как правильно устанавливать?
 
Код:
public static ItemStack getSkull(String url) {
        ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        if (url.isEmpty()) return head;

        SkullMeta headMeta = (SkullMeta) head.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        profile.getProperties().put("textures", new Property("textures", url));
        try {
            Field profileField = headMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(headMeta, profile);

        } catch (IllegalArgumentException | NoSuchFieldException | SecurityException | IllegalAccessException error) {
            error.printStackTrace();
        }
        head.setItemMeta(headMeta);
        return head;
    }

Url получаешь как написано тут:

https://github.com/OnlyNoobDied/GadgetsMenu/wiki/Texture-Head
 
Код:
public static ItemStack getSkull(String url) {
        ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        if (url.isEmpty()) return head;

        SkullMeta headMeta = (SkullMeta) head.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        profile.getProperties().put("textures", new Property("textures", url));
        try {
            Field profileField = headMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(headMeta, profile);

        } catch (IllegalArgumentException | NoSuchFieldException | SecurityException | IllegalAccessException error) {
            error.printStackTrace();
        }
        head.setItemMeta(headMeta);
        return head;
    }

Url получаешь как написано тут:

https://github.com/OnlyNoobDied/GadgetsMenu/wiki/Texture-Head
Есть же бумага. Зачем себе жизнь усложнять?
 
Назад
Верх