Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
[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
Dieser Commit ist enthalten in:
Ursprung
93732e21bc
Commit
43001ca2a8
@ -19,6 +19,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.command.CommandException;
|
import org.bukkit.command.CommandException;
|
||||||
import org.bukkit.conversations.Conversable;
|
import org.bukkit.conversations.Conversable;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftInventoryCustom;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
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.*;
|
||||||
import org.bukkit.event.inventory.InventoryType.SlotType;
|
import org.bukkit.event.inventory.InventoryType.SlotType;
|
||||||
import org.bukkit.inventory.CraftingInventory;
|
import org.bukkit.inventory.CraftingInventory;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
import org.bukkit.inventory.Recipe;
|
import org.bukkit.inventory.Recipe;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -1146,12 +1148,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
InventoryView inventory = this.player.activeContainer.getBukkitView();
|
InventoryView inventory = this.player.activeContainer.getBukkitView();
|
||||||
SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot);
|
SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot);
|
||||||
|
|
||||||
InventoryClickEvent event;
|
InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift);
|
||||||
if (packet102windowclick.slot == 0 && inventory.getTopInventory() instanceof CraftingInventory) {
|
Inventory top = inventory.getTopInventory();
|
||||||
Recipe recipe = ((CraftingInventory) inventory.getTopInventory()).getRecipe();
|
if (packet102windowclick.slot == 0 && top instanceof CraftingInventory) {
|
||||||
event = new CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift);
|
Recipe recipe = ((CraftingInventory) top).getRecipe();
|
||||||
} else {
|
if (recipe != null) {
|
||||||
event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift);
|
event = new CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren