Interface TradeOffer.Builder

All Superinterfaces:
AbstractBuilder<TradeOffer>, Builder<TradeOffer,TradeOffer.Builder>, CopyableBuilder<TradeOffer,TradeOffer.Builder>, DataBuilder<TradeOffer>, ResettableBuilder<TradeOffer,TradeOffer.Builder>
Enclosing interface:
TradeOffer

Represents a builder to generate immutable TradeOffers.
  • Method Details

    • firstBuyingItem

      TradeOffer.Builder firstBuyingItem(ItemStack item)

      Sets the first selling item of the trade offer to be generated.

      Trade offers require at least one item to be generated.

      Parameters:
      item - The first item to buy
      Returns:
      This builder
    • secondBuyingItem

      TradeOffer.Builder secondBuyingItem(ItemStack item)
      Sets the second selling item of the trade offer to be generated.
      Parameters:
      item - The second item to buy
      Returns:
      This builder
    • sellingItem

      TradeOffer.Builder sellingItem(ItemStack item)
      Sets the selling item of the trade offer to be generated.
      Parameters:
      item - The item to sell
      Returns:
      This builder
    • uses

      TradeOffer.Builder uses(int uses)
      Sets the existing uses of the trade offer to be generated. A trade offer will become unusable when the uses surpasses the max uses.
      Parameters:
      uses - The uses
      Returns:
      This builder
    • maxUses

      TradeOffer.Builder maxUses(int maxUses)
      Sets the maximum uses the generated trade offer will have. A trade offer will become unusable when the uses surpasses the max uses.
      Parameters:
      maxUses - The maximum uses of the trade offer
      Returns:
      This builder
    • canGrantExperience

      TradeOffer.Builder canGrantExperience(boolean experience)
      Sets the trade offer to be generated to grant experience to the customer upon use.
      Parameters:
      experience - Whether the offer will grant experience
      Returns:
      This builder
    • merchantExperienceGranted

      TradeOffer.Builder merchantExperienceGranted(int experience)
      Sets how much experience the trade offer will grant to the merchant upon use.
      Parameters:
      experience - The amount of experience.
      Returns:
      This builder
    • priceGrowthMultiplier

      TradeOffer.Builder priceGrowthMultiplier(double priceGrowthMultiplier)
      Sets the rate at which the generated trade offer's price will grow when demand for an item increases. Every time a villager trades, this value is multiplied by the current price of the offer and the demand bonus.

      If this value is 0, trade demand will have no effect on this offer's price.

      Parameters:
      priceGrowthMultiplier - The offer's rate of price growth
      Returns:
      This builder
      See Also:
    • demandBonus

      TradeOffer.Builder demandBonus(int bonus)
      Sets the demand bonus for this trade offer.
      Parameters:
      bonus - The offer's demand bonus
      Returns:
      This builder
    • build

      Creates a new TradeOffer instance with the current state of the builder.
      Specified by:
      build in interface AbstractBuilder<TradeOffer>
      Returns:
      A new trade offer instance
      Throws:
      IllegalStateException - If the resulting trade offer would be invalid