use of net.minecraft.server.v1_11_R1.NBTBase in project MechanicsMain by WeaponMechanics.
the class NBT_1_9_R2 method visit.
private StringBuilder visit(NBTTagCompound nbt, int indents, int colorOffset) {
String braceColor = "&" + BRACE_COLORS.charAt(indents % BRACE_COLORS.length());
StringBuilder builder = new StringBuilder(braceColor).append('{');
List<String> keys = new ArrayList<>(nbt.c());
Collections.sort(keys);
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
NBTBase value = Objects.requireNonNull(nbt.get(key), "This is impossible");
if (i != 0)
builder.append('\n');
builder.append(StringUtil.repeat(" ", indents));
String color = "&" + VALUE_COLORS.charAt((i + colorOffset) % VALUE_COLORS.length());
builder.append(color).append(key).append("&f&l: ").append(color);
if (value instanceof NBTTagCompound)
builder.append(visit((NBTTagCompound) value, indents + 1, colorOffset + i));
else
builder.append(value);
}
return builder.append(braceColor).append("}\n");
}
use of net.minecraft.server.v1_11_R1.NBTBase in project PaperDev by Kamillaova.
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.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;
}
Aggregations