Search in sources :

Example 16 with ListItem

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();
}
Also used : Arrays(java.util.Arrays) FeatureSortType(com.almuradev.almura.feature.FeatureSortType) UIComponent(net.malisis.core.client.gui.component.UIComponent) PopupNotification(com.almuradev.almura.feature.notification.type.PopupNotification) I18n(net.minecraft.client.resources.I18n) BigDecimal(java.math.BigDecimal) UISaneTooltip(com.almuradev.almura.shared.client.ui.component.UISaneTooltip) MalisisGui(net.malisis.core.client.gui.MalisisGui) BasicTextBox(net.malisis.core.client.gui.component.interaction.BasicTextBox) Side(net.minecraftforge.fml.relauncher.Side) ExchangeModule(com.almuradev.almura.feature.exchange.ExchangeModule) Map(java.util.Map) BasicList(net.malisis.core.client.gui.component.container.BasicList) BasicContainer(net.malisis.core.client.gui.component.container.BasicContainer) Exchange(com.almuradev.almura.feature.exchange.Exchange) FontColors(net.malisis.core.util.FontColors) FeatureConstants(com.almuradev.almura.shared.feature.FeatureConstants) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) UIImage(net.malisis.core.client.gui.component.decoration.UIImage) MathUtil(com.almuradev.almura.shared.util.MathUtil) Direction(com.almuradev.almura.shared.feature.filter.Direction) SortType(com.almuradev.almura.feature.SortType) ListStatusType(com.almuradev.almura.feature.exchange.ListStatusType) BasicLine(net.malisis.core.client.gui.component.decoration.BasicLine) HashMap(java.util.HashMap) ITooltipFlag(net.minecraft.client.util.ITooltipFlag) FeatureSortTypes(com.almuradev.almura.FeatureSortTypes) ForSaleItem(com.almuradev.almura.feature.exchange.listing.ForSaleItem) ListItem(com.almuradev.almura.feature.exchange.listing.ListItem) Inject(javax.inject.Inject) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) Anchor(net.malisis.core.client.gui.Anchor) VirtualStack(com.almuradev.almura.shared.item.VirtualStack) BasicScreen(net.malisis.core.client.gui.BasicScreen) UIExpandingLabel(com.almuradev.almura.shared.client.ui.component.UIExpandingLabel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) UISelect(net.malisis.core.client.gui.component.interaction.UISelect) Nullable(javax.annotation.Nullable) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) Logger(org.slf4j.Logger) ClientExchangeManager(com.almuradev.almura.feature.exchange.client.ClientExchangeManager) UILabel(net.malisis.core.client.gui.component.decoration.UILabel) TextFormatting(net.minecraft.util.text.TextFormatting) ClientNotificationManager(com.almuradev.almura.feature.notification.ClientNotificationManager) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) FontRenderer(net.minecraft.client.gui.FontRenderer) FontOptions(net.malisis.core.renderer.font.FontOptions) ListItem(com.almuradev.almura.feature.exchange.listing.ListItem)

Example 17 with ListItem

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);
            });
        }
    }
}
Also used : ForSaleItem(com.almuradev.almura.feature.exchange.listing.ForSaleItem) IOException(java.io.IOException) ListItem(com.almuradev.almura.feature.exchange.listing.ListItem)

Aggregations

ListItem (com.almuradev.almura.feature.exchange.listing.ListItem)17 BasicListItem (com.almuradev.almura.feature.exchange.basic.listing.BasicListItem)14 ForSaleItem (com.almuradev.almura.feature.exchange.listing.ForSaleItem)14 BasicForSaleItem (com.almuradev.almura.feature.exchange.basic.listing.BasicForSaleItem)12 AxsListItem (com.almuradev.generated.axs.tables.AxsListItem)11 ClientboundListItemsSaleStatusPacket (com.almuradev.almura.feature.exchange.network.ClientboundListItemsSaleStatusPacket)10 AxsForSaleItem (com.almuradev.generated.axs.tables.AxsForSaleItem)10 ClientboundForSaleFilterRequestPacket (com.almuradev.almura.feature.exchange.network.ClientboundForSaleFilterRequestPacket)9 ClientboundListItemsResponsePacket (com.almuradev.almura.feature.exchange.network.ClientboundListItemsResponsePacket)9 SQLException (java.sql.SQLException)8 ArrayList (java.util.ArrayList)8 DSLContext (org.jooq.DSLContext)8 BasicExchange (com.almuradev.almura.feature.exchange.basic.BasicExchange)7 IOException (java.io.IOException)7 BigDecimal (java.math.BigDecimal)7 List (java.util.List)7 UUID (java.util.UUID)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 ClientboundExchangeGuiResponsePacket (com.almuradev.almura.feature.exchange.network.ClientboundExchangeGuiResponsePacket)5 ClientboundTransactionCompletePacket (com.almuradev.almura.feature.exchange.network.ClientboundTransactionCompletePacket)5