use of net.minecraft.server.v1_14_R1.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_8_R3 method deserialize.
private InventoryHolder deserialize(NBTTagCompound tagCompound) {
InventoryHolder inventory = new InventoryHolder(tagCompound.getInt("Size"), "Chest");
NBTTagList itemsList = tagCompound.getList("Items", 10);
for (int i = 0; i < itemsList.size(); i++) {
NBTTagCompound nbtTagCompound = itemsList.get(i);
inventory.setItem(nbtTagCompound.getByte("Slot"), CraftItemStack.asBukkitCopy(ItemStack.createStack(nbtTagCompound)));
}
return inventory;
}
use of net.minecraft.server.v1_14_R1.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_8_R3 method getChestName.
@Override
public String getChestName(org.bukkit.inventory.ItemStack itemStack) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = nmsItem.getTag();
return tagCompound == null || !tagCompound.hasKey("chest-name") ? null : tagCompound.getString("chest-name");
}
use of net.minecraft.server.v1_14_R1.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method getChestName.
@Override
public String getChestName(org.bukkit.inventory.ItemStack itemStack) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = nmsItem.getTag();
return tagCompound == null || !tagCompound.hasKey("chest-name") ? null : tagCompound.getString("chest-name");
}
use of net.minecraft.server.v1_14_R1.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method deserialzeItem.
@Override
public org.bukkit.inventory.ItemStack deserialzeItem(String serialized) {
if (serialized.isEmpty())
return new org.bukkit.inventory.ItemStack(Material.AIR);
byte[] buff;
if (serialized.toCharArray()[0] == '*') {
buff = Base64.getDecoder().decode(serialized.substring(1));
} else {
buff = new BigInteger(serialized, 32).toByteArray();
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(buff);
try {
NBTTagCompound nbtTagCompoundRoot = NBTCompressedStreamTools.a(new DataInputStream(inputStream));
ItemStack nmsItem = new ItemStack(nbtTagCompoundRoot);
return CraftItemStack.asBukkitCopy(nmsItem);
} catch (Exception ex) {
return null;
}
}
use of net.minecraft.server.v1_14_R1.NBTTagCompound in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 method deserialze.
@Override
public InventoryHolder[] deserialze(String serialized) {
byte[] buff;
if (serialized.toCharArray()[0] == '*') {
buff = Base64.getDecoder().decode(serialized.substring(1));
} else {
buff = new BigInteger(serialized, 32).toByteArray();
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(buff);
InventoryHolder[] inventories = new InventoryHolder[0];
try {
NBTTagCompound tagCompound = NBTCompressedStreamTools.a(new DataInputStream(inputStream));
int length = tagCompound.getInt("Length");
inventories = new InventoryHolder[length];
for (int i = 0; i < length; i++) {
if (tagCompound.hasKey(i + "")) {
NBTTagCompound nbtTagCompound = tagCompound.getCompound(i + "");
inventories[i] = deserialize(nbtTagCompound);
}
}
} catch (Exception ignored) {
}
return inventories;
}
Aggregations