Interface TradeOffer.Builder
- All Superinterfaces:
AbstractBuilder<TradeOffer>
,Builder<TradeOffer,
,TradeOffer.Builder> CopyableBuilder<TradeOffer,
,TradeOffer.Builder> DataBuilder<TradeOffer>
,ResettableBuilder<TradeOffer,
TradeOffer.Builder>
- Enclosing interface:
TradeOffer
public static interface TradeOffer.Builder
extends Builder<TradeOffer,TradeOffer.Builder>, CopyableBuilder<TradeOffer,TradeOffer.Builder>, DataBuilder<TradeOffer>
Represents a builder to generate immutable
TradeOffer
s.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates a new TradeOffer instance with the current state of the builder.canGrantExperience
(boolean experience) Sets the trade offer to be generated to grant experience to the customer upon use.demandBonus
(int bonus) Sets the demand bonus for this trade offer.firstBuyingItem
(ItemStack item) Sets the first selling item of the trade offer to be generated.maxUses
(int maxUses) Sets the maximum uses the generated trade offer will have.merchantExperienceGranted
(int experience) Sets how much experience the trade offer will grant to the merchant upon use.priceGrowthMultiplier
(double priceGrowthMultiplier) Sets the rate at which the generated trade offer's price will grow when demand for an item increases.secondBuyingItem
(ItemStack item) Sets the second selling item of the trade offer to be generated.sellingItem
(ItemStack item) Sets the selling item of the trade offer to be generated.uses
(int uses) Sets the existing uses of the trade offer to be generated.Methods inherited from interface org.spongepowered.api.util.CopyableBuilder
from
Methods inherited from interface org.spongepowered.api.data.persistence.DataBuilder
build
-
Method Details
-
firstBuyingItem
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
Sets the second selling item of the trade offer to be generated.- Parameters:
item
- The second item to buy- Returns:
- This builder
-
sellingItem
Sets the selling item of the trade offer to be generated.- Parameters:
item
- The item to sell- Returns:
- This builder
-
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
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
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
Sets how much experience the trade offer will grant to the merchant upon use.- Parameters:
experience
- The amount of experience.- Returns:
- This builder
-
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
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 interfaceAbstractBuilder<TradeOffer>
- Returns:
- A new trade offer instance
- Throws:
IllegalStateException
- If the resulting trade offer would be invalid
-