Войти или зарегистрироваться
  • Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.

Помогите Бошка с текстурой

Copter533

Участник
Пользователь
Баллы
31
Имя в Minecraft
Copter533
Недавно решил обновиться до версии 1.16.5, и теперь мирюсь с кучей багов...

Как поставить скин на бошку игрока, вот url (для примера):
eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGU2NDQwYThkNTk5MmMyNjdkMmEzMzYzODgyOTY0YWMyYmE1MjJmMmY5MTE0YTZmN2QxN2IzNTcyMmQyZjVmOCJ9fX0

До этого у меня было:
PHP:
static ItemStack getSkull(String url) {
        ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        if (url.isEmpty()) return head;

        SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        profile.getProperties().put("textures", new Property("textures", url));

        try {
            Field profileField = skullMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(skullMeta, profile);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }

        head.setItemMeta(skullMeta);
        return head;
    }
    static CustomItemLabel getLabelIfPresent(ItemStack item) {
        if (item.getItemMeta() instanceof CustomItemMeta) return ((CustomItemMeta) item.getItemMeta()).getLabel();
        return null;
    }
После обновления:
PHP:
static ItemStack getSkull(String url) {
        ItemStack head = new ItemStack(Material.PLAYER_HEAD);
        if (url.isEmpty()) return head;

        SkullMeta skullMeta = (SkullMeta) head.getItemMeta();

        PlayerProfile profile = skullMeta.getPlayerProfile();
        for (ProfileProperty prop : profile.getProperties()) {
            if (prop.getName().equals("textures")) profile.setProperty(new ProfileProperty("textures", url));
        }
        skullMeta.setPlayerProfile(profile);

        head.setItemMeta(skullMeta);
        return head;
    }
Но теперь profile становиться нуллом, и код не работает.
 

Поделиться этой страницей

Назад
Верх