Interface TradeOffer
- All Superinterfaces:
DataSerializable
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a builder to generate immutableTradeOffers. -
Method Summary
Modifier and TypeMethodDescriptionstatic TradeOffer.Builderbuilder()Creates a newTradeOffer.Builderto build aTradeOffer.intGets the demand bonus for this trade offer.booleanGets whether this trade offer will grant experience to the customer upon usage or not.intGets the amount of experience granted to the merchant when this trade offer is used.Gets the first buying item.booleanChecks if this trade offer has indeed passed the time of which the uses surpassed the maximum uses.booleanReturns whether this trade offer has a second item the merchant is buying from the customer.intmaxUses()Gets the current maximum uses of this offer.doubleGets the rate at which this trade offer's price will grow when demand for an item increases.Gets the second buying item.Gets the selling item theMerchantwill give to the customer often in exchange for a single item or sometimes, two items from the following methods:firstBuyingItem()andsecondBuyingItem().intuses()Gets the current uses of this offer.Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Method Details
-
builder
Creates a newTradeOffer.Builderto build aTradeOffer.- 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 forsellingItem().- Returns:
- The second buying item, if available
-
sellingItem
ItemStackSnapshot sellingItem()Gets the selling item theMerchantwill give to the customer often in exchange for a single item or sometimes, two items from the following methods:firstBuyingItem()andsecondBuyingItem().- 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
-