Interface TradeOffer

All Superinterfaces:
DataSerializable

public interface TradeOffer extends DataSerializable

Represents a trade offer that a Merchant may offer a Humanoid.

TradeOffers usually have a limited amount of times they can be used.

Also, trade offers are not guaranteed to have two buying items.

  • Method Details

    • builder

      static TradeOffer.Builder builder()
      Creates a new TradeOffer.Builder to build a TradeOffer.
      Returns:
      The new builder
    • firstBuyingItem

      ItemStackSnapshot firstBuyingItem()
      Gets the first buying item.

      The first buying item is an item that the customer is selling to the merchant in exchange for sellingItem().

      Returns:
      The first buying item
    • hasSecondItem

      boolean hasSecondItem()
      Returns whether this trade offer has a second item the merchant is buying from the customer.
      Returns:
      True if there is a second buying item
    • secondBuyingItem

      Optional<ItemStackSnapshot> secondBuyingItem()

      Gets the second buying item.

      The second buying item is an item that the customer is selling to the merchant, along with the firstBuyingItem(), in exchange for sellingItem().

      Returns:
      The second buying item, if available
    • sellingItem

      ItemStackSnapshot sellingItem()
      Gets the selling item the Merchant will give to the customer often in exchange for a single item or sometimes, two items from the following methods: firstBuyingItem() and secondBuyingItem().
      Returns:
      The selling item
    • uses

      int uses()

      Gets the current uses of this offer.

      Usually, the uses of an offer are limited by the amount of maxUses(). Once the uses reaches the max uses, the offer may temporarily become disabled.

      Returns:
      The current uses of this trade offer
    • maxUses

      int maxUses()

      Gets the current maximum uses of this offer.

      Usually, the uses of an offer are limited by the amount of maximum uses. Once the uses reaches the max uses, the offer may temporarily become disabled.

      Returns:
      The maximum uses of this trade offer
    • hasExpired

      boolean hasExpired()
      Checks if this trade offer has indeed passed the time of which the uses surpassed the maximum uses.
      Returns:
      True if the uses have surpassed the maximum uses
    • doesGrantExperience

      boolean doesGrantExperience()
      Gets whether this trade offer will grant experience to the customer upon usage or not.
      Returns:
      True if using this trade offer will grant experience to the customer
    • experienceGrantedToMerchant

      int experienceGrantedToMerchant()
      Gets the amount of experience granted to the merchant when this trade offer is used.
      Returns:
      The experience to be granted to the merchant
    • priceGrowthMultiplier

      double priceGrowthMultiplier()
      Gets the rate at which this 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, demand will have no effect on this offer's price.

      Returns:
      the price growth multiplier
      See Also:
    • demandBonus

      int demandBonus()
      Gets the demand bonus for this trade offer.
      Returns:
      the demand bonus