Examples of InventoryHolder


Examples of org.bukkit.inventory.InventoryHolder

        Block center = getBackBlock().getRelative(0, -1, 0);
        ItemStack tool = null;

        if (InventoryUtil.doesBlockHaveInventory(center.getRelative(0, 2, 0))) {
            InventoryHolder holder = (InventoryHolder) center.getRelative(0, 2, 0).getState();
            if (holder.getInventory().getItem(0) != null) {
                tool = holder.getInventory().getItem(0);
            }
        }

        boolean hasHadTrue;
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

        int x = b.getX();
        int y = b.getY() + 1;
        int z = b.getZ();
        Block bl = BukkitUtil.toSign(getSign()).getBlock().getWorld().getBlockAt(x, y, z);
        if (InventoryUtil.doesBlockHaveInventory(bl)) {
            InventoryHolder c = (InventoryHolder) bl.getState();
            for (int i = 0; i < c.getInventory().getSize(); i++) {
                ItemStack it = c.getInventory().getItem(i);
                if (ItemUtil.isStackValid(it)) {

                    if(((Factory)getFactory()).blacklist.contains(new ItemInfo(it)))
                        continue;
                    int amount = it.getAmount();
                    if (it.getAmount() < 64) {

                        int missing = 0;

                        for (int ii = 0; ii < c.getInventory().getSize(); ii++) {
                            if (ii == i)
                                continue;
                            ItemStack itt = c.getInventory().getItem(ii);
                            if (ItemUtil.isStackValid(itt) && ItemUtil.areItemsIdentical(it, itt) && it.getEnchantments().isEmpty() && !itt.getEnchantments().isEmpty() && !it.hasItemMeta() && !itt.hasItemMeta()) {

                                if (amount + itt.getAmount() <= 64) {
                                    amount += itt.getAmount();
                                } else {
                                    missing = amount + itt.getAmount() - 64;
                                    amount = 64;
                                }
                                c.getInventory().remove(itt);
                            }
                        }

                        if (amount != it.getAmount()) {

                            it.setAmount(amount);
                            c.getInventory().setItem(i, it);
                            break;
                        }
                        if(missing > 0) {

                            ItemStack miss = new ItemStack(it);
                            miss.setAmount(missing);
                            c.getInventory().addItem(miss);
                        }
                    }
                }
            }
        }
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

    @Override
    public void onPipeTransfer(PipePutEvent event) {

        Block crafter = getBackBlock().getRelative(0, 1, 0);
        if (crafter.getType() == Material.DISPENSER || crafter.getType() == Material.DROPPER) {
            InventoryHolder disp = (InventoryHolder) crafter.getState();

            boolean delete = true;
            List<ItemStack> newItems = new ArrayList<ItemStack>();
            newItems.addAll(event.getItems());
            for (ItemStack ite : event.getItems()) {
                if (!ItemUtil.isStackValid(ite)) continue;
                int iteind = newItems.indexOf(ite);
                int newAmount = ite.getAmount();
                for (int i = 0; i < ite.getAmount(); i++) {
                    ItemStack it = ItemUtil.getSmallestStackOfType(disp.getInventory().getContents(), ite);
                    if (!ItemUtil.isStackValid(it) || !ItemUtil.areItemsIdentical(ite, it)) continue;
                    if (it.getAmount() < 64) {
                        it.setAmount(it.getAmount() + 1);
                        newAmount -= 1;
                    } else {
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

        if(chip.getInput(0)) {

            int amount = 0;

            if(InventoryUtil.doesBlockHaveInventory(getBackBlock().getRelative(0, 1, 0))) {
                InventoryHolder chest = (InventoryHolder) getBackBlock().getRelative(0, 1, 0).getState();
                for(ItemStack stack : chest.getInventory().getContents()) {
                    if(!ItemUtil.isStackValid(stack)) continue;
                    if(item == null || ItemUtil.areItemsIdentical(stack, item)) {
                        amount += stack.getAmount();
                    }
                }
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

    public boolean sense() {

        if (InventoryUtil.doesBlockHaveInventory(offset)) {

            InventoryHolder inv = (InventoryHolder) offset.getState();
            int amount = 0;
            if(slot < 0 || slot > inv.getInventory().getContents().length) {
                for(ItemStack cont : inv.getInventory().getContents())
                    if(ItemUtil.areItemsIdentical(cont, item)) {
                        if(checkAmount) {
                            amount += cont.getAmount();
                            if(amount >= item.getAmount()) {
                                return true;
                            }
                        } else {
                            return true;
                        }
                    }
            }
            else
                return ItemUtil.areItemsIdentical(item, inv.getInventory().getItem(slot)) && (!checkAmount || inv.getInventory().getItem(slot).getAmount() >= item.getAmount());
        }

        return false;
    }
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

        if(lastEntity != null)
            lastEntity.clear();
        else
            lastEntity = new HashMap<EntityType, Entity>();
        InventoryHolder inv = null;

        if(InventoryUtil.doesBlockHaveInventory(chest))
            inv = (InventoryHolder) chest.getState();

        if(inv == null)
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

            Bukkit.getPluginManager().callEvent(event);

            if(!event.isValid())
                return false;

            InventoryHolder c = (InventoryHolder) offset.getBlock().getState();
            for(ItemStack stack : event.getItems())
                if (c.getInventory().addItem(stack).isEmpty()) {
                    if(c instanceof BlockState)
                        ((BlockState) c).update();
                    return true;
                }
        }
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

    if (inventory == null) return null;
   
    Inventory ret = null;
   
    int size = inventory.getSize();
    InventoryHolder holder = inventory.getHolder();
    String title = inventory.getTitle();
   
    if (inventory instanceof PlayerInventory)
    {
      PlayerInventory pret = createPlayerInventory();
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

   * @param player player to check
   * @param block container to store
   */
  public void checkInventoryOpen(Player player, Block block) {
    if (!(block.getState() instanceof InventoryHolder)) return;
    InventoryHolder container = (InventoryHolder) block.getState();
    accessList.add(new ContainerAccess(container, player, InventoryUtil.compressInventory(InventoryUtil.getContainerContents(container)), block.getLocation()));
  }
View Full Code Here

Examples of org.bukkit.inventory.InventoryHolder

      if (event.getClickedBlock().getState() instanceof InventoryHolder
        && event.getAction() == Action.RIGHT_CLICK_BLOCK && match.getCurrentState().inProgress()
        && !event.getPlayer().isSneaking())
      {
        InventoryHolder invh = (InventoryHolder) event.getClickedBlock().getState();
        Inventory inv = invh.getInventory(), newinv;

        if (inv instanceof DoubleChestInventory)
          newinv = Bukkit.getServer().createInventory(player, 54, "Large Chest");
        else newinv = Bukkit.getServer().createInventory(player, inv.getType());
        newinv.setContents(inv.getContents());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.