Skip to content

Commit

Permalink
Add priceMultipler field
Browse files Browse the repository at this point in the history
  • Loading branch information
Reldeam committed Feb 3, 2022
1 parent 6e67e69 commit a20bd68
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ ingredients:
maxUses: <number> # (required) The number of times this trade can be made
# before needing to be refreshed

priceMultiplier: <number> # (required) The trade cost multiplier for items.
# This effects how much the cost of the trade changes depending on factors such
# as how much the villager likes or hates you, as well as how much you have
# traded this item recently.

experience: <number> # (optional) (default: 0) The amount of experience the
# villager/player recieves

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CustomTrade {
private final ItemStack firstIngredient;
private final ItemStack secondIngredient;
private final Integer maxUses;
private final Double priceMultiplier;
private final Integer villagerExperience;
private final Boolean giveExperienceToPlayer;

Expand All @@ -36,6 +37,7 @@ public CustomTrade(
ItemStack firstIngredient,
ItemStack secondIngredient,
Integer maxUses,
Double priceMultiplier,
Integer villagerExperience,
Boolean giveExperienceToPlayer,

Expand All @@ -53,6 +55,7 @@ public CustomTrade(
this.firstIngredient = firstIngredient;
this.secondIngredient = secondIngredient;
this.maxUses = maxUses;
this.priceMultiplier = priceMultiplier;
this.villagerExperience = villagerExperience;
this.giveExperienceToPlayer = giveExperienceToPlayer;

Expand All @@ -70,6 +73,9 @@ public CustomTrade(

recipe.addIngredient(firstIngredient);
if(secondIngredient != null) recipe.addIngredient(secondIngredient);

recipe.setPriceMultiplier(priceMultiplier.floatValue());

recipe.setExperienceReward(giveExperienceToPlayer);
recipe.setVillagerExperience(villagerExperience);

Expand All @@ -95,6 +101,10 @@ public Integer getMaxUses() {
return maxUses;
}

public Double getPriceMultiplier() {
return priceMultiplier;
}

public Double getChance() {
return chance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static public Map<String, CustomTrade> loadTrades(CustomVillagerTrades plugin) {
ItemStack firstIngredient = null;
ItemStack secondIngredient = null;
Integer maxUses = tradeSection.getInt("maxUses");
Double priceMultiplier = tradeSection.getDouble("priceMultiplier");
Integer villagerExperience = tradeSection.getInt("experience");
Boolean giveExperienceToPlayer = tradeSection.getBoolean("giveExperienceToPlayer");

Expand Down Expand Up @@ -154,6 +155,7 @@ static public Map<String, CustomTrade> loadTrades(CustomVillagerTrades plugin) {
firstIngredient,
secondIngredient,
maxUses,
priceMultiplier,
villagerExperience,
giveExperienceToPlayer,
chance,
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/trades.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# The trade is 20 EMERALDS and a NETHER STAR for 2 NETHER SCRAP. You can make
# this trade 2 times before the villager needs to replenish its stock.

# You can also set the priceMultiplier to make it more expensive if the
# villager doesn't like you or if you trade too much.

"netheriteScrapforStar":
result:
material: NETHERITE_SCRAP
Expand All @@ -68,6 +71,7 @@
amount: 20
- material: NETHER_STAR
maxUses: 2
priceMultiplier: 0.2
chance: 0.05
experience: 50
levels: [5]
Expand Down Expand Up @@ -152,11 +156,14 @@
# Sell a diamond for 100 units of your Vault Economy currency.
# This trade requires Vault and an Econony plugin in work.

# You can even add a priceMultipler onto a money item

"moneyForDiamond":
result:
money: 100
ingredients:
- material: DIAMOND
maxUses: 20
priceMultiplier: 0.5
experience: 10
chance: 0.1

0 comments on commit a20bd68

Please sign in to comment.