use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder 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 com.bgsoftware.wildchests.objects.inventory.InventoryHolder 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;
}
use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_12_R1 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(new ItemStack(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 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_8_R3 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