src/main/java/me/hyfe/simplespigot/item/SpigotItem.java
/**
         * Builds the item using all set values and applies NBT changes.
         *
         * @param function The changes to apply to the item's NBT (through an NBT item)
         * @return The ItemStack
         */
Builds the item using all set values and applies NBT changes.
@param function The changes to apply to the item's NBT (through an NBT item)
@return The ItemStack
Builds the item using all set values and applies NBT changes . @param function The changes to apply to the item ' s NBT ( through an NBT item ) @return The ItemStack
public ItemStack build(UnaryOperator<NbtItem> function) {
            if (this.material != null) {
                this.itemStack.setType(this.material);
                this.itemStack.setAmount(this.amount);
                this.itemStack.setDurability(this.data);
            }
            if (this.amount > 0) {
                this.itemStack.setAmount(this.amount);
            }
            if (this.itemStack.getItemMeta() == null) {
                return this.itemStack;
            }
            ItemMeta itemMeta = this.itemStack.getItemMeta();
            this.itemStack.setItemMeta(createMeta(itemMeta));
            if (this.isHead) {
                SkullMeta skullMeta = (SkullMeta) this.itemStack.getItemMeta();
                if (this.base64Head != null) {
                    GameProfile profile = new GameProfile(UUID.randomUUID(), "");
                    profile.getProperties().put("textures", new Property("textures", this.base64Head));
                    Field profileField = null;
                    try {
                        profileField = skullMeta.getClass().getDeclaredField("profile");
                        profileField.setAccessible(true);
                        profileField.set(skullMeta, profile);
                    } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
                        e.printStackTrace();
                    }
                } else {
                    skullMeta.setOwner(this.ownerHead);
                }
                this.itemStack.setItemMeta(skullMeta);
            }
            if (function == null) {
                return this.itemStack;
            }
            return function.apply(new NbtItem(this.itemStack)).getItem();
        }
public ItemStack build ( UnaryOperator < NbtItem > function ) { if ( this . material != null ) { this . itemStack . setType ( this . material ) ; this . itemStack . setAmount ( this . amount ) ; this . itemStack . setDurability ( this . data ) ; } if ( this . amount > 0 ) { this . itemStack . setAmount ( this . amount ) ; } if ( this . itemStack . getItemMeta ( ) == null ) { return this . itemStack ; } ItemMeta itemMeta = this . itemStack . getItemMeta ( ) ; this . itemStack . setItemMeta ( createMeta ( itemMeta ) ) ; if ( this . isHead ) { SkullMeta skullMeta = ( SkullMeta ) this . itemStack . getItemMeta ( ) ; if ( this . base64Head != null ) { GameProfile profile = new GameProfile ( UUID . randomUUID ( ) , "" ) ; profile . getProperties ( ) . put ( "textures" , new Property ( "textures" , this . base64Head ) ) ; Field profileField = null ; try { profileField = skullMeta . getClass ( ) . getDeclaredField ( "profile" ) ; profileField . setAccessible ( true ) ; profileField . set ( skullMeta , profile ) ; } catch ( IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e ) { e . printStackTrace ( ) ; } } else { skullMeta . setOwner ( this . ownerHead ) ; } this . itemStack . setItemMeta ( skullMeta ) ; } if ( function == null ) { return this . itemStack ; } return function . apply ( new NbtItem ( this . itemStack ) ) . getItem ( ) ; }
Builds the item using all set values and applies NBT changes.
Builds the item using all set values and applies NBT changes .