Package org.bukkit.inventory
Class MerchantRecipe
java.lang.Object
org.bukkit.inventory.MerchantRecipe
- All Implemented Interfaces:
Recipe
Represents a merchant's trade.
Trades can take one or two ingredients, and provide one result. The
ingredients' ItemStack amounts are respected in the trade.
A trade has a limited number of uses, after which the trade can no longer be used, unless the player uses a different trade, which will cause its maximum uses to increase.
A trade may or may not reward experience for being completed.
A trade has a limited number of uses, after which the trade can no longer be used, unless the player uses a different trade, which will cause its maximum uses to increase.
A trade may or may not reward experience for being completed.
- See Also:
VillagerReplenishTradeEvent
-
Constructor Summary
ConstructorDescriptionMerchantRecipe(@NotNull ItemStack result, int maxUses)
MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward)
MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier)
MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier, boolean ignoreDiscounts)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addIngredient(@NotNull ItemStack item)
int
Get the maximum number of uses this trade has.float
Gets the additive price multiplier for the cost of this trade.Get the result of this recipe.int
getUses()
Get the number of times this trade has been used.int
Gets the amount of experience the villager earns from this trade.boolean
Whether to reward experience to the player for the trade.void
removeIngredient(int index)
void
setExperienceReward(boolean flag)
Set whether to reward experience to the player for the trade.void
setIgnoreDiscounts(boolean ignoreDiscounts)
void
setIngredients(@NotNull List<ItemStack> ingredients)
void
setMaxUses(int maxUses)
Set the maximum number of uses this trade has.void
setPriceMultiplier(float priceMultiplier)
Sets the additive price multiplier for the cost of this trade.void
setUses(int uses)
Set the number of times this trade has been used.void
setVillagerExperience(int villagerExperience)
Sets the amount of experience the villager earns from this trade.boolean
-
Constructor Details
-
MerchantRecipe
-
MerchantRecipe
-
MerchantRecipe
-
MerchantRecipe
-
-
Method Details
-
getResult
Description copied from interface:Recipe
Get the result of this recipe. -
addIngredient
-
removeIngredient
public void removeIngredient(int index) -
setIngredients
-
getIngredients
-
getUses
public int getUses()Get the number of times this trade has been used.- Returns:
- the number of uses
-
setUses
public void setUses(int uses)Set the number of times this trade has been used.- Parameters:
uses
- the number of uses
-
getMaxUses
public int getMaxUses()Get the maximum number of uses this trade has.
The maximum uses of this trade may increase when a player trades with the owning merchant.- Returns:
- the maximum number of uses
-
setMaxUses
public void setMaxUses(int maxUses)Set the maximum number of uses this trade has.- Parameters:
maxUses
- the maximum number of time this trade can be used
-
hasExperienceReward
public boolean hasExperienceReward()Whether to reward experience to the player for the trade.- Returns:
- whether to reward experience to the player for completing this trade
-
setExperienceReward
public void setExperienceReward(boolean flag)Set whether to reward experience to the player for the trade.- Parameters:
flag
- whether to reward experience to the player for completing this trade
-
getVillagerExperience
public int getVillagerExperience()Gets the amount of experience the villager earns from this trade.- Returns:
- villager experience
-
setVillagerExperience
public void setVillagerExperience(int villagerExperience)Sets the amount of experience the villager earns from this trade.- Parameters:
villagerExperience
- new experience amount
-
getPriceMultiplier
public float getPriceMultiplier()Gets the additive price multiplier for the cost of this trade.- Returns:
- price multiplier
-
setPriceMultiplier
public void setPriceMultiplier(float priceMultiplier)Sets the additive price multiplier for the cost of this trade.- Parameters:
priceMultiplier
- new price multiplier
-
shouldIgnoreDiscounts
public boolean shouldIgnoreDiscounts()- Returns:
- Whether all discounts on this trade should be ignored.
-
setIgnoreDiscounts
public void setIgnoreDiscounts(boolean ignoreDiscounts)- Parameters:
ignoreDiscounts
- Whether all discounts on this trade should be ignored.
-