Interface TradeOffer
-
- All Superinterfaces:
DataSerializable
public interface TradeOffer extends DataSerializable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
TradeOffer.Builder
Represents a builder to generate immutableTradeOffer
s.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static TradeOffer.Builder
builder()
Creates a newTradeOffer.Builder
to build aTradeOffer
.int
demandBonus()
Gets the demand bonus for this trade offer.boolean
doesGrantExperience()
Gets whether this trade offer will grant experience to the customer upon usage or not.int
experienceGrantedToMerchant()
Gets the amount of experience granted to the merchant when this trade offer is used.ItemStackSnapshot
firstBuyingItem()
Gets the first buying item.boolean
hasExpired()
Checks if this trade offer has indeed passed the time of which the uses surpassed the maximum uses.boolean
hasSecondItem()
Returns whether this trade offer has a second item the merchant is buying from the customer.int
maxUses()
Gets the current maximum uses of this offer.double
priceGrowthMultiplier()
Gets the rate at which this trade offer's price will grow when demand for an item increases.java.util.Optional<ItemStackSnapshot>
secondBuyingItem()
Gets the second buying item.ItemStackSnapshot
sellingItem()
Gets the selling item theMerchant
will give to the customer often in exchange for a single item or sometimes, two items from the following methods:firstBuyingItem()
andsecondBuyingItem()
.int
uses()
Gets the current uses of this offer.-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
-
-
-
Method Detail
-
builder
static TradeOffer.Builder builder()
Creates a newTradeOffer.Builder
to 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
java.util.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 theMerchant
will 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:
- the Minecraft Wiki for more detail on how the price growth multiplier applies to trade offers
-
demandBonus
int demandBonus()
Gets the demand bonus for this trade offer.- Returns:
- the demand bonus
-
-