Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import org.tribot.api.Timing;
- import org.tribot.api.util.abc.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Login.STATE;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "fmtrick" }, category = "Money Making", name = "Trick's Clay Softener")
- public class ClaySoftener extends Script implements Painting {
- private State SCRIPT_STATE = getState();
- private ABCUtil abc = new ABCUtil();
- private int CLAY_ID = 434;
- private int WATER_JUG_ID = 1937;
- private static final long startTime = System.currentTimeMillis();
- public enum State {
- OPEN_BANK, WITHDRAW, NOT_AT_BANK, NO_SUPPLIES, USE_CLAY, LOGIN;
- }
- private State getState() {
- if(loggedIn()) {
- if(atBank()) {
- if(hasSuppliesInventory()) {
- return State.USE_CLAY;
- } else {
- if(bankOpen()) {
- if(hasSuppliesBank()) {
- return State.WITHDRAW;
- } else {
- return State.NO_SUPPLIES;
- }
- } else {
- return State.OPEN_BANK;
- }
- }
- } else {
- return State.NOT_AT_BANK;
- }
- } else {
- return State.LOGIN;
- }
- }
- private boolean loggedIn() {
- if(Login.getLoginState() == STATE.LOGINSCREEN || Login.getLoginState() == STATE.WELCOMESCREEN) {
- return false;
- } else {
- return true;
- }
- }
- private Font font = new Font("Verdana", Font.BOLD, 14);
- @Override
- public void onPaint(Graphics g) {
- long timeRan = System.currentTimeMillis() - startTime;
- g.setColor(new Color(157, 111, 74));
- g.setFont(font);
- g.drawString("Trick's Clay Softener", 7, 330);
- g.drawString("Runetime: " + Timing.msToString(timeRan), 7, 315);
- g.drawString("State: " + SCRIPT_STATE, 7, 300);
- }
- private boolean atBank() {
- return Banking.isInBank();
- }
- private void doAntiBan() {
- if (abc.shouldCheckTabs()) {
- abc.checkTabs();
- }
- if (abc.shouldCheckXP()) {
- abc.checkXP();
- }
- if (abc.shouldExamineEntity()) {
- abc.examineEntity();
- }
- if (abc.shouldMoveMouse()) {
- abc.moveMouse();
- }
- if (abc.shouldPickupMouse()) {
- abc.pickupMouse();
- }
- if (abc.shouldRightClick()) {
- abc.rightClick();
- }
- if (abc.shouldRotateCamera()) {
- abc.rotateCamera();
- }
- if (abc.shouldLeaveGame()) {
- abc.leaveGame();
- }
- }
- private boolean bankOpen() {
- return Banking.isBankScreenOpen();
- }
- private boolean openBank() {
- return Banking.openBank();
- }
- private boolean hasSuppliesBank() {
- RSItem[] clay = Banking.find(CLAY_ID);
- RSItem[] jug = Banking.find(WATER_JUG_ID);
- if (clay.length > 0) {
- if(jug.length > 0) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- private boolean hasSuppliesInventory() {
- RSItem[] clay = Inventory.find(CLAY_ID);
- RSItem[] jug = Inventory.find(WATER_JUG_ID);
- return(clay.length>0 && jug.length>0);
- }
- private void withdrawSupplies() {
- RSItem[] inventory = Inventory.getAll();
- if(inventory.length>0 || inventory!=null) {
- Banking.depositAll();
- }
- RSItem[] clay = Banking.find(CLAY_ID);
- if(clay!=null && clay.length>0) {
- Banking.withdraw(14, CLAY_ID);
- }
- RSItem[] waterJug = Banking.find(WATER_JUG_ID);
- if(waterJug!=null && waterJug.length>0) {
- Banking.withdraw(14, WATER_JUG_ID);
- }
- Banking.close();
- }
- private void usingClay() {
- while (true) {
- doAntiBan();
- RSItem[] clay = Inventory.find(CLAY_ID);
- int previousClay = clay.length;
- if(previousClay == 0) {
- break;
- } else {
- sleep(2500);
- RSItem[] clay2 = Inventory.find(CLAY_ID);
- int currentClay = clay2.length;
- if (currentClay == 0 || clay2 == null) {
- break;
- } else {
- if (currentClay == previousClay) {
- break;
- }
- }
- }
- }
- }
- private void useClay() {
- RSItem[] clay = Inventory.find(CLAY_ID);
- RSItem[] jug = Inventory.find(WATER_JUG_ID);
- if(clay!=null&&clay.length>0 && jug!=null&&jug.length>0) {
- clay[0].click("Use");
- jug[0].click("Use Clay -> Jug of water");
- }
- sleep(1000);
- RSInterface makeInterface = Interfaces.get(309);
- if(!makeInterface.isHidden()&&makeInterface!=null) {
- RSInterfaceChild makeButton = Interfaces.get(309, 2);
- if(makeButton!=null && !makeButton.isHidden()) {
- makeButton.click("Make All");
- }
- }
- usingClay();
- }
- private void endScript() {
- println("No supplies or not at a bank");
- Login.logout();
- }
- private void login() {
- Login.login();
- }
- @Override
- public void run() {
- loop: while(true) {
- SCRIPT_STATE = getState();
- switch (SCRIPT_STATE) {
- case NOT_AT_BANK:
- endScript();
- break loop;
- case NO_SUPPLIES:
- endScript();
- break loop;
- case OPEN_BANK:
- openBank();
- break;
- case WITHDRAW:
- withdrawSupplies();
- break;
- case USE_CLAY:
- useClay();
- break;
- case LOGIN:
- login();
- break;
- }
- sleep(150);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement