Examples of firstEmpty()


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

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

    }

    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

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

        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

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

        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

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

                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

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

    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

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

  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

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

                  removed++;
                }
                i++;
              }
             
              int firstEmpty = playerInv.firstEmpty();
              if (firstEmpty > 0) {
                playerInv.setItem(firstEmpty, team.getKind().getBlockHead());
              }
             
              if (removed > 1) {
View Full Code Here

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

      }

      if (leftover != 0) {
    inventory.remove(i);

    if (inventory.firstEmpty() == -1) {
        player.getWorld().dropItem(player.getLocation(), new ItemStack(item, leftover));
    } else {
        inventory.setItem(inventory.firstEmpty(), new ItemStack(item, leftover));
    }
View Full Code Here

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

    inventory.remove(i);

    if (inventory.firstEmpty() == -1) {
        player.getWorld().dropItem(player.getLocation(), new ItemStack(item, leftover));
    } else {
        inventory.setItem(inventory.firstEmpty(), new ItemStack(item, leftover));
    }

    counter = 0;
    break;
      } else {
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.