Java 类org.bukkit.event.inventory.InventoryMoveItemEvent 实例源码

项目:SuperiorCraft    文件:CustomCrafting.java   
@EventHandler
public void onCraft(InventoryMoveItemEvent e) {
    Bukkit.broadcastMessage(e.getDestination().getName());
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
        @Override
        public void run() {
            for (CustomCraftingRecipe r : recipes) {
                if (r.check(e.getDestination().getContents(), e.getDestination())) {
                    //System.out.println();
                    r.onCraft(e);
                    return;
                }
            }
        }
    }, 10);
}
项目:SuperiorCraft    文件:CustomCrafting.java   
@EventHandler
public void onCraft(InventoryMoveItemEvent e) {
    Bukkit.broadcastMessage(e.getDestination().getName());
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
        @Override
        public void run() {
            for (CustomCraftingRecipe r : recipes) {
                if (r.check(e.getDestination().getContents(), e.getDestination())) {
                    //System.out.println();
                    r.onCraft(e);
                    return;
                }
            }
        }
    }, 10);
}
项目:ShopChest    文件:ChestProtectListener.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent e) {
    if (config.hopper_protection) {
        if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {

            if (e.getSource().getHolder() instanceof DoubleChest) {
                DoubleChest dc = (DoubleChest) e.getSource().getHolder();
                Chest r = (Chest) dc.getRightSide();
                Chest l = (Chest) dc.getLeftSide();

                if (shopUtils.isShop(r.getLocation()) || shopUtils.isShop(l.getLocation())) e.setCancelled(true);

            } else if (e.getSource().getHolder() instanceof Chest) {
                Chest c = (Chest) e.getSource().getHolder();

                if (shopUtils.isShop(c.getLocation())) e.setCancelled(true);
            }

        }
    }
}
项目:CratesPlus    文件:BlockListeners.java   
@EventHandler
public void onInventoryMove(InventoryMoveItemEvent event) {
    if (!cratesPlus.getConfigHandler().isDisableKeySwapping())
        return;
    String title;
    ItemStack item = event.getItem();

    for (Map.Entry<String, Crate> crate : cratesPlus.getConfigHandler().getCrates().entrySet()) {
        if (!(crate.getValue() instanceof KeyCrate)) {
            continue;
        }
        KeyCrate keyCrate = (KeyCrate) crate.getValue();
        Key key = keyCrate.getKey();
        if (key == null)
            continue;
        title = key.getName();

        if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().contains(title)) {
            // Send message?
            event.setCancelled(true);
            return;
        }
    }
}
项目:BlockLocker    文件:InteractListener.java   
@EventHandler(ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Block from = getInventoryBlockOrNull(event.getSource());
    Block to = getInventoryBlockOrNull(event.getDestination());

    if (from != null) {
        if (isProtectedForRedstone(from)) {
            event.setCancelled(true);
            return;
        }
    }
    if (to != null) {
        if (isProtectedForRedstone(to)) {
            event.setCancelled(true);
            return;
        }
    }
}
项目:SavageDeathChest    文件:InventoryEventListener.java   
/**
 * Prevent hoppers from removing or inserting items in death chests
 * @param event
 */
