From ef17571a3814b3ec7b27b4458854979f3a3ee1ba Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 13 Dec 2021 11:25:22 +1100 Subject: [PATCH] SPIGOT-6851: removeRecipe not unregistering recipe ID By: md_5 --- .../world/item/crafting/CraftingManager.patch | 10 +++++++++- .../main/java/org/bukkit/craftbukkit/CraftServer.java | 8 +------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch index 298e404f2b..0614d702d5 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/crafting/CraftingManager.patch @@ -116,7 +116,7 @@ }); MinecraftKey minecraftkey = irecipe.getId(); IRecipe irecipe1 = (IRecipe) map1.put(minecraftkey, irecipe); -@@ -160,6 +186,18 @@ +@@ -160,6 +186,26 @@ } }); this.recipes = ImmutableMap.copyOf(map); @@ -125,6 +125,14 @@ + } + + // CraftBukkit start ++ public boolean removeRecipe(MinecraftKey mcKey) { ++ for (Object2ObjectLinkedOpenHashMap> recipes : recipes.values()) { ++ recipes.remove(mcKey); ++ } ++ ++ return byName.remove(mcKey) != null; ++ } ++ + public void clearRecipes() { + this.recipes = Maps.newHashMap(); + diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 4a86693ee6..bc7aef61e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1364,13 +1364,7 @@ public final class CraftServer implements Server { Preconditions.checkArgument(recipeKey != null, "recipeKey == null"); MinecraftKey mcKey = CraftNamespacedKey.toMinecraft(recipeKey); - for (Object2ObjectLinkedOpenHashMap> recipes : getServer().getRecipeManager().recipes.values()) { - if (recipes.remove(mcKey) != null) { - return true; - } - } - - return false; + return getServer().getRecipeManager().removeRecipe(mcKey); } @Override