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

项目: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());
    }
}
项目:CraftBukkit    文件:CraftMetaItem.java   
void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) {
    final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);

    if (!tag.hasKey(DISPLAY.NBT)) {
        tag.set(DISPLAY.NBT, display);
    }

    display.set(key, value);
}
项目:Craftbukkit    文件:CraftMetaItem.java   
void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) {
    final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);

    if (!tag.hasKey(DISPLAY.NBT)) {
        tag.set(DISPLAY.NBT, display);
    }

    display.set(key, value);
}
项目:Craftbukkit    文件:CraftMetaSkull.java   
@Override
void serializeInternal(final Map<String, NBTBase> internalTags) {
    if (profile != null) {
        NBTTagCompound nbtData = new NBTTagCompound();
        GameProfileSerializer.serialize(nbtData, profile);
        internalTags.put(SKULL_PROFILE.NBT, nbtData);
    }
}
项目:Almura-Server    文件:CraftMetaItem.java   
void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) {
    final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);

    if (!tag.hasKey(DISPLAY.NBT)) {
        tag.setCompound(DISPLAY.NBT, display);
    }

    display.set(key, value);
}
项目:Tweakkit-Server    文件:CraftMetaItem.java   
void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) {
    final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);

    if (!tag.hasKey(DISPLAY.NBT)) {
        tag.set(DISPLAY.NBT, display);
    }

    display.set(key, value);
}
项目:Tweakkit-Server    文件:NBTMetadataStore.java   
/**
 * A helper method to convert a tag directly to a MetadataValue.
 *
 * @param plugin The owning plugin
 * @param tag The tag to convert
 * @return A new MetadataValue object, or null if the tag could not be converted
 */
public static PersistentMetadataValue convertToMetadata(Plugin plugin, NBTBase tag) {
    if (plugin == null || tag == null) return null;

    Object converted = convert(tag);
    // Note that we don't currently export arrays as metadata
    if (converted instanceof String) {
        return new PersistentMetadataValue(plugin, (String)converted);
    } else if (converted instanceof Integer) {
        return new PersistentMetadataValue(plugin, (Integer)converted);
    } else if (converted instanceof Short) {
        return new PersistentMetadataValue(plugin, (Short)converted);
    } else if (converted instanceof Byte) {
        return new PersistentMetadataValue(plugin, (Byte)converted);
    } else if (converted instanceof Long) {
        return new PersistentMetadataValue(plugin, (Long)converted);
    } else if (converted instanceof Float) {
        return new PersistentMetadataValue(plugin, (Float)converted);
    } else if (converted instanceof Double) {
        return new PersistentMetadataValue(plugin, (Double)converted);
    } else if (converted instanceof Map) {
        return new PersistentMetadataValue(plugin, (Map<String, ?>)converted);
    } else if (converted instanceof List) {
        return new PersistentMetadataValue(plugin, (List<?>)converted);
    } else if (converted instanceof ConfigurationSerializable) {
        return new PersistentMetadataValue(plugin, (ConfigurationSerializable)converted);
    }

    return null;
}
项目:Tweakkit-Server    文件:NBTMetadataStore.java   
/**
 * Apply a Map of data to an NBTTagCompound
 *
 * @param tag The tag for which to apply data.
 * @param data The data to apply
 */
private static void applyToTag(NBTTagCompound tag, Map<String, Object> data) {
    if (tag == null || data == null) return;

    for (Map.Entry<String, Object> entry : data.entrySet()) {
        NBTBase copiedValue = convert(entry.getValue());
        if (copiedValue != null) {
            tag.set(entry.getKey(), copiedValue);
        } else {
            tag.remove(entry.getKey());
        }
    }
}
项目:CardinalPGM    文件:CardinalNotifications.java   
public void UpdateNotificationAndBook(){
    Bukkit.getScheduler().runTaskAsynchronously(Cardinal.getInstance(), new Runnable() {
        @Override
        public void run() {
            try {
                chat = ComponentSerializer.parse(GitUtil.getUpdateMessage(notificationUrl));

                ItemStack NMSbook = new ItemStack(Item.getById(387));
                try {
                    NBTBase nbtbase = MojangsonParser.parse(ChatColor.translateAlternateColorCodes('`', GitUtil.getUpdateMessage(bookUrl)));
                    NMSbook.setTag((NBTTagCompound) nbtbase);
                } catch (MojangsonParseException mojangsonparseexception) {
                    Bukkit.getConsoleSender().sendMessage(mojangsonparseexception.getMessage());
                    return;
                }
                book = CraftItemStack.asBukkitCopy(NMSbook);
            } catch (IOException ignored) {
            }
        }
    });
}
项目: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   
void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) {
    final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);

    if (!tag.hasKey(DISPLAY.NBT)) {
        tag.set(DISPLAY.NBT, display);
    }

    display.set(key, value);
}
项目:SpigotSource    文件:CraftMetaSkull.java   
@Override
void serializeInternal(final Map<String, NBTBase> internalTags) {
    if (profile != null) {
        NBTTagCompound nbtData = new NBTTagCompound();
        GameProfileSerializer.serialize(nbtData, profile);
        internalTags.put(SKULL_PROFILE.NBT, nbtData);
    }
}
项目:Craft-city    文件:CraftMetaItem.java   
void setDisplayTag(NBTTagCompound tag, String key, NBTBase value) {
    final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);

    if (!tag.hasKey(DISPLAY.NBT)) {
        tag.setCompound(DISPLAY.NBT, display);
    }

    display.set(key, value);
}
项目:ProjectAres    文件:NBTUtils.java   
/**
 * Return the private namespace tag, or null if it is not present in the stack
 */
public static @Nullable NBTTagCompound getCustomTag(@Nullable ItemMeta meta) {
    if(meta == null) return null;
    final NBTBase tag = ((CraftMetaItem) meta).getUnhandledTags().get(KEY);
    return tag instanceof NBTTagCompound ? (NBTTagCompound) tag : null;
}
项目:Craftbukkit    文件:CraftMetaItem.java   
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
    if (hasDisplayName()) {
        builder.put(NAME.BUKKIT, displayName);
    }

    if (hasLore()) {
        builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
    }

    serializeEnchantments(enchantments, builder, ENCHANTMENTS);

    if (hasRepairCost()) {
        builder.put(REPAIR.BUKKIT, repairCost);
    }

    Set<String> hideFlags = new HashSet<String>();
    for (ItemFlag hideFlagEnum : getItemFlags()) {
        hideFlags.add(hideFlagEnum.name());
    }
    if (!hideFlags.isEmpty()) {
        builder.put(HIDEFLAGS.BUKKIT, hideFlags);
    }

    final Map<String, NBTBase> internalTags = new HashMap<String, NBTBase>(unhandledTags);
    serializeInternal(internalTags);
    if (!internalTags.isEmpty()) {
        NBTTagCompound internal = new NBTTagCompound();
        for (Map.Entry<String, NBTBase> e : internalTags.entrySet()) {
            internal.set(e.getKey(), e.getValue());
        }
        try {
            ByteArrayOutputStream buf = new ByteArrayOutputStream();
            NBTCompressedStreamTools.a(internal, buf);
            builder.put("internal", Base64.encodeBase64String(buf.toByteArray()));
        } catch (IOException ex) {
            Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    return builder;
}
项目:Craftbukkit    文件:CraftMetaItem.java   
void serializeInternal(final Map<String, NBTBase> unhandledTags) {
}
项目:Craftbukkit    文件:CraftMetaBlockState.java   
@Override
void serializeInternal(final Map<String, NBTBase> internalTags) {
    if (blockEntityTag != null) {
        internalTags.put(BLOCK_ENTITY_TAG.NBT, blockEntityTag);
    }
}
项目:SpigotSource    文件:CraftMetaItem.java   
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
    if (hasDisplayName()) {
        builder.put(NAME.BUKKIT, displayName);
    }

    if (hasLore()) {
        builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
    }

    serializeEnchantments(enchantments, builder, ENCHANTMENTS);

    if (hasRepairCost()) {
        builder.put(REPAIR.BUKKIT, repairCost);
    }

    // Spigot start
    if ( spigot.isUnbreakable() )
    {
        builder.put( UNBREAKABLE.BUKKIT, true );
    }
    // Spigot end


    Set<String> hideFlags = new HashSet<String>();
    for (ItemFlag hideFlagEnum : getItemFlags()) {
        hideFlags.add(hideFlagEnum.name());
    }
    if (!hideFlags.isEmpty()) {
        builder.put(HIDEFLAGS.BUKKIT, hideFlags);
    }

    final Map<String, NBTBase> internalTags = new HashMap<String, NBTBase>(unhandledTags);
    serializeInternal(internalTags);
    if (!internalTags.isEmpty()) {
        NBTTagCompound internal = new NBTTagCompound();
        for (Map.Entry<String, NBTBase> e : internalTags.entrySet()) {
            internal.set(e.getKey(), e.getValue());
        }
        try {
            ByteArrayOutputStream buf = new ByteArrayOutputStream();
            NBTCompressedStreamTools.a(internal, buf);
            builder.put("internal", Base64.encodeBase64String(buf.toByteArray()));
        } catch (IOException ex) {
            Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    return builder;
}
项目:SpigotSource    文件:CraftMetaItem.java   
void serializeInternal(final Map<String, NBTBase> unhandledTags) {
}
项目:SpigotSource    文件:CraftMetaBlockState.java   
@Override
void serializeInternal(final Map<String, NBTBase> internalTags) {
    if (blockEntityTag != null) {
        internalTags.put(BLOCK_ENTITY_TAG.NBT, blockEntityTag);
    }
}