use of com.almuradev.almura.feature.exchange.listing.ForSaleItem in project Almura by AlmuraDev.
the class ClientboundListItemsSaleStatusPacket method writeTo.
@Override
public void writeTo(final ChannelBuf buf) {
checkNotNull(this.id);
buf.writeString(this.id);
buf.writeInteger(this.listedItems == null ? 0 : this.listedItems.size());
if (this.listedItems != null) {
for (final ForSaleItem listedItem : this.listedItems) {
buf.writeInteger(listedItem.getListItem().getRecord());
buf.writeInteger(listedItem.getRecord());
try {
final byte[] createdData = SerializationUtil.objectToBytes(listedItem.getCreated());
buf.writeInteger(createdData.length);
buf.writeBytes(createdData);
} catch (IOException e) {
e.printStackTrace();
continue;
}
ByteBufUtil.writeBigDecimal((ByteBuf) buf, listedItem.getPrice());
}
}
buf.writeInteger(this.lastKnownPriceItems == null ? 0 : this.lastKnownPriceItems.size());
if (this.lastKnownPriceItems != null) {
for (final ListItem delistedItem : this.lastKnownPriceItems) {
delistedItem.getLastKnownPrice().ifPresent(lastKnownPrice -> {
buf.writeInteger(delistedItem.getRecord());
ByteBufUtil.writeBigDecimal((ByteBuf) buf, lastKnownPrice);
});
}
}
}
Aggregations