Search in sources :

Example 6 with BasicVanillaStack

use of com.almuradev.almura.shared.item.BasicVanillaStack in project Almura by AlmuraDev.

the class StoreListScreen method listOrModify.

private void listOrModify() {
    if (!this.buttonList.isEnabled()) {
        return;
    }
    // Check if there are any valid combinations
    final boolean isBuyValid = !this.buyQtyTextBox.getText().isEmpty() && !this.buyPricePerTextBox.getText().isEmpty();
    final boolean isSellValid = !this.sellQtyTextBox.getText().isEmpty() && !this.sellPricePerTextBox.getText().isEmpty();
    if (isBuyValid) {
        // We're modifying an existing listing
        if (this.toModifyBuy != null) {
            final int newBuyQuantity = Integer.valueOf(this.buyQtyTextBox.getText());
            storeManager.requestModifyBuyingItem(this.store.getId(), this.toModifyBuy.getRecord(), newBuyQuantity, 0, new BigDecimal(this.buyPricePerTextBox.getText()));
        } else {
            // We're adding a new listing
            final VanillaStack toListBuy = new BasicVanillaStack(this.toList);
            toListBuy.setQuantity(Integer.valueOf(this.buyQtyTextBox.getText()));
            storeManager.requestListBuyingItem(this.store.getId(), toListBuy, 0, new BigDecimal(this.buyPricePerTextBox.getText()));
        }
    } else if (this.toModifyBuy != null) {
        // We're unlisting an existing listing
        storeManager.requestDelistBuyingItem(this.store.getId(), this.toModifyBuy.getRecord());
    }
    if (isSellValid) {
        // We're modifying an existing listing
        if (this.toModifySell != null) {
            final int newQuantity = Integer.valueOf(this.sellQtyTextBox.getText());
            storeManager.requestModifySellingItem(this.store.getId(), this.toModifySell.getRecord(), newQuantity, 0, new BigDecimal(this.sellPricePerTextBox.getText()));
        } else {
            // We're adding a new listing
            final VanillaStack toListSell = new BasicVanillaStack(this.toList);
            toListSell.setQuantity(Integer.valueOf(this.sellQtyTextBox.getText()));
            storeManager.requestListSellingItem(this.store.getId(), toListSell, 0, new BigDecimal(this.sellPricePerTextBox.getText()));
        }
    } else if (this.toModifySell != null) {
        // We're unlisting an existing listing
        storeManager.requestDelistSellingItem(this.store.getId(), this.toModifySell.getRecord());
    }
    ((StoreScreen) this.parent).refresh(true);
    this.close();
}
Also used : BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack) BigDecimal(java.math.BigDecimal) VanillaStack(com.almuradev.almura.shared.item.VanillaStack) BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack)

Aggregations

BasicVanillaStack (com.almuradev.almura.shared.item.BasicVanillaStack)6 InventoryAction (com.almuradev.almura.feature.exchange.InventoryAction)3 VanillaStack (com.almuradev.almura.shared.item.VanillaStack)3 BigDecimal (java.math.BigDecimal)3 Exchange (com.almuradev.almura.feature.exchange.Exchange)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Minecraft (net.minecraft.client.Minecraft)2 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Almura (com.almuradev.almura.Almura)1 ExchangeModifyType (com.almuradev.almura.feature.exchange.ExchangeModifyType)1 ExchangeModule (com.almuradev.almura.feature.exchange.ExchangeModule)1 ListStatusType (com.almuradev.almura.feature.exchange.ListStatusType)1 BasicForSaleItem (com.almuradev.almura.feature.exchange.basic.listing.BasicForSaleItem)1