Interface TradeOffer.Builder
-
- All Superinterfaces:
Buildable.Builder<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 immutableTradeOffer
s.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TradeOffer
build()
Creates a new TradeOffer instance with the current state of the builder.TradeOffer.Builder
canGrantExperience(boolean experience)
Sets the trade offer to be generated to grant experience to the customer upon use.TradeOffer.Builder
demandBonus(int bonus)
Sets the demand bonus for this trade offer.TradeOffer.Builder
firstBuyingItem(ItemStack item)
Sets the first selling item of the trade offer to be generated.TradeOffer.Builder
maxUses(int maxUses)
Sets the maximum uses the generated trade offer will have.TradeOffer.Builder
merchantExperienceGranted(int experience)
Sets how much experience the trade offer will grant to the merchant upon use.TradeOffer.Builder
priceGrowthMultiplier(double priceGrowthMultiplier)
Sets the rate at which the generated trade offer's price will grow when demand for an item increases.TradeOffer.Builder
secondBuyingItem(ItemStack item)
Sets the second selling item of the trade offer to be generated.TradeOffer.Builder
sellingItem(ItemStack item)
Sets the selling item of the trade offer to be generated.TradeOffer.Builder
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 Detail
-
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:
- the Minecraft Wiki for more detail on how the price growth multiplier applies to trade offers
-
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
TradeOffer build() throws IllegalStateException
Creates a new TradeOffer instance with the current state of the builder.- Specified by:
build
in interfaceBuildable.Builder<TradeOffer>
- Returns:
- A new trade offer instance
- Throws:
IllegalStateException
- If the resulting trade offer would be invalid
-
-