Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.firemaker;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- public class Bank {
- private Main main;
- private ABCUtil abc = new ABCUtil();
- public Bank(Main main) {
- setMain(main);
- }
- public boolean performedBankTask() {
- int logId = getMain().getLogType().getLogId();
- boolean tinderbox = Inventory.getCount(Constants.TINDERBOX) > 0;;
- boolean logs = Inventory.getCount(logId) > 0;
- if(Banking.isBankScreenOpen())
- Banking.depositAllExcept(Constants.TINDERBOX, getMain().getLogId());
- if(!tinderbox) {
- if(Inventory.getCount(Constants.TINDERBOX) <= 0) {
- if(withdrawItem(Constants.TINDERBOX, 1)) {
- tinderbox = Inventory.getCount(Constants.TINDERBOX) > 0;
- }
- }
- }
- if(!logs) {
- if(withdrawItem(logId, 28 - Inventory.getAll().length)) {
- logs = Inventory.getCount(logId) > 0;
- }
- }
- if(tinderbox && logs) {
- return true;
- }
- return false;
- }
- public boolean openBank() {
- if(Banking.isBankScreenOpen()) {
- return true;
- }
- if(getMain().usingGrandExchange()) {
- RSObject[] geBank = Objects.findNearest(64, "Grand Exchange booth");
- if(geBank != null && geBank.length > 0) {
- for(int i = 0; i < geBank.length; i++) {
- String[] actions = geBank[i].getDefinition().getActions();
- for(String a : actions) {
- if(a.equals("Bank")) {
- if(geBank[i].click("Bank")) {
- General.sleep(abc.DELAY_TRACKER.NEW_OBJECT.next());
- abc.DELAY_TRACKER.NEW_OBJECT.reset();
- return isBankScreenOpen(2000);
- }
- }
- }
- }
- }
- return false;
- }
- Banking.openBank();
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- return isBankScreenOpen(2000);
- }
- public boolean withdrawItem(int itemId, int withdrawAmount) {
- if(openBank()) {
- getMain().sleep(250, 500);
- RSItem[] item = Banking.find(itemId);
- if(item != null && item.length > 0) {
- Banking.withdraw(withdrawAmount, itemId);
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(isItemWithdrawn(2000, itemId, Inventory.getCount(itemId))) {
- return true;
- }
- } else {
- getMain().println("Can't find: " + itemId);
- getMain().setEndScript(true);
- return false;
- }
- }
- return false;
- }
- public boolean isBankScreenOpen(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if (Banking.isBankScreenOpen()) {
- return true;
- }
- getMain().sleep(50, 150);
- }
- return false;
- }
- private boolean isItemWithdrawn(int i, int id, int amt) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if (Inventory.getCount(id) > amt) {
- return true;
- }
- getMain().sleep(50, 150);
- }
- return false;
- }
- public Main getMain() {
- return main;
- }
- public void setMain(Main main) {
- this.main = main;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement