diff --git a/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java index 36bfe05f2a..c6d849af00 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java @@ -1,16 +1,18 @@ package org.bukkit.event.entity; import org.bukkit.entity.AbstractVillager; +import org.bukkit.entity.Villager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; import org.jetbrains.annotations.NotNull; /** - * Called when a villager's trade's maximum uses is increased, due to a player's - * trade. - * - * @see MerchantRecipe#getMaxUses() + * Called when a {@link Villager} is about to restock one of its trades. + *
+ * If this event passes, the villager will reset the
+ * {@link MerchantRecipe#getUses() uses} of the affected {@link #getRecipe()
+ * MerchantRecipe} to 0
.
*/
public class VillagerReplenishTradeEvent extends EntityEvent implements Cancellable {
@@ -18,12 +20,10 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
private boolean cancelled;
//
private MerchantRecipe recipe;
- private int bonus;
- public VillagerReplenishTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe, int bonus) {
+ public VillagerReplenishTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe) {
super(what);
this.recipe = recipe;
- this.bonus = bonus;
}
/**
@@ -46,23 +46,26 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
}
/**
- * Get the bonus uses added. The maximum uses of the recipe will be
- * increased by this number.
+ * Get the bonus uses added.
*
* @return the extra uses added
+ * @deprecated MC 1.14 has changed how villagers restock their trades. Use
+ * {@link MerchantRecipe#getUses()}.
*/
+ @Deprecated
public int getBonus() {
- return bonus;
+ return recipe.getUses();
}
/**
* Set the bonus uses added.
*
* @param bonus the extra uses added
- * @see VillagerReplenishTradeEvent#getBonus()
+ * @deprecated MC 1.14 has changed how villagers restock their trades. This
+ * has no effect anymore.
*/
+ @Deprecated
public void setBonus(int bonus) {
- this.bonus = bonus;
}
@Override
diff --git a/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java
index 620a4df816..d33b66facf 100644
--- a/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java
+++ b/paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java
@@ -4,7 +4,7 @@ import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
-import org.bukkit.event.entity.VillagerReplenishTradeEvent;
+import org.bukkit.entity.Villager;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.NumberConversions;
import org.jetbrains.annotations.NotNull;
@@ -12,16 +12,16 @@ import org.jetbrains.annotations.Nullable;
/**
* 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 has a maximum number of uses. A {@link Villager} may periodically
+ * replenish its trades by resetting the {@link #getUses uses} of its merchant
+ * recipes to 0
, allowing them to be used again.
+ *
* A trade may or may not reward experience for being completed.
- *
+ *
* During trades, the {@link MerchantRecipe} dynamically adjusts the amount of * its first ingredient based on the following criteria: *
1
and the item stack's
* {@link ItemStack#getMaxStackSize() maximum stack size}.
- *
- * @see org.bukkit.event.entity.VillagerReplenishTradeEvent
*/
public class MerchantRecipe implements Recipe {
@@ -159,20 +157,18 @@ public class MerchantRecipe implements Recipe {
}
/**
- * Get the value of the demand for the item in {@link #getResult()}.
+ * Get the demand for this trade.
*
- * @return the demand for the item
+ * @return the demand
*/
public int getDemand() {
return demand;
}
/**
- * Set the value of the demand for the item in {@link #getResult()}.
- *