Package org.bukkit.inventory

Examples of org.bukkit.inventory.Inventory


        }
    }

    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
    public void onInventoryDragEvent(InventoryDragEvent event) {
        Inventory inventory = event.getInventory();

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

        InventoryHolder holder = inventory.getHolder();

        if (!(holder instanceof BrewingStand)) {
            return;
        }
View Full Code Here


        }
    }

    @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;
        }
View Full Code Here

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerInteract(PlayerInteractEvent event) {
        final Player player = event.getPlayer();
        if (!this.plugin.chestFakeInUse(player.getName()) && !player.isSneaking() && (event.getAction() == Action.RIGHT_CLICK_BLOCK) && this.plugin.getManager().isVanished(event.getPlayer()) && VanishPerms.canReadChestsSilently(event.getPlayer())) {
            final Block block = event.getClickedBlock();
            Inventory inventory = null;
            final BlockState blockState = block.getState();
            boolean fake = false;
            switch (block.getType()) {
                case TRAPPED_CHEST:
                case CHEST:
                    final Chest chest = (Chest) blockState;
                    inventory = this.plugin.getServer().createInventory(player, chest.getInventory().getSize());
                    inventory.setContents(chest.getInventory().getContents());
                    fake = true;
                    break;
                case ENDER_CHEST:
                    if (this.plugin.getServer().getPluginManager().isPluginEnabled("EnderChestPlus") && VanishPerms.canNotInteract(player)) {
                        event.setCancelled(true);
View Full Code Here

        int x = b.getX();
        int y = b.getY() + 1;
        int z = b.getZ();
        Block bl = BukkitUtil.toSign(getSign()).getBlock().getWorld().getBlockAt(x, y, z);
        ItemStack stack = null;
        Inventory inv = null;
        if (bl.getType() == Material.CHEST) {
            Chest c = (Chest) bl.getState();
            for (ItemStack it : c.getInventory().getContents()) {
                if (ItemUtil.isStackValid(it)) {
                    if(item == null || ItemUtil.areItemsIdentical(it, item)) {
View Full Code Here

                        return;
                }
            }
        } else {
            for (Chest c : RailUtil.getNearbyChests(blocks.base)) {
                Inventory inv = c.getInventory();

                CartType type = CartType.fromString(blocks.getSign().getLine(0));

                // go
                if (cart == null) {
View Full Code Here

        } else if (parts[0].equalsIgnoreCase("Mob")) {
            String testMob = parts[1];
            return test.getType().toString().equalsIgnoreCase(testMob);
        } else if (minecart instanceof StorageMinecart && parts[0].equalsIgnoreCase("Ctns")) {
            StorageMinecart storageCart = (StorageMinecart) minecart;
            Inventory storageInventory = storageCart.getInventory();

            if (parts.length == 4) {
                try {
                    int item = Integer.parseInt(parts[1]);
                    short durability = Short.parseShort(parts[2]);
                    int index = Math.min(Math.max(Integer.parseInt(parts[3]) - 1, 0),
                            storageInventory.getContents().length - 1);
                    ItemStack indexed = storageInventory.getContents()[index];
                    if (indexed != null && indexed.equals(new ItemStack(item, 1, durability))) return true;
                } catch (NumberFormatException ignored) {
                }
            } else if (parts.length == 3) {
                try {
                    int item = Integer.parseInt(parts[1]);
                    short durability = Short.parseShort(parts[2]);
                    if (storageInventory.contains(new ItemStack(item, 1, durability))) return true;
                } catch (NumberFormatException ignored) {
                }
            } else if (parts[1].equalsIgnoreCase("!")) {
                for (ItemStack item : storageInventory.getContents()) {
                    if (item != null) {
                        return false;
                    }
                }
                return true;
            } else {
                try {
                    int item = Integer.parseInt(parts[1]);
                    if (storageInventory.contains(item)) return true;
                } catch (NumberFormatException ignored) {
                }
            }
        }
        if (line.startsWith("#")) {
View Full Code Here

        state.setOutput(0, doStuff(true, true));
    }

    public boolean craft(InventoryHolder disp) {

        Inventory inv = disp.getInventory();
        for (ItemStack it : inv.getContents()) {
            if (!ItemUtil.isStackValid(it))
                continue;
            if (it.getAmount() < 2) return false;
        }

        if (recipe == null) {

            Iterator<Recipe> recipes = Bukkit.recipeIterator();
            try {
                while (recipes.hasNext()) {
                    Recipe temprecipe = recipes.next();
                    if (isValidRecipe(temprecipe, inv)) {
                        recipe = temprecipe;
                    }
                }
            } catch (Exception e) {
                BukkitUtil.printStacktrace(e);
                disp.getInventory().setContents(inv.getContents());
            }
        }

        if (recipe == null) return false;
View Full Code Here

    }

    private String getBookCode(Block chestBlock) throws CodeNotFoundException {

        Chest c = (Chest) chestBlock.getState();
        Inventory i = c.getBlockInventory();
        ItemStack book = null;
        for (ItemStack s : i.getContents()) {
            if (s != null && s.getAmount() > 0 && (s.getType() == Material.BOOK_AND_QUILL || s.getType() == Material.WRITTEN_BOOK)) {
                if (book != null) throw new CodeNotFoundException("More than one written book found in chest!!");
                book = s;
            }
        }
View Full Code Here

        player = mock(Player.class);

        when(player.getLocation()).thenReturn(location);
        when(event.getExited()).thenReturn(player);

        Inventory inv = mock(PlayerInventory.class);

        when(inv.addItem(Mockito.<ItemStack[]>any())).thenReturn(new HashMap<Integer, ItemStack>(){{put(0,null);}});

        when(((Player) player).getInventory()).thenReturn((PlayerInventory) inv);

        rem.new BoatRemover(player, boat).run();

        when(inv.addItem(Mockito.<ItemStack[]>any())).thenReturn(new HashMap<Integer, ItemStack>());
        rem.new BoatRemover(player, boat).run();

        verify(boat, Mockito.times(4)).remove();
        verify(world, Mockito.times(3)).dropItemNaturally(Mockito.eq(location), Mockito.<ItemStack>any());
    }
View Full Code Here

  }


  public void showMenu(Player p){
    GameManager.getInstance().openKitMenu(p);
    Inventory i = Bukkit.getServer().createInventory(p, 90, ChatColor.RED+""+ChatColor.BOLD+"Kit Selection");

    int a = 0;
    int b = 0;


    ArrayList<Kit>kits = GameManager.getInstance().getKits(p);
    SurvivalGames.debug(kits+"");
    if(kits == null || kits.size() == 0 || !SettingsManager.getInstance().getKits().getBoolean("enabled")){
      GameManager.getInstance().leaveKitMenu(p);
      return;
    }

    for(Kit k: kits){
      ItemStack i1 = k.getIcon();
      ItemMeta im = i1.getItemMeta();

      debug(k.getName()+" "+i1+" "+im);

      im.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+k.getName());
      i1.setItemMeta(im);
      i.setItem((9 * a) + b, i1);
      a = 2;

      for(ItemStack s2:k.getContents()){
        if(s2 != null){
          i.setItem((9 * a) + b, s2);
          a++;
        }
      }

      a = 0;
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.Inventory

Copyright © 2018 www.massapicom. 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.