Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param id Id of the item you want to withdraw.
- */
- public void withdrawAllButOne(int id) {
- withdraw(id, 0, WITHDRAW_ALL_BUT_ONE);
- }
- /**
- * @param id Id of the item you want to withdraw.
- */
- public void withdrawAll(int id) {
- withdraw(id, 0, WITHDRAW_ALL);
- }
- /**
- * @param id Id of the item you want to withdraw.
- * @param amount Amount of the item you want to withdraw.
- */
- public void withdraw(int id, int amount) {
- withdraw(id, amount, WITHDRAW_X);
- }
- /**
- * @param id Id of the item you want to withdraw.
- * @param amount Amount of the item you want to withdraw.
- * @param type Withdraw type - withdraw-x, all, all-but-one
- */
- private void withdraw(int id, int amount, int type) {
- boolean doAction = false;
- Item item = bank.getItem(id);
- if (bank.contains(id) && item != null) {
- if (bank.getCount(id) >= amount) {
- IComponent visible = interfaces.getComponent(Bank.BANK_INTERFACE_ID, 3);
- if (visible != null) {
- if (visible.getBounds().contains(item.getBounds())) { //visible
- doAction = true;
- } else while (!visible.getBounds().contains(item.getBounds())) {
- item = bank.getItem(id);
- int scroll;
- if (item.getCenter().y < visible.getCenter().y) { //scroll up
- scroll = Bank.BANK_SCROLLBAR_UP;
- } else scroll = Bank.BANK_SCROLLBAR_DOWN;
- IComponent button = interfaces.getComponent(Bank.BANK_INTERFACE_ID, Bank.BANK_SCROLLBAR);
- if (button != null) {
- button.getChildren()[scroll].doClick();
- } else return;
- }
- doAction = true;
- }
- }
- }
- if (doAction) {
- Rectangle r = item.getBounds();
- mouse.moveMouse(new Point(random(r.x + 2, r.x + r.width - 2), random(r.y + 2, r.y + r.height - 2)));
- String action = "Withdraw-" + amount + " ";
- if (type == WITHDRAW_ALL) {
- action = "Withdraw-All";
- } else if (type == WITHDRAW_ALL_BUT_ONE) {
- action = "Withdraw-All but one";
- }
- if (menu.contains(action)) {
- menu.atMenu(action);
- } else { //withdraw X
- menu.atMenu("Withdraw-X");
- sleep(random(1000, 2000));
- keyboard.writeText(Integer.toString(amount), true);
- }
- }
- }
Add Comment
Please, Sign In to add comment