From 9af900778d056dd395b5a3f7e950e529890ddef9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 22 Jun 2019 18:24:23 +1000 Subject: [PATCH] SPIGOT-5097: Bukkit.clearRecipes() no longer working --- nms-patches/CraftingManager.patch | 14 +++++--------- .../java/org/bukkit/craftbukkit/CraftServer.java | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch index 6e8e379e98..ae5cdcfd63 100644 --- a/nms-patches/CraftingManager.patch +++ b/nms-patches/CraftingManager.patch @@ -90,22 +90,18 @@ }).filter(Objects::nonNull).findFirst(); } -@@ -118,4 +138,18 @@ +@@ -118,4 +138,14 @@ return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'"); })).a(minecraftkey, jsonobject); } + + // CraftBukkit start -+ public static void initializeRecipeMap(Map, Object2ObjectLinkedOpenHashMap>> map) { -+ map.clear(); -+ Iterator iterator = IRegistry.RECIPE_TYPE.iterator(); ++ public void clearRecipes() { ++ this.recipes = Maps.newHashMap(); + -+ while (iterator.hasNext()) { -+ Recipes recipes = (Recipes) iterator.next(); -+ -+ map.put(recipes, new Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit ++ for (Recipes recipeType : IRegistry.RECIPE_TYPE) { ++ this.recipes.put(recipeType, new Object2ObjectLinkedOpenHashMap<>()); + } -+ + } + // CraftBukkit end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index a94b5c43a6..a6a6fba26a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1100,7 +1100,7 @@ public final class CraftServer implements Server { @Override public void clearRecipes() { - CraftingManager.initializeRecipeMap(console.getCraftingManager().recipes); + console.getCraftingManager().clearRecipes(); } @Override