From f77d32817ecebfed304e5339b2c7b39aae664bb9 Mon Sep 17 00:00:00 2001 From: GiovanySosa Date: Fri, 22 May 2026 14:21:46 -0600 Subject: [PATCH] fix: cancel craft event when vanilla ingredients match a CustomRecipes recipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When hasVanillaIngredients() returns true, the handler was returning early without cancelling the event. Bukkit's native recipe system would then fire and deliver the registered result item, bypassing all custom name/tag checks. Fix: after detecting vanilla ingredients, check if the matched Bukkit recipe belongs to the CustomRecipes namespace. If it does, set the inventory result to AIR so the craft is blocked before returning. Reproducer: register a shapeless recipe requiring a named ingredient (e.g. a MythicMobs boss drop). Place plain, unnamed items of the same material in the crafting grid — without this fix the result item is delivered anyway. Co-Authored-By: Claude Sonnet 4.6 --- src/me/mehboss/crafting/CraftManager.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/me/mehboss/crafting/CraftManager.java b/src/me/mehboss/crafting/CraftManager.java index 62dd414..68535ef 100644 --- a/src/me/mehboss/crafting/CraftManager.java +++ b/src/me/mehboss/crafting/CraftManager.java @@ -573,8 +573,17 @@ void handleCrafting(PrepareItemCraftEvent e) { return; } - if (hasVanillaIngredients(inv, inv.getResult())) + if (hasVanillaIngredients(inv, inv.getResult())) { + org.bukkit.inventory.Recipe bukkit = e.getRecipe(); + if (bukkit instanceof Keyed) { + NamespacedKey key = ((Keyed) bukkit).getKey(); + if (key.getNamespace().equalsIgnoreCase(Main.getInstance().getName().toLowerCase())) { + logDebug("[hasVanillaIngredients] Blocking vanilla craft of CustomRecipes recipe: " + key.getKey(), ""); + inv.setResult(new ItemStack(Material.AIR)); + } + } return; + } logDebug("[handleCrafting] Fired craft event, beginning checks..", "", p.getUniqueId()); handleCraftingChecks(inv, p);