use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_18_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), NBTReadLimiter.a);
int length = getInt(tagCompound, "Length");
inventories = new InventoryHolder[length];
for (int i = 0; i < length; i++) {
if (hasKey(tagCompound, i + "")) {
NBTTagCompound nbtTagCompound = getCompound(tagCompound, i + "");
inventories[i] = deserialize(nbtTagCompound);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return inventories;
}
use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_18_R2 method deserialize.
private static InventoryHolder deserialize(NBTTagCompound tagCompound) {
InventoryHolder inventory = new InventoryHolder(getInt(tagCompound, "Size"), "Chest");
NBTTagList itemsList = getList(tagCompound, "Items", 10);
for (int i = 0; i < itemsList.size(); i++) {
NBTTagCompound nbtTagCompound = getCompound(itemsList, i);
inventory.setItem(getByte(nbtTagCompound, "Slot"), CraftItemStack.asBukkitCopy(ItemStack.a(nbtTagCompound)));
}
return inventory;
}
use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_16_R3 method deserialize.
private static 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.getCompound(i);
inventory.setItem(nbtTagCompound.getByte("Slot"), CraftItemStack.asBukkitCopy(ItemStack.a(nbtTagCompound)));
}
return inventory;
}
use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_17_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), NBTReadLimiter.a);
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 ex) {
ex.printStackTrace();
}
return inventories;
}
use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_17_R1 method deserialize.
private static 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.getCompound(i);
inventory.setItem(nbtTagCompound.getByte("Slot"), CraftItemStack.asBukkitCopy(ItemStack.a(nbtTagCompound)));
}
return inventory;
}
Aggregations