Fix NPE thrown when converting MerchantRecipe from Bukkit to NMS (#4755)

This bug was introduced in c451989b86 (Add ignore discounts API)
This commit is contained in:
Jason Penilla 2020-11-11 19:35:44 -08:00
parent 4ca833b607
commit add661a180

View file

@ -41,7 +41,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) {
- this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier);
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, bukkit.shouldIgnoreDiscounts()); // Paper - shouldIgnoreDiscounts
+ // Paper start - add ignoreDiscounts param
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, false, bukkit);
+ }
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, boolean ignoreDiscounts, CraftMerchantRecipe bukkit) {
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, ignoreDiscounts);
+ // Paper end
this.bukkitHandle = bukkit;
}
// CraftBukkit end
@ -100,6 +105,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.handle = new net.minecraft.server.MerchantRecipe(
net.minecraft.server.ItemStack.b,
net.minecraft.server.ItemStack.b,
@@ -0,0 +0,0 @@ public class CraftMerchantRecipe extends MerchantRecipe {
maxUses,
experience,
priceMultiplier,
+ ignoreDiscounts, // Paper - add ignoreDiscounts param
this
);
this.setExperienceReward(experienceReward);
@@ -0,0 +0,0 @@ public class CraftMerchantRecipe extends MerchantRecipe {
handle.priceMultiplier = priceMultiplier;
}