use of com.almuradev.almura.feature.exchange.listing.ListItem in project Almura by AlmuraDev.
the class ExchangeScreen method refreshListItems.
public void refreshListItems() {
if (this.listItemList == null) {
return;
}
final ListItem currentItem = this.listItemList.getSelectedItem() == null ? null : this.listItemList.getSelectedItem().copy();
this.listItemList.clearItems();
final List<ListItem> listItems = this.axs.getListItemsFor(Minecraft.getMinecraft().player.getUniqueID()).orElse(null);
if (listItems != null && !listItems.isEmpty()) {
this.listItemList.setItems(listItems);
}
// Attempt to re-select the same item
if (currentItem != null) {
this.listItemList.setSelectedItem(this.listItemList.getItems().stream().filter(i -> i.getRecord() == currentItem.getRecord()).findFirst().orElse(null));
}
this.updateControls();
}
use of com.almuradev.almura.feature.exchange.listing.ListItem 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