@EventHandler
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {

    // get inventories involved in event
    Inventory destination = event.getDestination();
    Inventory source = event.getSource();

    // if source inventory is a death chest, cancel event and return
    if (inventoryIsDeathChest(source)) {
        event.setCancelled(true);
        return;
    }

    // if destination is a death chest and prevent-item-placement is true, cancel event and return
    if (inventoryIsDeathChest(destination) && plugin.getConfig().getBoolean("prevent-item-placement")) {
        event.setCancelled(true);
        return;
    }
}
项目:ItemExchange    文件:ItemExchangeListener.java   
@EventHandler(ignoreCancelled = true)
public void onInventoryMove(InventoryMoveItemEvent event) {
    ItemStack item = event.getItem();

    try {
        ExchangeRule.parseRuleBlock(item);
    }
    catch(ExchangeRuleParseException e) {
        try {
            ExchangeRule.parseBulkRuleBlock(item);
        }
        catch(ExchangeRuleParseException e2) {
            return;
        }
    }

    event.setCancelled(true);
}
项目:NeverLag    文件:AntiNetherHopper.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onHopper(InventoryMoveItemEvent e) {
    if (cm.isAntiNetherHopper) {
        if (e.getInitiator().getHolder() instanceof Hopper) {
            Hopper hopper = (Hopper) e.getInitiator().getHolder();
            if (hopper.getWorld().getEnvironment() == World.Environment.NETHER) {
                e.setCancelled(true);
            }
        }
    }
}
项目:HCFCore    文件:SignSubclaimListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
    if (plugin.getEotwHandler().isEndOfTheWorld())
        return;
    InventoryHolder holder = event.getSource().getHolder();

    // Have to do this hackery since Bukkit doesn't
    // provide an API for us to do this
    Collection<Block> sourceBlocks;
    if (holder instanceof Chest) {
        sourceBlocks = Collections.singletonList(((Chest) holder).getBlock());
    } else if (holder instanceof DoubleChest) {
        DoubleChest doubleChest = (DoubleChest) holder;
        sourceBlocks = Lists.newArrayList(((Chest) doubleChest.getLeftSide()).getBlock(), ((Chest) doubleChest.getRightSide()).getBlock());
    } else {
        return;
    }

    for (Block block : sourceBlocks) {
        if (isSubclaimable(block)) {
            Collection<Sign> attachedSigns = getAttachedSigns(block);
            for (Sign attachedSign : attachedSigns) {
                String[] lines = attachedSign.getLines();
                if (lines[0].equals(SignSubclaimListener.SUBCLAIM_CONVERSION_PREFIX)) {
                    event.setCancelled(true);
                    break;
                }
            }
        }
    }
}
项目:HCFCore    文件:SignSubclaimListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
    if (plugin.getEotwHandler().isEndOfTheWorld())
        return;
    InventoryHolder holder = event.getSource().getHolder();

    // Have to do this hackery since Bukkit doesn't
    // provide an API for us to do this
    Collection<Block> sourceBlocks;
    if (holder instanceof Chest) {
        sourceBlocks = Collections.singletonList(((Chest) holder).getBlock());
    } else if (holder instanceof DoubleChest) {
        DoubleChest doubleChest = (DoubleChest) holder;
        sourceBlocks = Lists.newArrayList(((Chest) doubleChest.getLeftSide()).getBlock(), ((Chest) doubleChest.getRightSide()).getBlock());
    } else {
        return;
    }

    for (Block block : sourceBlocks) {
        if (isSubclaimable(block)) {
            Collection<Sign> attachedSigns = getAttachedSigns(block);
            for (Sign attachedSign : attachedSigns) {
                String[] lines = attachedSign.getLines();
                if (lines[0].equals(SignSubclaimListener.SUBCLAIM_CONVERSION_PREFIX)) {
                    event.setCancelled(true);
                    break;
                }
            }
        }
    }
}
项目:TimeIsMoney    文件:ATM.java   
@EventHandler
public void onMove(InventoryMoveItemEvent e) {
    if (e.getSource() == null) return;
    if (e.getSource().getTitle() == null) return;
    if (e.getSource().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
        e.setCancelled(true);
    }
}
项目:Slimefun4    文件:ItemListener.java   
/**
 * Listens to InventoryMoveItemEvent to handle IGNITION_CHAMBER.
 * @param e InventoryMoveItemEvent
 * @since 4.1.11
 */
@EventHandler
public void onIgnitionChamberItemMove(InventoryMoveItemEvent e) {
    if (e.getInitiator().getHolder() instanceof Hopper) {
        if (BlockStorage.check(((Hopper) e.getInitiator().getHolder()).getBlock(), "IGNITION_CHAMBER")) {
            e.setCancelled(true);
        }
    }
}
项目:SortingHopper    文件:HopperListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory initiator = event.getInitiator();
    Inventory dest = event.getDestination();
    Inventory source = event.getSource();

    //Prevent items from being pulled out by other hopper
if(plugin.getConfig().getBoolean("preventitempull")){
    if(plugin.checkNames(source.getName()) && initiator != source){ 
        event.setCancelled(true);        
    }
}

    if(plugin.checkNames(initiator.getName())){   
        if(!initiator.contains(event.getItem().getType())) {

            event.setCancelled(true);

            //Try to move items in other slots
            if(dest != initiator) {
                for(int slot=1; slot < initiator.getSize(); slot++) {
                    if(this.MoveItem(initiator, slot, dest) == true){break;}
               }                
            }            
        }
    }
}
项目:SyncChest    文件:InventoryMoveListener.java   
@EventHandler
   public void onInventoryEvent(InventoryMoveItemEvent event) {

SyncHopper hopper = SyncManager.getManager().getHopper(event.getInitiator());

if (hopper != null) {
    hopper.transmit(event.getItem().clone(), event.getSource());
    return;
}
   }
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory inventory = event.getDestination();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    ItemStack item = event.getItem();

    if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
        AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
    }
}
项目:modules-extra    文件:ListenerItemMove.java   
@EventHandler
public void onItemMove(InventoryMoveItemEvent event)
{
    Inventory source = event.getSource();
    Inventory target = event.getDestination();

    if (target == null || source == null)
    {
        this.module.getLog().warn("InventoryMoveItem has null {} -> {} This should never happen!", source, target);
        return;
    }
    Location sourceLocation = this.getLocationForHolder(source.getHolder());
    if (sourceLocation == null)
    {
        return;
    }
    Location targetLocation = this.getLocationForHolder(target.getHolder());
    if (targetLocation == null)
    {
        return;
    }
    ItemMove action = this.newAction(ItemMove.class, targetLocation.getWorld());
    if (action != null)
    {
        LoggingConfiguration config = this.getConfig(targetLocation.getWorld());
        if (config.container.moveIgnore.contains(event.getItem().getType()))
        {
            return;
        }
        action.item = event.getItem();
        action.setLocation(sourceLocation);
        action.direction = sourceLocation.getBlock().getFace(targetLocation.getBlock());
        action.fromContainer = new ContainerType(source.getHolder());
        action.toContainer = new ContainerType(target.getHolder());
        this.logAction(action);
    }
}
项目:sensibletoolbox    文件:TrashCanListener.java   
@EventHandler
public void onMoveItemToTrashCan(InventoryMoveItemEvent event) {
    final TrashCan can = TrashCan.getTrashCan(event.getDestination());
    if (can != null) {
        Bukkit.getScheduler().runTask(plugin, new Runnable() {
            @Override
            public void run() {
                can.emptyTrash(false);
            }
        });
    }
}
项目:CraftoPlugin    文件:Menu.java   
@EventHandler
public void onItemMove(InventoryMoveItemEvent event) {
    try {
        if (event.getDestination() != null && event.getDestination().equals(this.inventory)) {
            event.setCancelled(true);
        }
        if (event.getSource() != null && event.getSource().equals(this.inventory)) {
            event.setCancelled(true);
        }
    }
    catch (final Exception e) { CraftoMessenger.report(this, "Failed to handle item move event!", e); }
}
项目:HopperFilterSimplified    文件:HfsBlockListener.java   
/** 
 * Event handler to watch whenever a container tries to move an item to another container.
 * Hoppers for example are the only thing that triggers this so far.
 * If the item being moved is not allowed in the destination container, then the event will be canceled to prevent the move.
 *
 *  @param event InventoryMoveItemEvent containing data about the event given by the system. We care about hoppers being the receiving end of the transfer.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    //Get destination container
    InventoryHolder destHolder = event.getDestination().getHolder();

    //since we only care about hoppers, then ignore everything else
    if (destHolder instanceof Hopper) {
        //Get the location of the hopper in question.  
        Block hopperBlock = ((Hopper) destHolder).getBlock();

        //Get the cache, if any, for the hopper location.
        String cache = plugin.knownHoppersCache_Get(hopperBlock);

        //get the itemStack that was moved and convert it to a String for comparison
        String eventItemInformation = plugin.GetItemInformationForInventory(event.getItem(), false);

        //debug if requested
        if (plugin.debugLevel_get() > 0) plugin.getLogger().info("Testing item (" + eventItemInformation + ") in hopper (" + hopperBlock.getLocation().toString() + ") against allowed:" + cache);

        //do the actual filtering
        if (cache.length() > 0)
            //we have a cache to compare against
            if (!cache.contains(eventItemInformation))
                //the item is not allowed in the hopper
                event.setCancelled(true);
    }
}
项目:Merlin    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onInventoryMoveItem (InventoryMoveItemEvent event)
  {
    if ( ! (event.getInitiator() instanceof PlayerInventory)
        || ! (event.getDestination() instanceof BrewerInventory))
      return;
    if (event.getItem().getType() != Material.QUARTZ)
      return;
    event.setCancelled(true);
    int amount = event.getItem().getAmount();
    ItemStack[] inv = event.getInitiator().getContents();
    for (int i = 0; i < inv.length; i++)
      {
        ItemStack item = inv[i];
        if (item.getType() != Material.QUARTZ)
          continue;
        if (item.getAmount() == amount)
          {
            inv[i] = null;
          }
        else
          {
            item.setAmount(item.getAmount() - amount);
          }
      }
    event.getInitiator().setContents(inv);
    event.getDestination().setItem(3,
        new ItemStack(Material.QUARTZ, amount));
  }
项目:Shopkeepers    文件:ChestProtectListener.java   
@EventHandler(ignoreCancelled = true)
void onInventoryMoveItem(InventoryMoveItemEvent event) {
    if (event.getSource() != null) {
        InventoryHolder holder = event.getSource().getHolder();
        if (holder != null && holder instanceof Chest) {
            Block block = ((Chest) holder).getBlock();
            if (plugin.getProtectedChests().isChestProtected(block, null)) {
                event.setCancelled(true);
            }
        }
    }
}
项目:Warzone    文件:SpectatorModule.java   
@EventHandler
public void onInventoryMove(InventoryMoveItemEvent event) {
    if (event.getInitiator().getHolder() instanceof Player && isSpectating((Player) event.getInitiator().getHolder())) {
        event.setCancelled(true);
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemListener.java   
@EventHandler
public void onIgnitionChamberItemMove(InventoryMoveItemEvent e) {
    if(BlockStorage.check(((Hopper) e.getInitiator().getHolder()).getBlock(), "IGNITION_CHAMBER")) {
        e.setCancelled(true);
    }
}
项目:SuperiorCraft    文件:InOutRecipe.java   
@Override
public void craft(InventoryMoveItemEvent e) {
    e.getDestination().clear();
    e.getDestination().setItem(4, out);
}
项目:SuperiorCraft    文件:CustomCraftingRecipe.java   
public void onCraft(InventoryMoveItemEvent e) {
    if (nCheck(e.getDestination().getName())) {
        craft(e);
    }
}
项目:ProjectAres    文件:WoolMatchModule.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onItemTransfer(InventoryMoveItemEvent event) {
    // When a hopper or dispenser transfers an item, register both blocks involved
    this.registerContainer(event.getSource());
    this.registerContainer(event.getDestination());
}
项目:PA    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent e) {
    e.setCancelled(true);
}
项目:PA    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent e) {
    e.setCancelled(true);
}
项目:SuperiorCraft    文件:InOutRecipe.java   
@Override
public void craft(InventoryMoveItemEvent e) {
    e.getDestination().clear();
    e.getDestination().setItem(4, out);
}
项目:SuperiorCraft    文件:CustomCraftingRecipe.java   
public void onCraft(InventoryMoveItemEvent e) {
    if (nCheck(e.getDestination().getName())) {
        craft(e);
    }
}
项目:MC2FA    文件:PlayerListener.java   
@EventHandler
public void onItemMove(InventoryMoveItemEvent event) {
    if (mc2FA.getAuthHandler().isQRCodeItem(event.getItem()) && event.getDestination().getType() != InventoryType.PLAYER) {
        event.setCancelled(true);
    }
}
项目:Arcade2    文件:WoolChestTracker.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void registerWoolChests(InventoryMoveItemEvent event) {
    this.registerWoolChest(event.getSource().getHolder());
    this.registerWoolChest(event.getDestination().getHolder());
}
项目:MysteryBags    文件:MysteryBagsListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void inventoryMove(InventoryMoveItemEvent e) {
    if (check(e.getDestination().getType(), e.getItem()))
        e.setCancelled(true);
}
项目:Steel    文件:RollbackInventoryListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
    checkInventoryEvent(event.getSource(), event);
    checkInventoryEvent(event.getDestination(), event);
}
项目:CraftBukkit    文件:BlockDropper.java   
public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public
    SourceBlock sourceblock = new SourceBlock(world, i, j, k);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();

    if (tileentitydispenser != null) {
        int l = tileentitydispenser.i();

        if (l < 0) {
            world.triggerEffect(1001, i, j, k, 0);
        } else {
            ItemStack itemstack = tileentitydispenser.getItem(l);
            int i1 = world.getData(i, j, k) & 7;
            IInventory iinventory = TileEntityHopper.getInventoryAt(world, (double) (i + Facing.b[i1]), (double) (j + Facing.c[i1]), (double) (k + Facing.d[i1]));
            ItemStack itemstack1;

            if (iinventory != null) {
                // CraftBukkit start - Fire event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1));

                org.bukkit.inventory.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(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                world.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    return;
                }
                itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[i1]);
                if (event.getItem().equals(oitemstack) && itemstack1 == null) {
                    // CraftBukkit end
                    itemstack1 = itemstack.cloneItemStack();
                    if (--itemstack1.count == 0) {
                        itemstack1 = null;
                    }
                } else {
                    itemstack1 = itemstack.cloneItemStack();
                }
            } else {
                itemstack1 = this.P.a(sourceblock, itemstack);
                if (itemstack1 != null && itemstack1.count == 0) {
                    itemstack1 = null;
                }
            }

            tileentitydispenser.setItem(l, itemstack1);
        }
    }
}
项目:CraftBukkit    文件:TileEntityHopper.java   
private boolean y() {
    IInventory iinventory = this.z();

    if (iinventory == null) {
        return false;
    } else {
        int i = Facing.OPPOSITE_FACING[BlockHopper.b(this.p())];

        if (this.a(iinventory, i)) {
            return false;
        } else {
            for (int j = 0; j < this.getSize(); ++j) {
                if (this.getItem(j) != null) {
                    ItemStack itemstack = this.getItem(j).cloneItemStack();
                    // CraftBukkit start - Call event when pushing items into other inventories
                    CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(j, 1));

                    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);
                    this.getWorld().getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        this.setItem(j, itemstack);
                        this.c(8); // Delay hopper checks
                        return false;
                    }
                    ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i);

                    if (itemstack1 == null || itemstack1.count == 0) {
                        if (event.getItem().equals(oitemstack)) {
                            iinventory.update();
                        } else {
                            this.setItem(j, itemstack);
                        }
                        // CraftBukkit end
                        return true;
                    }

                    this.setItem(j, itemstack);
                }
            }

            return false;
        }
    }
}
项目:CraftBukkit    文件:TileEntityHopper.java   
private static boolean tryTakeInItemFromSlot(IHopper ihopper, IInventory iinventory, int i, int j) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));

        Inventory sourceInventory;
        // Have to special case large chests as they work oddly
        if (iinventory instanceof InventoryLargeChest) {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
        } else {
            sourceInventory = iinventory.getOwner().getInventory();
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

        ihopper.getWorld().getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            iinventory.setItem(i, itemstack1);

            if (ihopper instanceof TileEntityHopper) {
                ((TileEntityHopper) ihopper).c(8); // Delay hopper checks
            } else if (ihopper instanceof EntityMinecartHopper) {
                ((EntityMinecartHopper) ihopper).l(4); // Delay hopper minecart checks
            }

            return false;
        }
        ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1);

        if (itemstack2 == null || itemstack2.count == 0) {
            if (event.getItem().equals(oitemstack)) {
                iinventory.update();
            } else {
                iinventory.setItem(i, itemstack1);
            }
            // CraftBukkit end

            return true;
        }

        iinventory.setItem(i, itemstack1);
    }

    return false;
}
项目:Almura-Server    文件:BlockDropper.java   
public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public
    SourceBlock sourceblock = new SourceBlock(world, i, j, k);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();

    if (tileentitydispenser != null) {
        int l = tileentitydispenser.j();

        if (l < 0) {
            world.triggerEffect(1001, i, j, k, 0);
        } else {
            ItemStack itemstack = tileentitydispenser.getItem(l);
            int i1 = world.getData(i, j, k) & 7;
            IInventory iinventory = TileEntityHopper.getInventoryAt(world, (double) (i + Facing.b[i1]), (double) (j + Facing.c[i1]), (double) (k + Facing.d[i1]));
            ItemStack itemstack1;

            if (iinventory != null) {
                // CraftBukkit start - Fire event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1));

                org.bukkit.inventory.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(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                world.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    return;
                }
                itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[i1]);
                if (event.getItem().equals(oitemstack) && itemstack1 == null) {
                    // CraftBukkit end
                    itemstack1 = itemstack.cloneItemStack();
                    if (--itemstack1.count == 0) {
                        itemstack1 = null;
                    }
                } else {
                    itemstack1 = itemstack.cloneItemStack();
                }
            } else {
                itemstack1 = this.cX.a(sourceblock, itemstack);
                if (itemstack1 != null && itemstack1.count == 0) {
                    itemstack1 = null;
                }
            }

            tileentitydispenser.setItem(l, itemstack1);
        }
    }
}
项目:Almura-Server    文件:TileEntityHopper.java   
private boolean u() {
    IInventory iinventory = this.v();

    if (iinventory == null) {
        return false;
    } else {
        for (int i = 0; i < this.getSize(); ++i) {
            if (this.getItem(i) != null) {
                ItemStack itemstack = this.getItem(i).cloneItemStack();
                // CraftBukkit start - Call event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));

                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);
                this.getWorld().getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    this.setItem(i, itemstack);
                    this.c(world.spigotConfig.hopperTransfer); // Spigot
                    return false;
                }
                ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[BlockHopper.c(this.p())]);

                if (itemstack1 == null || itemstack1.count == 0) {
                    if (event.getItem().equals(oitemstack)) {
                        iinventory.update();
                    } else {
                        this.setItem(i, itemstack);
                    }
                    // CraftBukkit end
                    return true;
                }

                this.setItem(i, itemstack);
            }
        }

        return false;
    }
}
项目:Almura-Server    文件:TileEntityHopper.java   
private static boolean tryTakeInItemFromSlot(IHopper ihopper, IInventory iinventory, int i, int j) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));

        Inventory sourceInventory;
        // Have to special case large chests as they work oddly
        if (iinventory instanceof InventoryLargeChest) {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
        } else {
            sourceInventory = iinventory.getOwner().getInventory();
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

        ihopper.getWorld().getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            iinventory.setItem(i, itemstack1);

            if (ihopper instanceof TileEntityHopper) {
                ((TileEntityHopper) ihopper).c(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
            } else if (ihopper instanceof EntityMinecartHopper) {
                ((EntityMinecartHopper) ihopper).l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
            }

            return false;
        }
        ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1);

        if (itemstack2 == null || itemstack2.count == 0) {
            if (event.getItem().equals(oitemstack)) {
                iinventory.update();
            } else {
                iinventory.setItem(i, itemstack1);
            }
            // CraftBukkit end

            return true;
        }

        iinventory.setItem(i, itemstack1);
    }

    return false;
}