From 43001ca2a8bbb566792496a9ce475f3ab4751135 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sun, 18 Mar 2012 12:25:39 -0400 Subject: [PATCH] [Bleeding] Only fire CraftItemEvent if there's actually an item there to craft (ie, don't fire it for a click on an empty result slot). Fixes BUKKIT-1250 --- .../net/minecraft/server/NetServerHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 58724a31cc..494a702820 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -19,6 +19,7 @@ import org.bukkit.Location; import org.bukkit.command.CommandException; import org.bukkit.conversations.Conversable; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.inventory.CraftInventoryCustom; import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.block.CraftBlock; @@ -47,6 +48,7 @@ import org.bukkit.event.Event.Result; import org.bukkit.event.inventory.*; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.CraftingInventory; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.Recipe; // CraftBukkit end @@ -1146,12 +1148,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener { InventoryView inventory = this.player.activeContainer.getBukkitView(); SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot); - InventoryClickEvent event; - if (packet102windowclick.slot == 0 && inventory.getTopInventory() instanceof CraftingInventory) { - Recipe recipe = ((CraftingInventory) inventory.getTopInventory()).getRecipe(); - event = new CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift); - } else { - event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift); + InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift); + Inventory top = inventory.getTopInventory(); + if (packet102windowclick.slot == 0 && top instanceof CraftingInventory) { + Recipe recipe = ((CraftingInventory) top).getRecipe(); + if (recipe != null) { + event = new CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift); + } } server.getPluginManager().callEvent(event);