Untitled

mail@pastecode.io avatar
unknown
java
22 days ago
1.2 kB
5
Indexable
Never
    private static void testInventory(Player player) {
        Inventory inventory = Bukkit.createInventory(null, 54, "Test Inventory");

        ItemStack stack = new ItemStack(Material.DIAMOND_SWORD);
        ItemMeta meta = stack.getItemMeta();

        if (meta != null) {
            meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
            stack.setItemMeta(meta);

            Bukkit.getLogger().info("Item flags: " + meta.getItemFlags());

            if(meta.getItemFlags().contains(ItemFlag.HIDE_ATTRIBUTES)) {
                Bukkit.getLogger().info("HIDE_ATTRIBUTES successfully added.");
            } else {
                Bukkit.getLogger().warning("HIDE_ATTRIBUTES not added.");
            }

            if(stack.getItemMeta().getItemFlags().contains(ItemFlag.HIDE_ATTRIBUTES)) {
                Bukkit.getLogger().info("HIDE_ATTRIBUTES successfully found.");
            } else {
                Bukkit.getLogger().warning("HIDE_ATTRIBUTES not found.");
            }
        } else {
            Bukkit.getLogger().warning("ItemMeta is null!");
        }

        inventory.setItem(0, stack);
        player.openInventory(inventory);
    }
Leave a Comment