Beispiel #1
0
  /**
   * Deposits all the items excluding the specified IDs.
   *
   * @param ids Item IDs not to deposit.
   * @return Whether or not the deposit was successful.
   * @author Ampzz
   */
  public boolean depositAllExcept(int... ids) {

    if (!isOpen()) return false;

    Item[] allItems = botEnv.inventory.getItems();
    if (allItems.length == 0) return false;

    ArrayList<Item> possItems = new ArrayList<Item>();

    for (Item iItem : allItems) {
      boolean add = true;

      for (int id : ids) {
        if (iItem.getID() == id) add = false;
      }

      if (possItems.size() > 0 && add) {
        for (Item kItem : possItems) {
          if (kItem.getID() == iItem.getID()) add = false;
        }
      }

      if (add) possItems.add(iItem);
    }

    if (possItems.size() == 0) return true;

    for (Item jItem : possItems) {
      jItem.doAction("Deposit-all");
      sleep(300, 700);
    }

    return true;
  }
Beispiel #2
0
 /**
  * Checks how many of the specified item the bank contains.
  *
  * @param itemID ID of the item to count.
  * @return itemAmount Stack size of item in bank.
  */
 public int getCount(int itemID) {
   if (!isOpen()) return 0;
   for (Item item : getItems()) {
     if (item == null) continue;
     if (item.getID() == itemID) return item.getStackSize();
   }
   return 0;
 }
Beispiel #3
0
 /**
  * Gets the Item for a specified item ID.
  *
  * @param itemID Item ID to look for.
  * @return Object of type Item with the specified ID.
  */
 public Item getItem(int itemID) {
   if (!isOpen()) return null;
   for (Item item : getItems()) {
     if (item == null) {
       continue;
     }
     if (item.getID() == itemID) {
       return item;
     }
   }
   return null;
 }
Beispiel #4
0
 /**
  * Checks if the bank contains any of the given items identified by their IDs.
  *
  * @param IDs The item IDs to check for.
  * @return True if any of the specified items are found.
  */
 public boolean contains(int... IDs) {
   Item[] items = getItems();
   for (Item item : items) {
     if (item != null) {
       for (int ID : IDs) {
         if (item.getID() == ID) {
           return true;
         }
       }
     }
   }
   return false;
 }
Beispiel #5
0
 /**
  * Deposits all of the specified item in the inventory.
  *
  * @param itemID Name of item to be deposited.
  * @return Whether or not the items were deposited.
  */
 public boolean depositAll(int itemID) {
   if (!isOpen() || botEnv.inventory.getItems().length == 0) {
     return false;
   }
   int count = 0;
   for (Item it : botEnv.inventory.getItems()) {
     if (it.getID() == itemID) {
       count++;
       it.doAction("Deposit-all");
       sleep(100, 200);
     }
     if (botEnv.inventory.getCount(false, itemID) == 0) {
       break;
     }
   }
   return count != 0;
 }
Beispiel #6
0
 /**
  * Gets an item array of all the bank items.
  *
  * @return Array of bank items.
  */
 public Item[] getItems() {
   Interfaces interfaces = botEnv.interfaces;
   Interface inventoryInterface = interfaces.getInterface(BANK_INTERFACE_ID);
   if (inventoryInterface == null) {
     return new Item[0];
   }
   IComponent inventoryPane = inventoryInterface.getComponent(BANK_ITEM_PANE_ID);
   IComponent[] children = inventoryPane.getChildren();
   if (children == null || children.length == 0) {
     return new Item[0];
   }
   List<Item> items = new ArrayList<Item>();
   for (IComponent aChildren : children) {
     if (aChildren == null) {
       continue;
     }
     Item item = new Item(botEnv, aChildren);
     if (item.getID() == -1) {
       continue;
     }
     items.add(item);
   }
   return items.toArray(new Item[items.size()]);
 }