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

项目:ProjectAres    文件:ItemTransferListener.java   
@EventHandler
public void onBlockPickupItem(InventoryPickupItemEvent event) {
    int initialQuantity = getQuantityPlaceable(event.getItem().getItemStack(), event.getInventory());
    ItemTransferEvent transferEvent = new ItemTransferEvent(
        event, ItemTransferEvent.Type.PICKUP,
        Optional.empty(),
        Optional.of(new InventorySlot<>(event.getInventory())),
        event.getItem().getItemStack(), event.getItem(), initialQuantity
    );

    this.callEvent(transferEvent);

    if(initialQuantity != transferEvent.getQuantity() && !event.isCancelled()) {
        event.setCancelled(true);
        ItemStack stack = event.getItem().getItemStack();
        stack.setAmount(stack.getAmount() - transferEvent.getQuantity());
        stack = stack.clone();
        stack.setAmount(transferEvent.getQuantity());
        event.getInventory().addItem(stack);
    }
}
项目:Kineticraft    文件:Dungeons.java   
@EventHandler(ignoreCancelled = true) // Handles special items entering hoppers.
public void onHopperPickup(InventoryPickupItemEvent evt) {
    if (!(evt.getInventory().getHolder() instanceof Hopper))
        return; // Verify the inventory the item is going to enter is a hopper.

    Hopper hp = (Hopper) evt.getInventory().getHolder();
    Matcher mName = Pattern.compile("<Custom ID: (\\w+)>").matcher(hp.getInventory().getName());
    if (!mName.find())
        return; // If it doesn't have a Custom item ID defined, don't handle it.

    ItemWrapper iw = ItemManager.constructItem(evt.getItem().getItemStack());
    evt.setCancelled(true);

    if (mName.group(1).equalsIgnoreCase(iw.getTagString("id"))) { // We've found the right item! Consume it.
        evt.getItem().remove();
        hp.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK);
    } else { // This item isn't acceptable, spit it back out.
        evt.getItem().setVelocity(new Vector(0, .15F, 0));
    }
}
项目:CratesPlus    文件:BlockListeners.java   
@EventHandler
public void onInventoryPickup(InventoryPickupItemEvent event) {
    if (!cratesPlus.getConfigHandler().isDisableKeySwapping())
        return;
    if (event.getItem().getItemStack() != null) {
        String title;
        ItemStack item = event.getItem().getItemStack();
        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;
            }
        }
    }
}
项目:SpigotSource    文件:TileEntityHopper.java   
public static boolean a(IInventory iinventory, EntityItem entityitem) {
    boolean flag = false;

    if (entityitem == null) {
        return false;
    } else {
        // CraftBukkit start
        InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
        entityitem.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end
        ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
        ItemStack itemstack1 = addItem(iinventory, itemstack, (EnumDirection) null);

        if (itemstack1 != null && itemstack1.count != 0) {
            entityitem.setItemStack(itemstack1);
        } else {
            flag = true;
            entityitem.die();
        }

        return flag;
    }
}
项目:ItemExchange    文件:ItemExchangeListener.java   
@EventHandler(ignoreCancelled = true)
public void onInventoryPickupItem(InventoryPickupItemEvent event) {
    if(event.getInventory().getType() != InventoryType.HOPPER) {
        return;
    }

    ItemStack item = event.getItem().getItemStack();

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

    event.setCancelled(true);
}
项目:Slimefun4-Chinese-Version    文件:ItemPickupListener_1_12.java   
@EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) {
    if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
    else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) {
        e.setCancelled(true);
        e.getItem().remove();
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemPickupListener.java   
@EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) {
    if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
    else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) {
        e.setCancelled(true);
        e.getItem().remove();
    }
}
项目:KillerMoney    文件:MoneyHandler.java   
@EventHandler
public void onHopperPickUp(InventoryPickupItemEvent e) {
    if (!DefaultConfig.isMoneyItemDropEnabled()) {
        return;
    }

    if (e.getInventory().getType() != InventoryType.HOPPER) {
        return;
    }

    if (isMoneyItem(e.getItem().getItemStack())) {
        e.setCancelled(true);
    }
}
项目:demigames    文件:GameListener.java   
@EventHandler(priority = EventPriority.LOW)
public void onPickup(InventoryPickupItemEvent event) {
    if (event.getInventory().getHolder() instanceof Player) {
        Player player = (Player) event.getInventory().getHolder();
        Optional<Session> opSession = INST.getSessionRegistry().getSession(player);
        if (opSession.isPresent()) {
            Session session = opSession.get();
            if (session.getGame().isPresent() && !session.getGame().get().canDrop()) {
                event.setCancelled(true);
            }
        }
    }
}
项目:demigames    文件:KitListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onPickup(InventoryPickupItemEvent event) {
    if (event.getInventory().getHolder() instanceof Player &&
            ((Player) event.getInventory().getHolder()).getGameMode() != GameMode.CREATIVE) {
        Profile profile = INST.getProfileRegistry().fromPlayer(INST, (Player) event.getInventory().getHolder());
        if (profile.getKit().isPresent() && profile.getKit().get() instanceof ImmutableKit) {
            event.setCancelled(true);
            ((Player) event.getInventory().getHolder()).updateInventory();
        }
    }
}
项目:CraftBukkit    文件:TileEntityHopper.java   
public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) {
    boolean flag = false;

    if (entityitem == null) {
        return false;
    } else {
        // CraftBukkit start
        InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
        entityitem.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
        ItemStack itemstack1 = addItem(iinventory, itemstack, -1);

        if (itemstack1 != null && itemstack1.count != 0) {
            entityitem.setItemStack(itemstack1);
        } else {
            flag = true;
            entityitem.die();
        }

        return flag;
    }
}
项目:uSkyBlock    文件:ItemDropEvents.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPickupInventoryEvent(InventoryPickupItemEvent event) {
    if (!plugin.isSkyWorld(event.getItem().getWorld())) {
        return;
    }
    // I.e. hoppers...
    clearDropInfo(event.getItem());
}
项目:Slimefun4    文件:ItemPickupListener_1_12.java   
@EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) {
    if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
    else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) {
        e.setCancelled(true);
        e.getItem().remove();
    }
}
项目:Slimefun4    文件:ItemPickupListener.java   
@EventHandler
public void onMinecartPickup(InventoryPickupItemEvent e) {
    if (e.getItem().hasMetadata("no_pickup")) e.setCancelled(true);
    else if (!e.getItem().hasMetadata("no_pickup") && e.getItem().getItemStack().hasItemMeta() && e.getItem().getItemStack().getItemMeta().hasDisplayName() && e.getItem().getItemStack().getItemMeta().getDisplayName().startsWith("&5&dALTAR &3Probe - &e")) {
        e.setCancelled(true);
        e.getItem().remove();
    }
}
项目:SortingHopper    文件:PickupListener.java   
@EventHandler
public void onInventoryPickupEvent(InventoryPickupItemEvent event) {

    if(plugin.checkNames(event.getInventory().getName())) {
        event.setCancelled(true);
    }
}
项目:Almura-Server    文件:TileEntityHopper.java   
public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) {
    boolean flag = false;

    if (entityitem == null) {
        return false;
    } else {
        // CraftBukkit start
        InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
        entityitem.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
        ItemStack itemstack1 = addItem(iinventory, itemstack, -1);

        if (itemstack1 != null && itemstack1.count != 0) {
            entityitem.setItemStack(itemstack1);
        } else {
            flag = true;
            entityitem.die();
        }

        return flag;
    }
}
项目:Tweakkit-Server    文件:TileEntityHopper.java   
public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) {
    boolean flag = false;

    if (entityitem == null) {
        return false;
    } else {
        // CraftBukkit start
        InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
        entityitem.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
        ItemStack itemstack1 = addItem(iinventory, itemstack, -1);

        if (itemstack1 != null && itemstack1.count != 0) {
            entityitem.setItemStack(itemstack1);
        } else {
            flag = true;
            entityitem.die();
        }

        return flag;
    }
}
项目:Cauldron    文件:TileEntityHopper.java   
public static boolean func_145898_a(IInventory p_145898_0_, EntityItem p_145898_1_)
{
    boolean flag = false;

    if (p_145898_1_ == null)
    {
        return false;
    }
    else
    {
        // CraftBukkit start
        // Cauldron start - vanilla compatibility
        if (p_145898_0_.getOwner() != null && p_145898_1_.getBukkitEntity() != null)
        {
            InventoryPickupItemEvent event = new InventoryPickupItemEvent(p_145898_0_.getOwner().getInventory(), (org.bukkit.entity.Item) p_145898_1_.getBukkitEntity());
            p_145898_1_.worldObj.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled())
            {
                return false;
            }
        }
        // Cauldron end
        // CraftBukkit end
        ItemStack itemstack = p_145898_1_.getEntityItem().copy();
        ItemStack itemstack1 = func_145889_a(p_145898_0_, itemstack, -1);

        if (itemstack1 != null && itemstack1.stackSize != 0)
        {
            p_145898_1_.setEntityItemStack(itemstack1);
        }
        else
        {
            flag = true;
            p_145898_1_.setDead();
        }

        return flag;
    }
}
项目:SparkTrail    文件:PlayerListener.java   
@EventHandler
public void onInventoryPickup(InventoryPickupItemEvent event) {
    if (event.getInventory().getType() == InventoryType.HOPPER) {
        if (ItemSpray.UUID_LIST.contains(event.getItem().getUniqueId())) {
            event.setCancelled(true);
        }
    }
}
项目:NBTEditor    文件:CustomItemListener.java   
@EventHandler
private void inventoryPickupItemItem(InventoryPickupItemEvent event) {
    CustomItem customItem = CustomItemManager.getCustomItem(event.getItem().getItemStack());
    if (verifyCustomItem(customItem, event.getItem().getWorld())) {
        customItem.onDropperPickup(event);
    }
}
项目:StorageSign    文件:StorageSignCore.java   
@EventHandler
public void onInventoryPickup(InventoryPickupItemEvent event) {
    if (event.isCancelled() || !config.getBoolean("auto-import")) return;

    InventoryHolder holder = event.getInventory().getHolder();
    if (holder instanceof BlockState) {
        Sign sign = null;
        StorageSign storageSign = null;
        boolean flag = false;
        for (int i=0; i<5; i++) {
            int[] x = {0, 0, 0,-1, 1};
            int[] y = {1, 0, 0, 0, 0};
            int[] z = {0,-1, 1, 0, 0};
            Block block = ((BlockState)holder).getBlock().getRelative(x[i], y[i], z[i]);
            if (i==0 && block.getType() == Material.SIGN_POST && isStorageSign(block)) {
                sign = (Sign) block.getState();
                storageSign = new StorageSign(sign);
                if (storageSign.isSimilar(event.getItem().getItemStack())) {
                    flag = true;
                    break;
                }
            } else if (i != 0 && block.getType() == Material.WALL_SIGN && block.getData() == i+1 && isStorageSign(block)) {
                sign = (Sign) block.getState();
                storageSign = new StorageSign(sign);
                if (storageSign.isSimilar(event.getItem().getItemStack())) {
                    flag = true;
                    break;
                }
            }
        }
        if (flag) importSign(sign, storageSign, event.getItem().getItemStack(), event.getInventory());
    }
}
项目:Craft-city    文件:TileEntityHopper.java   
public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) {
    boolean flag = false;

    if (entityitem == null) {
        return false;
    } else {
        // CraftBukkit start
        InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
        entityitem.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
        ItemStack itemstack1 = addItem(iinventory, itemstack, -1);

        if (itemstack1 != null && itemstack1.count != 0) {
            entityitem.setItemStack(itemstack1);
        } else {
            flag = true;
            entityitem.die();
        }

        return flag;
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onHopper(InventoryPickupItemEvent event) {
    event.setCancelled(true);
}
项目:Steel    文件:RollbackInventoryListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryPickupItem(InventoryPickupItemEvent event) {
    checkInventoryEvent(event.getInventory(), event);
}
项目:PickupMoney    文件:MainListener.java   
@EventHandler
public void onHopper(InventoryPickupItemEvent e){
    if(e.getInventory().getType().toString().equalsIgnoreCase("hopper") && e.getItem().getCustomName()!=null){
        e.setCancelled(true);
    }
}
项目:xEssentials-deprecated-bukkit    文件:RealisticWaterEvent.java   
@EventHandler
public void onItem(InventoryPickupItemEvent e) {
    if(e.getItem().hasMetadata("fakefish")) {
        e.setCancelled(true);
    }
}
项目:NBTEditor    文件:BatBomb.java   
@Override
public void onDropperPickup(InventoryPickupItemEvent event) {
    if (event.getItem().hasMetadata("is-active")) {
        event.setCancelled(true);
    }
}
项目:NBTEditor    文件:CustomItem.java   
public void onDropperPickup(InventoryPickupItemEvent event) { }