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 java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.RenderingHints;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Scanner;
- import javax.imageio.ImageIO;
- import javax.swing.WindowConstants;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Login.STATE;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Options;
- import org.tribot.api2007.PathFinding;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Ending;
- import org.tribot.script.interfaces.MouseActions;
- import org.tribot.script.interfaces.Painting;
- import org.tribot.util.Util;
- @ScriptManifest(authors = ("Nate"), category = ("Money Making"), name = ("nCabbage Picker v1"))
- public class CabbagePicker extends Script implements Painting, MouseActions, Ending {
- private RSTile DEPOSIT_BOX_TILE = new RSTile(3045, 3235),
- depositBoxBackupTile = new RSTile(3047,3236),
- cabbageTileSF = new RSTile(3052,3282),
- cabbageTileEM = new RSTile(3051, 3507),
- cabbageBackupTileSF = new RSTile(3054,3292),
- cabbageBackupTileEM = new RSTile(3052,3509),
- edgeBank = new RSTile(3095, 3494),
- prePreCabbageTileEM = new RSTile(3075, 3514),
- preCabbageTileEM = new RSTile(3072,3520),
- preCabbageTileEM2 = new RSTile(3061,3518),
- cabbageTileR = new RSTile(2956,3255),
- cabbageBackupTileR = new RSTile(2950, 3255),
- cabbageTileSV = new RSTile(3227,3384),
- cabbageBackupTileSV = new RSTile(3225,3382),
- preCabbageTileSV1 = new RSTile(3212,3385),
- preCabbageTileSV2 = new RSTile(3251,3388),
- vEastBank1 = new RSTile(3253,3420),
- vEastBank2 = new RSTile(3250,3420),
- dBank1 = new RSTile(3092,3243),
- dBank2 = new RSTile(3094,3243),
- preCabbageTileDM1 = new RSTile(3110,3282),
- preCabbageTileDM2 = new RSTile(3109,3333),
- cabbageTileDM = new RSTile(3087,3360),
- cabbageBackupTileDM = new RSTile(3086,3360),
- dCenter = new RSTile(3110, 3294),
- preDCenter = new RSTile(3112, 3303);
- private final int DEPOSIT_BOX_ID = 26254,
- CABBAGE_GROUND_ID = 1161,
- CABBAGE_ID = 1965,
- DRAYNOR_CABBAGE_GROUND_ID = 11494,
- DRAYNOR_CABBAGE_ID = 1967;
- private int count, current, last, cabbagePrice = getPrice(CABBAGE_ID),
- sleepCheck = 0;
- private RSObject depositBox, cabbageGround;
- private boolean cabbageNearby, GUIcomplete = false, notConnected = false,
- justPicked = false, infoOpen = true, showInfo = true, running = true,
- invFull, justBanked, reset = false, paintEnabled = true;
- private final long startTime = Timing.currentTimeMillis();
- private String status = "Initializing", area;
- private Font regFont = new Font("Verdana", Font.BOLD, 14);
- private final Image img = getImage("http://i.imgur.com/pmXeqI1.png");
- private final RenderingHints aa = new
- RenderingHints(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- private File outputFile;
- private Scanner sc;
- private Rectangle whereToClick = new Rectangle(120, 340, 40, 20);
- @Override
- public void run() {
- runScriptInfo();
- runGUI();
- checkCabbagePrice();
- while (Login.getLoginState() != STATE.INGAME) {
- General.sleep(500);
- }
- General.useAntiBanCompliance(true);
- Mouse.setSpeed(General.random(150, 220));
- if (area != null)
- println("Location: " + area);
- if (Player.getPosition().getPlane() != 0)
- println("Please start the bot when you are on the base plane (no dungeons or up stairs) of runescape");
- else if (area != null && area.equals("South Falador"))
- while (running) {
- sleep(400);
- loopSF();
- }
- else if (area != null && area.equals("Edgeville Monastery"))
- while (running) {
- sleep(400);
- loopEM();
- }
- else if (area != null && area.equals("Rimmington"))
- while (running) {
- sleep(400);
- loopR();
- }
- else if (area != null && area.equals("South Varrock"))
- while (running) {
- sleep(400);
- loopSV();
- }
- else if (area != null && area.equals("Draynor Manor"))
- while (running) {
- sleep(400);
- loopDM();
- }
- else
- println("Error: No selected location could be found");
- }
- private void loopDM() {
- cabbageNearby = checkForCabbagesDM();
- if (Inventory.isFull()) {
- dBank();
- justPicked = false;
- justBanked = true;
- }
- else if (!cabbageNearby) {
- if (justPicked) {
- sleep(500);
- }
- else {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to cabbages";
- }
- else
- status = "Walking to cabbages";
- if (justBanked) {
- RSTile[] path1 = Walking.generateStraightPath(preCabbageTileDM1);
- Walking.walkPath(path1);
- sleep(3000);
- PathFinding.aStarWalk(dCenter);
- sleep(1000);
- }
- RSTile[] path2 = Walking.generateStraightPath(preCabbageTileDM2);
- Walking.walkPath(path2);
- sleep(3000);
- RSTile[] path3 = Walking.generateStraightPath(cabbageTileDM);
- Walking.walkPath(path3);
- while (Player.isMoving())
- sleep(50);
- }
- }
- else {
- pickCabbagesDM();
- }
- }
- private void pickCabbagesDM() {
- current = Inventory.getCount(DRAYNOR_CABBAGE_ID);
- last = current;
- invFull = Inventory.isFull();
- justBanked = false;
- while (!invFull) {
- if (reset){
- sleepCheck = 0;
- reset = false;
- println("Attemping to fix error");
- break;
- }
- RSObject[] cabbages = Objects.findNearest(10,DRAYNOR_CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null) {
- cabbageGround = cabbages[0];
- if (cabbageGround.isClickable()) {
- if (cabbageGround.click("Pick")) {
- status = "Picking Cabbages";
- while (current - last != 1) {
- sleep((long) (Math.random() * 100 + 100));
- if (sleepCheck > 40) {
- reset = true;
- println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
- break;
- }
- else
- reset = false;
- sleepCheck++;
- current = Inventory.getCount(DRAYNOR_CABBAGE_ID);
- }
- sleepCheck = 0;
- last = current;
- count++;
- justPicked = true;
- }
- }
- else {
- Walking.blindWalkTo(cabbageBackupTileDM);
- sleep(500);
- }
- }
- else if (justPicked) {
- status = "Waiting out spawn";
- sleep(500);
- }
- else {
- Walking.blindWalkTo(cabbageBackupTileDM);
- sleep(500);
- }
- sleep(100);
- invFull = Inventory.isFull();
- }
- }
- private boolean checkForCabbagesDM() {
- RSObject[] cabbages = Objects.find(15, DRAYNOR_CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null)
- return true;
- else
- return false;
- }
- private void dBank() {
- if (Banking.isInBank()) {
- status = "Banking";
- if (Banking.openBank()) {
- Banking.depositAll();
- Banking.close();
- }
- }
- else {
- if (justPicked) {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to bank";
- }
- else
- status = "Walking to bank";
- RSTile[] path1 = Walking.generateStraightPath(preCabbageTileDM2);
- Walking.walkPath(path1);
- sleep(3000);
- PathFinding.aStarWalk(preDCenter);
- sleep(500);
- PathFinding.aStarWalk(dCenter);
- sleep(1000);
- RSTile[] path2 = Walking.generateStraightPath(preCabbageTileDM1);
- Walking.walkPath(path2);
- sleep(1000);
- PathFinding.aStarWalk(dBank1);
- }
- PathFinding.aStarWalk(dBank1);
- status = "Moving to bank";
- sleep(2000);
- if (Banking.isInBank()) {
- status = "Banking";
- if (Banking.openBank()) {
- Banking.depositAll();
- Banking.close();
- }
- }
- else {
- status = "Heading to bank";
- Walking.blindWalkTo(dBank2);
- }
- }
- }
- private void loopSV() {
- cabbageNearby = checkForCabbagesSV();
- if (Inventory.isFull()) {
- vBank();
- justPicked = false;
- justBanked = true;
- }
- else if (!cabbageNearby) {
- if (justPicked) {
- sleep(500);
- }
- else {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to cabbages";
- }
- else
- status = "Walking to cabbages";
- if (justBanked)
- Walking.blindWalkTo(preCabbageTileSV2);
- RSTile[] path1 = Walking.generateStraightPath(preCabbageTileSV1);
- Walking.walkPath(path1);
- sleep(500);
- PathFinding.aStarWalk(cabbageBackupTileSV);
- while (Player.isMoving()) {
- sleep(50);
- }
- }
- }
- else {
- pickCabbagesSV();
- }
- }
- private boolean checkForCabbagesSV() {
- RSObject[] cabbages = Objects.find(10, CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null)
- return true;
- else
- return false;
- }
- private void pickCabbagesSV() {
- justBanked = false;
- current = Inventory.getCount(CABBAGE_ID);
- last = current;
- int decider;
- invFull = Inventory.isFull();
- while (!invFull) {
- if (reset){
- sleepCheck = 0;
- reset = false;
- println("Attemping to fix error");
- break;
- }
- RSObject[] cabbages = Objects.findNearest(10,CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null) {
- cabbageGround = cabbages[0];
- if (cabbageGround.isClickable()) {
- if (cabbageGround.click("Pick")) {
- status = "Picking Cabbages";
- while (current - last != 1) {
- sleep((long) (Math.random() * 100 + 100));
- if (sleepCheck > 40) {
- reset = true;
- println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
- break;
- }
- else
- reset = false;
- sleepCheck++;
- current = Inventory.getCount(CABBAGE_ID);
- }
- sleepCheck = 0;
- last = current;
- count++;
- justPicked = true;
- }
- }
- else {
- decider = (int) (Math.random() * 100);
- if (decider >= 50)
- Walking.blindWalkTo(cabbageBackupTileSV);
- else
- Walking.blindWalkTo(cabbageTileSV);
- sleep(500);
- }
- }
- else if (justPicked) {
- status = "Waiting out spawn";
- sleep(500);
- }
- else {
- Walking.blindWalkTo(preCabbageTileSV1);
- decider = (int) (Math.random() * 100);
- if (decider >= 50)
- Walking.blindWalkTo(cabbageBackupTileSV);
- else
- Walking.blindWalkTo(cabbageTileSV);
- sleep(1500);
- }
- sleep(100);
- invFull = Inventory.isFull();
- }
- }
- private void vBank() {
- if (Banking.isInBank()) {
- if (Banking.openBank())
- Banking.depositAll();
- }
- else {
- if (justPicked) {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to bank";
- }
- else
- status = "Walking to bank";
- Walking.blindWalkTo(preCabbageTileSV1);
- sleep(200);
- Walking.blindWalkTo(preCabbageTileSV2);
- sleep(300);
- }
- RSTile[] path1 = Walking.generateStraightPath(vEastBank1);
- Walking.walkPath(path1);
- status = "Heading to bank";
- if (Banking.isInBank()) {
- if (Banking.openBank())
- Banking.depositAll();
- }
- else
- Walking.blindWalkTo(vEastBank2);
- }
- while (Player.isMoving())
- sleep(50);
- }
- @SuppressWarnings("deprecation")
- private void loopR() {
- cabbageNearby = checkForCabbagesR();
- if (Inventory.isFull()) {
- useDepositBox();
- justPicked = false;
- }
- else if (!cabbageNearby) {
- if (justPicked) {
- sleep(500);
- }
- else {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to cabbages";
- }
- else
- status = "Walking to cabbages";
- RSTile[] pathR = Walking.generateStraightPath(cabbageTileR);
- pathR = Walking.randomizePath(pathR, 3, 3);
- Walking.walkPath(pathR);
- while (Player.isMoving() || PathFinding.distanceTo(cabbageTileR, false) > 3)
- sleep(100);
- }
- }
- else {
- pickCabbagesR();
- }
- }
- private void pickCabbagesR() {
- current = Inventory.getCount(CABBAGE_ID);
- last = current;
- int decider;
- invFull = Inventory.isFull();
- while (!invFull) {
- if (reset){
- sleepCheck = 0;
- reset = false;
- println("Fixing error");
- break;
- }
- RSObject[] cabbages = Objects.findNearest(15,CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null) {
- cabbageGround = cabbages[0];
- if (cabbageGround.isClickable()) {
- if (cabbageGround.click("Pick")) {
- status = "Picking Cabbages";
- while (current - last != 1) {
- sleep((long) (Math.random() * 100 + 100));
- if (sleepCheck > 40) {
- reset = true;
- println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
- break;
- }
- else
- reset = false;
- sleepCheck++;
- current = Inventory.getCount(CABBAGE_ID);
- }
- last = current;
- count++;
- justPicked = true;
- sleepCheck = 0;
- }
- else
- PathFinding.aStarWalk(cabbageBackupTileR);
- }
- else {
- decider = (int) (Math.random() * 100);
- if (decider >= 50)
- Walking.blindWalkTo(cabbageBackupTileR);
- else
- PathFinding.aStarWalk(cabbageTileR);
- sleep(500);
- }
- }
- else if (justPicked)
- sleep(500);
- else {
- Walking.blindWalkTo(preCabbageTileEM);
- decider = (int) (Math.random() * 100);
- if (decider >= 50)
- Walking.blindWalkTo(cabbageBackupTileR);
- else
- Walking.blindWalkTo(cabbageTileR);
- sleep(500);
- }
- sleep(100);
- invFull = Inventory.isFull();
- }
- }
- private boolean checkForCabbagesR() {
- RSObject[] cabbages = Objects.findNearest(10, CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null)
- if (cabbages[0].isClickable())
- return true;
- else
- return false;
- else
- return false;
- }
- @SuppressWarnings("deprecation")
- private void loopEM() {
- cabbageNearby = checkForCabbagesEM();
- if (Inventory.isFull()) {
- emBank();
- }
- else if (!cabbageNearby) {
- if (justPicked) {
- sleep(500);
- }
- else {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to cabbages";
- }
- else
- status = "Walking to cabbages";
- Walking.blindWalkTo(prePreCabbageTileEM);
- while (PathFinding.distanceTo(prePreCabbageTileEM, false) > 5)
- sleep(100);
- PathFinding.aStarWalk(preCabbageTileEM2);
- Walking.walkPath(Walking.generateStraightPath(cabbageTileEM));
- while (Player.isMoving())
- sleep(100);
- }
- }
- else {
- pickCabbagesEM();
- }
- }
- private void pickCabbagesEM() {
- current = Inventory.getCount(CABBAGE_ID);
- last = current;
- int decider;
- invFull = Inventory.isFull();
- while (!invFull) {
- if (reset){
- sleepCheck = 0;
- reset = false;
- println("Fixing error");
- break;
- }
- RSObject[] cabbages = Objects.findNearest(50,CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null) {
- cabbageGround = cabbages[0];
- if (cabbageGround.isClickable()) {
- if (cabbageGround.click("Pick")) {
- status = "Picking Cabbages";
- while (current - last != 1) {
- sleep((long) (Math.random() * 100 + 100));
- if (sleepCheck > 40) {
- reset = true;
- println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
- break;
- }
- else
- reset = false;
- current = Inventory.getCount(CABBAGE_ID);
- sleepCheck++;
- }
- last = current;
- count++;
- justPicked = true;
- sleepCheck = 0;
- }
- }
- else if (justPicked) {
- status = "Waiting out spawn";
- sleep(500);
- }
- else {
- decider = (int) (Math.random() * 100);
- if (decider >= 50)
- Walking.blindWalkTo(cabbageBackupTileEM);
- else
- Walking.blindWalkTo(cabbageTileEM);
- sleep(500);
- }
- }
- else if (justPicked) {
- status = "Waiting out spawn";
- sleep(500);
- }
- else {
- Walking.blindWalkTo(preCabbageTileEM);
- decider = (int) (Math.random() * 100);
- if (decider >= 50)
- Walking.blindWalkTo(cabbageBackupTileEM);
- else
- Walking.blindWalkTo(cabbageTileEM);
- sleep(500);
- }
- sleep(100);
- invFull = Inventory.isFull();
- }
- }
- private boolean checkForCabbagesEM() {
- RSObject[] cabbages = Objects.find(10, CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null)
- return true;
- else
- return false;
- }
- @SuppressWarnings("deprecation")
- private void emBank() {
- if (Banking.isInBank()) {
- justPicked = false;
- status = "Banking";
- if (Banking.openBank())
- if (Banking.depositAll() > 0)
- Banking.close();;
- }
- else {
- if (justPicked || cabbageNearby) {
- justPicked = false;
- if (Game.getRunEnergy() >= 20)
- if (Options.setRunOn(true))
- status = "Running to bank";
- status = "Walking to bank";
- Walking.blindWalkTo(preCabbageTileEM2);
- Walking.blindWalkTo(preCabbageTileEM);
- while (PathFinding.distanceTo(preCabbageTileEM, false) > 4)
- sleep(50);
- }
- if (Game.getRunEnergy() >= 20)
- if (Options.setRunOn(true))
- status = "Running to bank";
- status = "Walking to bank";
- RSTile[] path2 = Walking.generateStraightPath(edgeBank);
- path2 = Walking.randomizePath(path2, 1, 1);
- Walking.walkPath(path2);
- sleep(400);
- if (Banking.isInBank()) {
- if (Banking.openBank())
- if (Banking.depositAll() > 0)
- Banking.close();
- }
- }
- }
- private void loopSF() {
- cabbageNearby = checkForCabbagesSF();
- if (Inventory.isFull()) {
- useDepositBox();
- }
- else if (!cabbageNearby) {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to cabbages";
- }
- else
- status = "Walking to cabbages";
- RSTile[] path = Walking.generateStraightPath(cabbageTileSF);
- path = Walking.randomizePath(path, 4, 4);
- Walking.walkPath(path);
- sleep(500);
- }
- else {
- pickCabbagesSF();
- }
- }
- private void pickCabbagesSF() {
- current = Inventory.getCount(CABBAGE_ID);
- last = current;
- invFull = Inventory.isFull();
- while (!invFull) {
- if (reset){
- sleepCheck = 0;
- reset = false;
- println("Fixing error");
- break;
- }
- RSObject[] cabbages = Objects.findNearest(25,CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null) {
- cabbageGround = cabbages[0];
- if (cabbageGround.isClickable()) {
- if (cabbageGround.click("Pick")) {
- status = "Picking Cabbages";
- while (current - last != 1) {
- sleep((long) (Math.random() * 100 + 100));
- if (sleepCheck > 40) {
- reset = true;
- println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
- break;
- }
- else
- reset = false;
- sleepCheck++;
- current = Inventory.getCount(CABBAGE_ID);
- }
- sleepCheck = 0;
- last = current;
- count++;
- }
- }
- else {
- PathFinding.aStarWalk(cabbageBackupTileSF);
- sleep(500);
- }
- }
- else {
- PathFinding.aStarWalk(cabbageBackupTileSF);
- sleep(500);
- }
- sleep(100);
- invFull = Inventory.isFull();
- }
- }
- private boolean checkForCabbagesSF() {
- RSObject[] cabbages = Objects.find(25, CABBAGE_GROUND_ID);
- if (cabbages.length > 0 && cabbages != null)
- return true;
- else
- return false;
- }
- private void useDepositBox() {
- RSObject[] dBox = Objects.findNearest(7, DEPOSIT_BOX_ID);
- if (dBox.length > 0 && dBox != null) {
- depositBox = dBox[0];
- if (depositBox.isClickable()) {
- if (depositBox.click("Deposit")) {
- sleep(1000);
- status = "Banking Cabbages";
- if (Banking.isDepositBoxOpen()) {
- Banking.depositAll();
- sleep(1000);
- if (Inventory.getCount(CABBAGE_ID) > 0 && Banking.isDepositBoxOpen())
- Banking.depositAll();
- if ((Math.random() * 100) > 70)
- Banking.close();
- }
- }
- else
- PathFinding.aStarWalk(depositBoxBackupTile);
- }
- else {
- PathFinding.aStarWalk(depositBoxBackupTile);
- if (depositBox.isClickable()) {
- depositBox.click("Deposit");
- Banking.depositAll();
- }
- }
- }
- else {
- sleep(200);
- if (Inventory.isFull()) {
- if (Game.getRunEnergy() >= 20) {
- if (Options.setRunOn(true))
- status = "Running to deposit";
- else
- status = "Walking to deposit";
- }
- else
- status = "Walking to deposit";
- RSTile[] path2 = Walking.generateStraightPath(DEPOSIT_BOX_TILE);
- path2 = Walking.randomizePath(path2, 2, 2);
- Walking.walkPath(path2);
- while (Player.isMoving())
- sleep(100);
- RSObject[] dBox1 = Objects.findNearest(7, DEPOSIT_BOX_ID);
- if (dBox1.length > 0 && dBox1 != null) {
- depositBox = dBox1[0];
- if (depositBox.isClickable()) {
- if (depositBox.click("Deposit")) {
- sleep(1000);
- status = "Banking Cabbages";
- if (Banking.isDepositBoxOpen()) {
- Banking.depositAll();
- sleep(1000);
- if (Inventory.getCount(CABBAGE_ID) > 0 && Banking.isDepositBoxOpen())
- Banking.depositAll();
- if ((Math.random() * 100) > 70)
- Banking.close();
- }
- }
- }
- }
- }
- }
- }
- private void checkCabbagePrice() {
- if (!area.equals("Draynor Manor")) {
- if (cabbagePrice == -1) {
- cabbagePrice = 100;
- notConnected = true;
- }
- if (notConnected) {
- println("Could not connect to RSBuddy price guide, will assume cabbages are worth 100gp each");
- }
- else
- println("Connected to RSBuddy price guide, cabbages are worth " + cabbagePrice + "gp each");
- }
- else
- println("Reminder: Draynor Manor cabbages are NOT tradeable");
- }
- private void runScriptInfo() {
- File scriptInfo = new File("nCabbagePicker.txt");
- try {
- sc = new Scanner(scriptInfo);
- if (sc.hasNext()) {
- if (sc.nextLine().equals("displayInfo=false")) {
- showInfo = false;
- sc.close();
- }
- }
- } catch (FileNotFoundException e) {
- // add action if not found
- e.printStackTrace();
- }
- if (showInfo) {
- ScriptInfo info = new ScriptInfo();
- info.setSize(350,300);
- info.setResizable(false);
- info.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
- info.setTitle("Information");
- info.setVisible(true);
- while (infoOpen) {
- sleep(1000);
- infoOpen = info.getOpen();
- }
- if (!info.getDisplayInfo()) {
- try {
- outputFile = new File(Util.getWorkingDirectory() + "\\nCabbagePicker.txt");
- outputFile.createNewFile();
- FileWriter output = new FileWriter(outputFile);
- output.write("displayInfo=false");
- output.flush();
- output.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- }
- }
- private void runGUI() {
- GUI GUI = new GUI();
- GUI.setSize(408,300);
- GUI.setResizable(false);
- GUI.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
- GUI.setTitle("nCabbage Picker GUI");
- GUI.setVisible(true);
- while (!GUIcomplete) {
- sleep(1000);
- GUIcomplete = GUI.getGUIcomplete();
- }
- GUI.setVisible(false);
- area = (GUI.getArea());
- }
- public static int getPrice(final int itemId) {
- try {
- URL url = new URL("https://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + itemId);
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
- String line = reader.readLine();
- return line == null ? -1 : Integer.parseInt(line.substring(11, line.indexOf(',')));
- } catch (IOException e) {
- e.printStackTrace();
- }
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return -1;
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- @Override
- public void mouseClicked(Point click, int button, boolean isBot) {
- if (!isBot && button == 1 && whereToClick.contains(click)) {
- paintEnabled = (!paintEnabled);
- }
- }
- @Override
- public void mouseDragged(Point arg0, int arg1, boolean arg2) {
- {}
- }
- @Override
- public void mouseMoved(Point mousePos, boolean isBot) {
- {}
- }
- @Override
- public void mouseReleased(Point arg0, int arg1, boolean arg2) {
- {}
- }
- @Override
- public void onPaint(Graphics g) {
- long currentTime = Timing.timeFromMark(startTime);
- long gpPerHour = (long)((long)3600000 * count * cabbagePrice)/((long)currentTime);
- int gpMade = count*cabbagePrice;
- int cabbagesHour = (int) ((long)((long)3600000 * count)/((long)currentTime));
- Graphics2D gg = (Graphics2D)g;
- gg.setRenderingHints(aa);
- Rectangle r = new Rectangle(120, 340, 40, 20);
- if (!r.contains(Mouse.getPos())) {
- paintEnabled = true;
- }
- else paintEnabled = false;
- if (paintEnabled) {
- gg.drawImage(img, 65, 275, null);
- gg.setColor(Color.WHITE);
- gg.setFont(regFont);
- gg.drawString("Cabbages Picked: " + count, 280, 365);
- gg.drawString("Status: " + status, 280, 385);
- gg.drawString("Time Running: " + Timing.msToString(currentTime), 280, 405);
- if (area != null && area.equals("Draynor Manor"))
- gg.drawString("Cabbages/Hr: " + cabbagesHour, 280, 425);
- else
- gg.drawString("Gp/Hr: " + gpPerHour, 280, 425);
- if (area != null && !area.equals("Draynor Manor"))
- gg.drawString("Total gp: " + gpMade, 280, 445);
- }
- gg.drawRect(120, 340, 40, 20);
- gg.drawString("Hide", 124, 355);
- }
- @Override
- public void onEnd() {
- println("If you enjoyed the script please leave a review on the official thread on TriBot forums! If you encountered any bugs/issues please leave a response too. Thank you for using nCabbage Picker");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement