- Thread Author
- #1
Just like the title says the below code sometimes seems to get stuck and just repeatedly click the bank search button instead of deposit all:
Code:
@Override
public void execute() {
if (useRanged) {
if (Inventory.contains("Iron arrow")) {
Inventory.getItems("Iron arrow").first().click();
}
}
if (!Bank.isOpen() && !Inventory.contains("Iron arrow")) {
Bank.open();
}
if (Bank.isOpen()) {
// deposit loot
for (SpriteItem item : Inventory.getItems().asList()) {
if (!requiredItems().keySet().contains(item.getDefinition().getName())) {
Bank.depositInventory();
}
}
//withdraw items
requiredItems().forEach((item, itemAmount) -> {
if (Inventory.getQuantity(item) != itemAmount) {
Bank.withdraw(item, itemAmount);
}
});
// deposit if items overdrawn
requiredItems().forEach((item, itemAmount) -> {
if (Inventory.getItems(item).size() == 0) {
return;
} else if (Inventory.getQuantity(item) != itemAmount) {
Bank.depositInventory();
}
});
}
if (Inventory.isFull()) {
Bank.close();
}
}