Java 类net.minecraft.server.NBTTagString 实例源码

项目:CraftBukkit    文件:CraftMetaItem.java   
@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);
    }
}
项目:Craftbukkit    文件:CraftMetaItem.java   
@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());
    }
}
项目:Almura-Server    文件:CraftMetaItem.java   
@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);
    }
}
项目:Almura-Server    文件:CraftMetaBook.java   
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);
    }
}
项目:Tweakkit-Server    文件:CraftMetaItem.java   
@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);
    }
}
项目:Craft-city    文件:CraftMetaItem.java   
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);
    }
}
项目:Craft-city    文件:CraftMetaItem.java   
@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);
    }
}
项目:Craft-city    文件:CraftMetaBook.java   
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);
    }
}
项目:CraftBukkit    文件:CraftMetaItem.java   
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;
}
项目:Craftbukkit    文件:CraftMetaBookSigned.java   
@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);
    }
}
项目:Craftbukkit    文件:CraftMetaItem.java   
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;
}
项目:Craftbukkit    文件:CraftMetaBook.java   
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);
    }
}
项目:Almura-Server    文件:CraftMetaItem.java   
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;
}
项目:Tweakkit-Server    文件:CraftMetaItem.java   
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;
}
项目:SpigotSource    文件:CraftMetaBookSigned.java   
@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);
    }
}
项目:SpigotSource    文件:CraftMetaItem.java   
@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());
    }
}
项目:SpigotSource    文件:CraftMetaItem.java   
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;
}
项目:SpigotSource    文件:CraftMetaBook.java   
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);
    }
}
项目:Craft-city    文件:CraftMetaItem.java   
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;
}