@Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName)); } if (hasLore()) { setDisplayTag(itemTag, LORE.NBT, createStringList(lore)); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS); if (hasRepairCost()) { itemTag.setInt(REPAIR.NBT, repairCost); } if (attributes != null) { itemTag.set(ATTRIBUTES.NBT, attributes); } }
@Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName)); } if (hasLore()) { setDisplayTag(itemTag, LORE.NBT, createStringList(lore)); } if (hideFlag != 0) { itemTag.setInt(HIDEFLAGS.NBT, hideFlag); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS); if (hasRepairCost()) { itemTag.setInt(REPAIR.NBT, repairCost); } for (Map.Entry<String, NBTBase> e : unhandledTags.entrySet()) { itemTag.set(e.getKey(), e.getValue()); } }
@Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { setDisplayTag(itemTag, NAME.NBT, new NBTTagString(NAME.NBT, displayName)); } if (hasLore()) { setDisplayTag(itemTag, LORE.NBT, createStringList(lore, LORE)); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS); if (hasRepairCost()) { itemTag.setInt(REPAIR.NBT, repairCost); } if (attributes != null) { itemTag.set(ATTRIBUTES.NBT, attributes); } }
CraftMetaBook(NBTTagCompound tag) { super(tag); if (tag.hasKey(BOOK_TITLE.NBT)) { this.title = tag.getString(BOOK_TITLE.NBT); } if (tag.hasKey(BOOK_AUTHOR.NBT)) { this.author = tag.getString(BOOK_AUTHOR.NBT); } if (tag.hasKey(BOOK_PAGES.NBT)) { NBTTagList pages = tag.getList(BOOK_PAGES.NBT); String[] pageArray = new String[pages.size()]; for (int i = 0; i < pages.size(); i++) { String page = ((NBTTagString) pages.get(i)).data; pageArray[i] = page; } addPage(pageArray); } }
CraftMetaItem(NBTTagCompound tag) { if (tag.hasKey(DISPLAY.NBT)) { NBTTagCompound display = tag.getCompound(DISPLAY.NBT); if (display.hasKey(NAME.NBT)) { displayName = display.getString(NAME.NBT); } if (display.hasKey(LORE.NBT)) { NBTTagList list = display.getList(LORE.NBT); lore = new ArrayList<String>(list.size()); for (int index = 0; index < list.size(); index++) { String line = ((NBTTagString) list.get(index)).data; lore.add(line); } } } this.enchantments = buildEnchantments(tag, ENCHANTMENTS); if (tag.hasKey(REPAIR.NBT)) { repairCost = tag.getInt(REPAIR.NBT); } }
@Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { setDisplayTag(itemTag, NAME.NBT, new NBTTagString(NAME.NBT, displayName)); } if (hasLore()) { setDisplayTag(itemTag, LORE.NBT, createStringList(lore, LORE)); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS); if (hasRepairCost()) { itemTag.setInt(REPAIR.NBT, repairCost); } }
static NBTTagList createStringList(List<String> list) { if (list == null || list.isEmpty()) { return null; } NBTTagList tagList = new NBTTagList(); for (String value : list) { tagList.add(new NBTTagString(value)); } return tagList; }
@Override void applyToItem(NBTTagCompound itemData) { super.applyToItem(itemData, false); if (hasTitle()) { itemData.setString(BOOK_TITLE.NBT, this.title); } else { itemData.setString(BOOK_TITLE.NBT, " "); } if (hasAuthor()) { itemData.setString(BOOK_AUTHOR.NBT, this.author); } else { itemData.setString(BOOK_AUTHOR.NBT, " "); } if (hasPages()) { NBTTagList list = new NBTTagList(); for (IChatBaseComponent page : pages) { list.add(new NBTTagString( ChatSerializer.a(page) )); } itemData.set(BOOK_PAGES.NBT, list); } itemData.setBoolean(RESOLVED.NBT, true); if (generation != null) { itemData.setInt(GENERATION.NBT, generation); } else { itemData.setInt(GENERATION.NBT, 0); } }
void applyToItem(NBTTagCompound itemData, boolean handlePages) { super.applyToItem(itemData); if (hasTitle()) { itemData.setString(BOOK_TITLE.NBT, this.title); } if (hasAuthor()) { itemData.setString(BOOK_AUTHOR.NBT, this.author); } if (handlePages) { if (hasPages()) { NBTTagList list = new NBTTagList(); for (IChatBaseComponent page : pages) { list.add(new NBTTagString(CraftChatMessage.fromComponent(page))); } itemData.set(BOOK_PAGES.NBT, list); } itemData.remove(RESOLVED.NBT); } if (generation != null) { itemData.setInt(GENERATION.NBT, generation); } }
static NBTTagList createStringList(List<String> list, ItemMetaKey key) { if (list == null || list.isEmpty()) { return null; } NBTTagList tagList = new NBTTagList(key.NBT); for (String value : list) { tagList.add(new NBTTagString("", value)); } return tagList; }
@Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName)); } if (hasLore()) { setDisplayTag(itemTag, LORE.NBT, createStringList(lore)); } if (hideFlag != 0) { itemTag.setInt(HIDEFLAGS.NBT, hideFlag); } applyEnchantments(enchantments, itemTag, ENCHANTMENTS); // Spigot start if ( spigot.isUnbreakable() ) { itemTag.setBoolean( UNBREAKABLE.NBT, true ); } // Spigot end if (hasRepairCost()) { itemTag.setInt(REPAIR.NBT, repairCost); } for (Map.Entry<String, NBTBase> e : unhandledTags.entrySet()) { itemTag.set(e.getKey(), e.getValue()); } }