Package org.bukkit.inventory

Examples of org.bukkit.inventory.Inventory.firstEmpty()


    }

    private void giveBook(Player player, ItemStack book) {
        Inventory inv = player.getInventory();
        int emptySpot = inv.firstEmpty();
        if (emptySpot != -1)
            player.getInventory().addItem(book);
        else {
            player.getWorld().dropItem(player.getLocation(), book);
            dB.log("Player's inventory is full, dropped book.");
View Full Code Here


    }

    private void equipBook (Player player, ItemStack book) {
        ItemStack currItem = player.getItemInHand();
        Inventory inv = player.getInventory();
        int emptySpot = inv.firstEmpty();

        // if player isn't holding anything
        if (currItem == null || currItem.getType() == Material.AIR) {
            player.setItemInHand(book);
            return;
View Full Code Here

        if (currItem == null || currItem.getType() == Material.AIR) {
            player.setItemInHand(book);
            return;
        }
        // drop it if inventory has no empty slots
        emptySpot = inv.firstEmpty();
        dB.log("emptySpot: " + emptySpot);

        if (emptySpot == -1) {
            player.getWorld().dropItem(player.getLocation(), book);
            dB.log("Player's inventory is full, dropped book.");
View Full Code Here

        ItemStack handitem = player.getItemInHand();
        Inventory inv = player.getInventory();
       
        if (!handitem.getType().equals(item)) {
            if (!handitem.getType().equals(Material.AIR)) {
                if(inv.firstEmpty() == -1) {
                    player.sendMessage(ChatColor.RED + "No space in your inventory");
                    return false;
                }
                   
                inv.setItem(inv.firstEmpty(), handitem);
View Full Code Here

                if(inv.firstEmpty() == -1) {
                    player.sendMessage(ChatColor.RED + "No space in your inventory");
                    return false;
                }
                   
                inv.setItem(inv.firstEmpty(), handitem);
            }
       
            if (inv.contains(item)) {
                Integer slotId = inv.first(item);
                ItemStack stack = inv.getItem(slotId);
View Full Code Here

    session.setUsingTool(true);
    ItemStack stack = BlockUtil.itemStringToStack(Config.ToolBlock, 1);

    //If player doesn't have a tool, give them one if enabled in config
    if (!inv.contains(stack) && Config.GiveTool) {
      int first = inv.firstEmpty();
      if (first == -1)
        player.getWorld().dropItem(player.getLocation(), stack);
      else inv.setItem(first, stack);
    }
View Full Code Here

  public static boolean hasFreeSlot(Collection<Chest> chest) {
    boolean result = false;

    for (Chest i : chest) {
      Inventory inventory = i.getInventory();
      if (inventory.firstEmpty() >= 0) {
        result = true;
        break;
      }
    }
    return result;
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.