Special case large chests for hopper events. Fixes BUKKIT-3916

Large chests work in a different fashion as they are a combination of
two other inventories. This causes their getOwner method to always return
null as their is no correct return. To compensate for this for the hopper
events we special case them to use their CraftBukkit counterpart that has
the information we need for the event.
Dieser Commit ist enthalten in:
Travis Watkins 2013-03-29 22:27:07 -05:00
Ursprung ee572114dd
Commit 82e05d435b

Datei anzeigen

@ -205,7 +205,14 @@ public class TileEntityHopper extends TileEntity implements IHopper {
// CraftBukkit start - Call event when pushing items into other inventories // CraftBukkit start - Call event when pushing items into other inventories
CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1)); CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));
Inventory destinationInventory = iinventory.getOwner() != null ? iinventory.getOwner().getInventory() : null; Inventory destinationInventory;
// Have to special case large chests as they work oddly
if (iinventory instanceof InventoryLargeChest) {
destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
} else {
destinationInventory = iinventory.getOwner().getInventory();
}
InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
this.getWorld().getServer().getPluginManager().callEvent(event); this.getWorld().getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {