From add661a180177603ad27125654833bc64d4c932e Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Wed, 11 Nov 2020 19:35:44 -0800
Subject: [PATCH] Fix NPE thrown when converting MerchantRecipe from Bukkit to
 NMS (#4755)

This bug was introduced in https://github.com/PaperMC/Paper/commit/c451989b86432a21509ee91f5067ec81ea8c3c60 (Add ignore discounts API)
---
 .../Add-ignore-discounts-API.patch                | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Spigot-Server-Patches/Add-ignore-discounts-API.patch b/Spigot-Server-Patches/Add-ignore-discounts-API.patch
index 14655fe170..74b3c45bbd 100644
--- a/Spigot-Server-Patches/Add-ignore-discounts-API.patch
+++ b/Spigot-Server-Patches/Add-ignore-discounts-API.patch
@@ -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;
      }