Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.Malii;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.awt.*;
- /**
- * Created by Damian on 4/26/2016.
- */
- @ScriptManifest(
- name = "Apple Baskets",
- author = "Malii",
- version = 1.0,
- info = "Makes Apple(5) baskets",
- logo = ""
- )
- public class AppleBaskets extends Script {
- private String applesName;
- private String basketsName;
- private String invent;
- private String empty;
- private long startTime;
- public enum State {
- DEPOSIT, WITHDRAW, BASKET, IDLE, LOGOUT,
- }
- @Override
- public void onStart() throws InterruptedException {
- if (this.getBank().isOpen())
- this.getBank().close();
- this.applesName = "Cooking apple";
- this.basketsName = "Basket";
- this.invent = "Apples(5)";
- this.log("Apple Basket " + this.getVersion() + " Started");
- {
- }
- }
- @Override
- public int onLoop() throws InterruptedException {
- State current = this.getState();
- this.log(current.toString());
- switch (current) {
- case DEPOSIT: // Self explanatory
- this.deposit();
- break;
- case WITHDRAW: // Self explanatory
- this.withdraw();
- break;
- case BASKET: // Creates Apple(5)
- this.basket();
- break;
- case IDLE:
- break;
- case LOGOUT:
- this.logoutTab.logOut();
- break;
- }
- return gRandom(350, 450);
- }
- @Override
- public void onExit() {
- this.log("Thank you for using Apple Baskets " + this.getVersion());
- this.log("Script Ended");
- }
- public boolean basket() throws InterruptedException { // Fills baskets with apples
- if (getInventory().interact("Fill", basketsName)) ;
- {
- sleep(350);
- }
- return false;
- }
- public void deposit() throws InterruptedException {
- if (this.openBank()) {
- this.getBank().depositAll();
- sleep(200);
- }
- }
- public void withdraw() throws InterruptedException {
- if (this.openBank()) {
- while (!this.getInventory().contains(applesName) || !this.getInventory().contains(basketsName)) {
- this.getBank().withdraw(basketsName, 4);
- this.getBank().withdrawAll(applesName);
- sleep(350);
- }
- this.closeBank();
- }
- }
- public boolean openBank() throws InterruptedException {
- if (!getBank().isOpen()) { //if bank is not open
- getBank().open(); //opens the nearest bank
- new ConditionalSleep(2400) { //2400ms
- @Override
- public boolean condition() throws InterruptedException {
- return getBank().isOpen(); //sleeps 2400ms or until the bank is open!
- }
- }.sleep();
- } else {
- return true;
- }
- return false;
- }
- public void closeBank() throws InterruptedException {
- if (this.getBank().isOpen()) {
- this.getBank().close();
- new ConditionalSleep(2030) {
- @Override
- public boolean condition() throws InterruptedException {
- return !getBank().isOpen(); //sleep 2030 ms (2 seconds)or until bank is closed!
- }
- }.sleep();
- }
- }
- public State logout() throws InterruptedException {
- if (!bank.contains(5377) || !bank.contains(1956)) {
- this.getLogoutTab().logOut();
- }
- return State.LOGOUT;
- }
- public State getState() {
- if (this.getInventory().contains(this.invent) && !this.getInventory().contains(this.basketsName)) {
- return State.DEPOSIT;
- } else if (!this.getInventory().contains(this.applesName) || !this.getInventory().contains(this.basketsName)) {
- return State.WITHDRAW;
- } else if (this.getInventory().contains(this.applesName) && this.getInventory().contains(this.basketsName)) {
- return State.BASKET;
- } else if (!bank.contains(5377) || !bank.contains(1956)) {
- return State.LOGOUT;
- }
- return State.IDLE;
- }
- @Override
- public void onPaint(Graphics2D g) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement