use of org.bukkit.craftbukkit.v1_18_R2.Overridden in project Mohist by MohistMC.
the class CraftMetaItem method applyToItem.
@Overridden
void applyToItem(CompoundTag itemTag) {
if (hasDisplayName()) {
setDisplayTag(itemTag, NAME.NBT, StringTag.valueOf(displayName));
}
if (hasLocalizedName()) {
setDisplayTag(itemTag, LOCNAME.NBT, StringTag.valueOf(locName));
}
if (lore != null) {
setDisplayTag(itemTag, LORE.NBT, createStringList(lore));
}
if (hasCustomModelData()) {
itemTag.putInt(CUSTOM_MODEL_DATA.NBT, customModelData);
}
if (hasBlockData()) {
itemTag.put(BLOCK_DATA.NBT, blockData);
}
if (hideFlag != 0) {
itemTag.putInt(HIDEFLAGS.NBT, hideFlag);
}
applyEnchantments(enchantments, itemTag, ENCHANTMENTS);
applyModifiers(attributeModifiers, itemTag, ATTRIBUTES);
if (hasRepairCost()) {
itemTag.putInt(REPAIR.NBT, repairCost);
}
if (isUnbreakable()) {
itemTag.putBoolean(UNBREAKABLE.NBT, unbreakable);
}
if (hasDamage()) {
itemTag.putInt(DAMAGE.NBT, damage);
}
for (Map.Entry<String, Tag> e : unhandledTags.entrySet()) {
itemTag.put(e.getKey(), e.getValue());
}
if (!persistentDataContainer.isEmpty()) {
CompoundTag bukkitCustomCompound = new CompoundTag();
Map<String, Tag> rawPublicMap = persistentDataContainer.getRaw();
for (Map.Entry<String, Tag> nbtBaseEntry : rawPublicMap.entrySet()) {
bukkitCustomCompound.put(nbtBaseEntry.getKey(), nbtBaseEntry.getValue());
}
itemTag.put(BUKKIT_CUSTOM_TAG.NBT, bukkitCustomCompound);
}
}
use of org.bukkit.craftbukkit.v1_18_R2.Overridden in project LoliServer by Loli-Server.
the class CraftMetaItem method serialize.
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
if (hasDisplayName()) {
builder.put(NAME.BUKKIT, displayName);
}
if (hasLocalizedName()) {
builder.put(LOCNAME.BUKKIT, locName);
}
if (hasLore()) {
builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
}
if (hasCustomModelData()) {
builder.put(CUSTOM_MODEL_DATA.BUKKIT, customModelData);
}
if (hasBlockData()) {
builder.put(BLOCK_DATA.BUKKIT, CraftNBTTagConfigSerializer.serialize(blockData));
}
serializeEnchantments(enchantments, builder, ENCHANTMENTS);
serializeModifiers(attributeModifiers, builder, ATTRIBUTES);
if (hasRepairCost()) {
builder.put(REPAIR.BUKKIT, repairCost);
}
List<String> hideFlags = new ArrayList<String>();
for (ItemFlag hideFlagEnum : getItemFlags()) {
hideFlags.add(hideFlagEnum.name());
}
if (!hideFlags.isEmpty()) {
builder.put(HIDEFLAGS.BUKKIT, hideFlags);
}
if (isUnbreakable()) {
builder.put(UNBREAKABLE.BUKKIT, unbreakable);
}
if (hasDamage()) {
builder.put(DAMAGE.BUKKIT, damage);
}
final Map<String, INBT> internalTags = new HashMap<String, INBT>(unhandledTags);
serializeInternal(internalTags);
if (!internalTags.isEmpty()) {
CompoundNBT internal = new CompoundNBT();
for (Map.Entry<String, INBT> e : internalTags.entrySet()) {
internal.put(e.getKey(), e.getValue());
}
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
CompressedStreamTools.writeCompressed(internal, buf);
builder.put("internal", Base64.encodeBase64String(buf.toByteArray()));
} catch (IOException ex) {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (!persistentDataContainer.isEmpty()) {
// Store custom tags, wrapped in their compound
builder.put(BUKKIT_CUSTOM_TAG.BUKKIT, persistentDataContainer.serialize());
}
return builder;
}
use of org.bukkit.craftbukkit.v1_18_R2.Overridden in project Magma-1.16.x by magmafoundation.
the class CraftMetaItem method serialize.
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
if (hasDisplayName()) {
builder.put(NAME.BUKKIT, displayName);
}
if (hasLocalizedName()) {
builder.put(LOCNAME.BUKKIT, locName);
}
if (hasLore()) {
builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
}
if (hasCustomModelData()) {
builder.put(CUSTOM_MODEL_DATA.BUKKIT, customModelData);
}
if (hasBlockData()) {
builder.put(BLOCK_DATA.BUKKIT, CraftNBTTagConfigSerializer.serialize(blockData));
}
serializeEnchantments(enchantments, builder, ENCHANTMENTS);
serializeModifiers(attributeModifiers, builder, ATTRIBUTES);
if (hasRepairCost()) {
builder.put(REPAIR.BUKKIT, repairCost);
}
List<String> hideFlags = new ArrayList<String>();
for (ItemFlag hideFlagEnum : getItemFlags()) {
hideFlags.add(hideFlagEnum.name());
}
if (!hideFlags.isEmpty()) {
builder.put(HIDEFLAGS.BUKKIT, hideFlags);
}
if (isUnbreakable()) {
builder.put(UNBREAKABLE.BUKKIT, unbreakable);
}
if (hasDamage()) {
builder.put(DAMAGE.BUKKIT, damage);
}
final Map<String, INBT> internalTags = new HashMap<String, INBT>(unhandledTags);
serializeInternal(internalTags);
if (!internalTags.isEmpty()) {
CompoundNBT internal = new CompoundNBT();
for (Map.Entry<String, INBT> e : internalTags.entrySet()) {
internal.put(e.getKey(), e.getValue());
}
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
CompressedStreamTools.writeCompressed(internal, buf);
builder.put("internal", Base64.encodeBase64String(buf.toByteArray()));
} catch (IOException ex) {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (!persistentDataContainer.isEmpty()) {
// Store custom tags, wrapped in their compound
builder.put(BUKKIT_CUSTOM_TAG.BUKKIT, persistentDataContainer.serialize());
}
return builder;
}
use of org.bukkit.craftbukkit.v1_18_R2.Overridden in project Magma by magmafoundation.
the class CraftMetaItem method serialize.
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
if (hasDisplayName()) {
builder.put(NAME.BUKKIT, displayName);
}
if (hasLocalizedName()) {
builder.put(LOCNAME.BUKKIT, locName);
}
if (hasLore()) {
builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
}
serializeEnchantments(enchantments, builder, ENCHANTMENTS);
if (hasRepairCost()) {
builder.put(REPAIR.BUKKIT, repairCost);
}
List<String> hideFlags = new ArrayList<String>();
for (ItemFlag hideFlagEnum : getItemFlags()) {
hideFlags.add(hideFlagEnum.name());
}
if (!hideFlags.isEmpty()) {
builder.put(HIDEFLAGS.BUKKIT, hideFlags);
}
if (isUnbreakable()) {
builder.put(UNBREAKABLE.BUKKIT, unbreakable);
}
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.setTag(e.getKey(), e.getValue());
}
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
CompressedStreamTools.writeCompressed(internal, buf);
builder.put("internal", Base64.encodeBase64String(buf.toByteArray()));
} catch (IOException ex) {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
return builder;
}
use of org.bukkit.craftbukkit.v1_18_R2.Overridden in project Mohist by MohistMC.
the class CraftMetaItem method serialize.
@Overridden
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
if (hasDisplayName()) {
builder.put(NAME.BUKKIT, displayName);
}
if (hasLocalizedName()) {
builder.put(LOCNAME.BUKKIT, locName);
}
if (lore != null) {
builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore));
}
if (hasCustomModelData()) {
builder.put(CUSTOM_MODEL_DATA.BUKKIT, customModelData);
}
if (hasBlockData()) {
builder.put(BLOCK_DATA.BUKKIT, CraftNBTTagConfigSerializer.serialize(blockData));
}
serializeEnchantments(enchantments, builder, ENCHANTMENTS);
serializeModifiers(attributeModifiers, builder, ATTRIBUTES);
if (hasRepairCost()) {
builder.put(REPAIR.BUKKIT, repairCost);
}
List<String> hideFlags = new ArrayList<String>();
for (ItemFlag hideFlagEnum : getItemFlags()) {
hideFlags.add(hideFlagEnum.name());
}
if (!hideFlags.isEmpty()) {
builder.put(HIDEFLAGS.BUKKIT, hideFlags);
}
if (isUnbreakable()) {
builder.put(UNBREAKABLE.BUKKIT, unbreakable);
}
if (hasDamage()) {
builder.put(DAMAGE.BUKKIT, damage);
}
final Map<String, Tag> internalTags = new HashMap<String, Tag>(unhandledTags);
serializeInternal(internalTags);
if (!internalTags.isEmpty()) {
CompoundTag internal = new CompoundTag();
for (Map.Entry<String, Tag> e : internalTags.entrySet()) {
internal.put(e.getKey(), e.getValue());
}
try {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
NbtIo.writeCompressed(internal, buf);
builder.put("internal", Base64.getEncoder().encodeToString(buf.toByteArray()));
} catch (IOException ex) {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (!persistentDataContainer.isEmpty()) {
// Store custom tags, wrapped in their compound
builder.put(BUKKIT_CUSTOM_TAG.BUKKIT, persistentDataContainer.serialize());
}
return builder;
}
Aggregations