use of net.minecraft.server.v1_9_R2.NBTBase in project MyPet by xXKeyleXx.
the class ConfigItem method load.
public void load(String data) {
NBTBase nbtBase = null;
if (data.contains("{")) {
String tagString = data.substring(data.indexOf("{"));
data = data.substring(0, data.indexOf("{"));
try {
nbtBase = MojangsonParser.parse(tagString);
} catch (Exception e) {
MyPetApi.getLogger().warning(ChatColor.RED + "Error" + ChatColor.RESET + " in config: " + ChatColor.YELLOW + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
MyPetApi.getLogger().warning(data + tagString);
}
}
String[] splitData = data.split("\\s+");
if (splitData.length == 0) {
return;
}
Item item = null;
if (splitData.length >= 1) {
if (Util.isInt(splitData[0])) {
int itemId = Integer.parseInt(splitData[0]);
item = Item.getById(itemId);
} else {
item = (Item) Item.REGISTRY.get(splitData[0]);
}
}
if (item != null) {
int itemDamage = 0;
if (splitData.length >= 2) {
if (splitData[1].startsWith("<")) {
this.durabilityMode = DurabilityMode.Smaller;
splitData[1] = splitData[1].substring(1);
} else if (splitData[1].startsWith(">")) {
this.durabilityMode = DurabilityMode.Bigger;
splitData[1] = splitData[1].substring(1);
} else {
this.durabilityMode = DurabilityMode.Equal;
}
if (Util.isInt(splitData[1])) {
itemDamage = Integer.parseInt(splitData[1]);
}
}
net.minecraft.server.v1_7_R4.ItemStack is = new net.minecraft.server.v1_7_R4.ItemStack(item, 1, itemDamage);
if (nbtBase != null) {
is.setTag((NBTTagCompound) nbtBase);
}
this.item = CraftItemStack.asBukkitCopy(is);
}
}
use of net.minecraft.server.v1_9_R2.NBTBase in project MechanicsMain by WeaponMechanics.
the class NBT_1_14_R1 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.getKeys());
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_9_R2.NBTBase in project MechanicsMain by WeaponMechanics.
the class NBT_1_15_R1 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.getKeys());
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_9_R2.NBTBase in project MechanicsMain by WeaponMechanics.
the class NBT_1_16_R3 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.getKeys());
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_9_R2.NBTBase in project MechanicsMain by WeaponMechanics.
the class NBT_1_13_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.getKeys());
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");
}
Aggregations