The OSBot methods are slow and unreliable so I wrote my own. Thanks to @TheScrub for cluing me in on what interface in the bank had the items!
public boolean bankContains(int item) {
for (Item i : sI.client.getInterface(12).getItems(6)) {
if (i != null && i.getId() == item) {
return true;
}
}
return false;
}
public boolean bankContains(String item) {
for (Item i : sI.client.getInterface(12).getItems(6)) {
if (i != null && i.getName().equalsIgnoreCase(item.toLowerCase())) {
return true;
}
}
return false;
}
public boolean rightClickBankItem(int item) throws InterruptedException {
if (!bankContains(item)) {
return false;
}
int slot = sI.client.getBank().getSlotForId(item);
if (!sI.client.getBank().isSlotVisible(slot)) {
sI.client.getBank().scrollToSlot(slot);
}
Rectangle rect = sI.client.getBank().getAbsoluteSlotPosition(slot);
sI.client.moveMouseTo(new RectangleDestination((int) rect.getX(), (int) rect.getY(), (int) rect.getWidth(), (int) rect.getHeight()), false, true, true);
return sI.client.isMenuOpen();
}
public boolean rightClickBankItem(String item) throws InterruptedException {
if (!bankContains(item)) {
return false;
}
int slot = sI.client.getBank().getSlotForId(sI.client.getBank().getItemForName(item).getId());
if (!sI.client.getBank().isSlotVisible(slot)) {
sI.client.getBank().scrollToSlot(slot);
}
Rectangle rect = sI.client.getBank().getAbsoluteSlotPosition(slot);
sI.client.moveMouseTo(new RectangleDestination((int) rect.getX(), (int) rect.getY(), (int) rect.getWidth(), (int) rect.getHeight()), false, true, true);
return sI.client.isMenuOpen();
}
public boolean selectOpenMenuOption(String option) throws InterruptedException {
if (sI.client.isMenuOpen()) {
List<Option> options = sI.client.getMenu();
for (int i= 0; i < options.size(); i++) {
if (options.get(i).action.equalsIgnoreCase(option.toLowerCase())) {
return sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
}
}
}
return false;
}
public boolean withdraw(int id, int amount) throws InterruptedException {
if (!bankContains(id)) {
return false;
}
if (rightClickBankItem(id)) {
if (sI.client.isMenuOpen()) {
List<Option> options = sI.client.getMenu();
for (int i= 0; i < options.size(); i++) {
if (options.get(i).action.equalsIgnoreCase("withdraw-" + amount)) {
return sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
}
else if (options.get(i).action.equalsIgnoreCase("withdraw-x")) {
sI.client.moveMouseTo(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+21+i*14, sI.client.getMenuWidth(), 10), false, true, false);
sI.sleep(MethodProvider.random(615, 963));
sI.client.typeString(Integer.toString(amount));
return true;
}
}
}
}
return false;
}
public boolean withdraw(String name, int amount) throws InterruptedException {
if (!bankContains(name)) {
return false;
}
if (rightClickBankItem(name)) {
if (sI.client.isMenuOpen()) {
List<Option> options = sI.client.getMenu();
for (int i= 0; i < options.size(); i++) {
if (options.get(i).action.equalsIgnoreCase("withdraw-" + amount)) {
return sI.client.moveMouseTo(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+21+i*14, sI.client.getMenuWidth(), 10), false, true, false);
}
else if (options.get(i).action.equalsIgnoreCase("withdraw-x")) {
sI.client.moveMouse(new RectangleDestination(sI.client.getMenuX(), sI.client.getMenuY()+19+(i*15), sI.client.getMenuWidth(), 15), false);
sI.sleep(MethodProvider.random(615, 963));
sI.client.typeString(Integer.toString(amount));
return true;
}
}
}
}
return false;
}