Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Desktop;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Polygon;
- import java.awt.Rectangle;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.URI;
- import java.net.URISyntaxException;
- import java.net.URL;
- import java.util.Properties;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Calculations;
- import org.powerbot.game.api.methods.Environment;
- import org.powerbot.game.api.methods.Game;
- import org.powerbot.game.api.methods.Settings;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Walking;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.Menu;
- import org.powerbot.game.api.methods.node.SceneEntities;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.tab.Skills;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.methods.widget.Lobby;
- import org.powerbot.game.api.util.Filter;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.util.Timer;
- import org.powerbot.game.api.wrappers.Area;
- import org.powerbot.game.api.wrappers.Locatable;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.interactive.NPC;
- import org.powerbot.game.api.wrappers.interactive.Player;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.api.wrappers.node.SceneObject;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.MessageEvent;
- import org.powerbot.game.bot.event.listener.MessageListener;
- import org.powerbot.game.bot.event.listener.PaintListener;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.border.*;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- @Manifest(name = "Runite Miner", description = "Mines Runite, Mithril, and Adamantite in the resource dungeon || World Hops || Banks", version = 1.6, website = "http://www.powerbot.org/community/topic/679105-runite-miner-world-hops-banks-resource-dungeon/", authors = {"Hogrog"})
- public class RuniteMiner extends ActiveScript implements PaintListener, MessageListener {
- int[] pin = {-1, -1, -1, -1};
- long ReturnTime[] = new long[139];
- long RespawnTime[] = new long[15];
- int CurrentWorldNum = 0;
- int CurrentWorldPop = 0;
- boolean CheckedCurrentWorldForOres = false;
- Timer RockTimer = new Timer(3000);
- String CurrentTask = "";
- boolean debug = false;
- WorldSelect WS = new WorldSelect();
- String verstionMessage = "";
- float currentVerstion = 1.6f;
- float latestVerstion = 0f;
- long startTime = 0;
- public int RestAnim[] = {5732, 11786, 5713};
- int RuniteRockID[] = {33078, 33079};
- int MithRockID[] = {32440, 32439, 32438};
- int AddeRockID[] = {32437, 32436, 32435};
- int EmptyRock[] = {33401, 33400, 33402, 33401};
- int RuniteOrePrice = 0;
- int MithOrePrice = 0;
- int AddOrePrice = 0;
- int PickaxeID[] = {1271, 1265, 15259, 1267, 1273, 1275, 1269};
- int RuniteOreCount = 0;
- int MithOreCount = 0;
- int AddOreCount = 0;
- int dungExitDoorID = 52866;
- int dunEntDoorID = 52856;
- int exitLadderID = 6226;
- int entLadderID = 2113;
- int bankBoothID = 11758;
- int runPerCent = 0;
- int RuniteOreID = 451;
- int MithOreID = 447;
- int AddOreID = 449;
- int setting1801 = 0;
- int setWorld = 0;
- int craftingLVL = 0;
- int topGemToDrop = 0;
- Tile LastClicked = new Tile(0,0,0);
- Tile NextClicked = new Tile(1,1,1);
- boolean mineRunite = true;
- boolean mineMith = false;
- boolean mineAdd = false;
- boolean memb = false;
- boolean useFreeWorlds = true;
- boolean highRisk = false;
- boolean worldHop = true;
- boolean skillWorlds = false;
- boolean politeMode = true;
- boolean clickLess = false;
- boolean gettingPop = false;
- boolean rockPrediction = false;
- boolean RockStatusCatch[] = new boolean[15];
- boolean cutGems = false;
- Timer mouseHoverTimer = new Timer(1000);
- Timer respawnTimer = new Timer(500);
- JFrame gui = new RuniteMinerGUI();
- SceneObject LastRockClicked = null;
- SceneObject CurrentRock = null;
- SceneObject NextRock = null;
- Area area_top = new Area(new Tile[] { new Tile(3004, 3367, 0), new Tile(3005, 3327, 0), new Tile(3037, 3327, 0),
- new Tile(3035, 3367, 0) });
- Area area_mine = new Area( new Tile[] { new Tile(1062,4509,0), new Tile(1062,4521,0), new Tile(1049,4521,0),
- new Tile(1049,4509,0)
- });
- Tile[] Path_bank = new Tile[] { new Tile(3020, 3339, 0), new Tile(3022, 3337, 0), new Tile(3027, 3337, 0),
- new Tile(3029, 3340, 0), new Tile(3029, 3345, 0), new Tile(3027, 3349, 0),
- new Tile(3023, 3353, 0), new Tile(3022, 3356, 0), new Tile(3020, 3358, 0),
- new Tile(3015, 3359, 0), new Tile(3013, 3357, 0), new Tile(3013, 3354, 0) };
- private final Color color1 = new Color(60, 60, 60, 170);
- private final Color color2 = new Color(0, 255, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 1, 18);
- private final Font font2 = new Font("Arial", 1, 9);
- private final Font font3 = new Font("Arial", 1, 11);
- public MouseTrail trail = new MouseTrail();
- public int testworld = 33;
- @Override
- public void onRepaint(Graphics g) {
- g.setColor(Color.black);
- Rectangle username = Widgets.get(137, 53).getBoundingRectangle();
- g.fillRect(username.x, username.y, username.width, username.height);
- //g.fillRect(8, 457, 100, 16);
- //g.fillRect(235, 80, 50, 120);
- //g.fillRect(115, 76, 560, 16);
- trail.add(Mouse.getLocation());
- trail.draw(g);
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis /(1000 *60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- int oreCount = RuniteOreCount + MithOreCount + AddOreCount;
- int profit = (RuniteOreCount * RuniteOrePrice) + (MithOreCount * MithOrePrice) + (AddOreCount * AddOrePrice);
- int orePerHour = 0;
- float oresec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && oreCount > 0) {
- oresec = ((float) oreCount)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- float oremin = oresec * 60;
- orePerHour = Math.round(oremin * 60);
- int profitPerHour = 0;
- float profitsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && profit > 0) {
- profitsec = ((float) profit)/(float)(seconds + (minutes*60) + (hours*60*60));
- }
- float profitmin = profitsec * 60;
- profitPerHour = Math.round(profitmin * 60);
- Graphics2D g2d = (Graphics2D)g;
- g2d.setColor(new Color(0, 255, 0, 60));
- if (CurrentRock != null && isTileOnScreen(CurrentRock.getLocation())){
- g2d.fillPolygon(CurrentRock.getLocation().getBounds()[0]);
- }
- g2d.setColor(new Color(255, 127, 39, 60));
- if (NextRock != null && isTileOnScreen(NextRock.getLocation())){
- g2d.fillPolygon(NextRock.getLocation().getBounds()[0]);
- }
- g2d.setColor(color1);
- g2d.fillRoundRect(328, 15, 184, 225, 16, 16);
- g2d.setColor(color2);
- g2d.setStroke(stroke1);
- g2d.drawRoundRect(328, 15, 184, 225, 16, 16);
- g2d.setFont(font1);
- g2d.drawString("Runite Miner", 370, 48);
- g2d.setFont(font2);
- g2d.drawString("Made By Hogrog v" + currentVerstion, 380, 60);
- g2d.setFont(font3);
- g2d.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 340, 90);
- g2d.drawString("Mining: " + (mineRunite ? "Runite," : "") + (mineAdd ? "Addy," : "") + (mineMith ? "Mith" : ""), 340, 110);
- g2d.drawString("Ores mined: " + oreCount, 340, 130);
- g2d.drawString("Ores p/h: " + orePerHour, 340, 150);
- g2d.drawString("Profit Made: " + profit, 340, 170);
- g2d.drawString("Profit p/h: " + profitPerHour, 340, 190);
- g2d.drawString("Runite Price: " + RuniteOrePrice, 340, 210);
- g2d.drawString("Current Task: " + CurrentTask, 340, 230);
- //g2d.drawString("Crafting LVL: " + Skills.getLevel(Skills.CRAFTING), 340, 250);
- //g2d.drawString("Current World Pop: " + CurrentWorldPop, 340, 250);
- int count = 0;
- g2d.setColor(Color.CYAN);
- count = 0;
- int world = 0;
- for (long t : ReturnTime){
- if (t != 0 && world != 0){
- g2d.drawString("World: " + world + " Return In: "+ Time.format(t - System.currentTimeMillis()), 20, 50 + (20 * count));
- count += 1;
- }
- world += 1;
- }
- if (debug) {
- if (WS.isAtLobby()){
- int worldID = WS.WorldToID(50);
- WidgetChild w = Widgets.get(910,77).getChildren()[worldID];
- WidgetChild s = Widgets.get(910, 86).getChildren()[1];
- WidgetChild worldBox = Widgets.get(910, 62);
- int worldPos = w.getRelativeY();
- int worldScrollPos = (int)((worldPos) / 8.4) + 16;
- int scrollPos = s.getRelativeY();
- g2d.drawLine(0, worldScrollPos + worldBox.getAbsoluteY(), Game.getDimensions().width, worldScrollPos + worldBox.getAbsoluteY());
- g2d.drawLine(0,scrollPos + worldBox.getAbsoluteY(),Game.getDimensions().width,scrollPos + worldBox.getAbsoluteY());
- Point worldPt = new Point(Random.nextInt(100, w.getWidth()/2),(w.getAbsoluteY() + Random.nextInt(1, w.getHeight() - 3)));
- g2d.fillOval(worldPt.x, worldPt.y, 3, 3);
- g2d.drawString("World On Screen: " + worldBox.getBoundingRectangle().contains(worldPt), 340, 250);
- }
- g2d.setColor(Color.red);
- count = 0;
- for (long l : RespawnTime){
- Point p = Rocks.values()[count].getLocation().getCentralPoint();
- g2d.drawString(l == 0 ? "0" : (formatTime(l - System.currentTimeMillis())), p.x, p.y + 10);
- count++;
- }
- g2d.drawString("bank open: "+ String.valueOf((isBankOpen())),340, 240);
- final SceneObject rock = getRock();
- final SceneObject nextRock = getNextRock();
- if (rock != null) {
- g2d.drawString(
- "faceing rock: "
- + String.valueOf(faceingTile(Players.getLocal(), rock.getLocation())),
- 340, 260);
- Tile t = rock.getLocation();
- Tile PlayerTile = Players.getLocal().getLocation();
- int rot = Players.getLocal().getOrientation();
- int dx = PlayerTile.getX() - t.getX();
- int dy = PlayerTile.getY() - t.getY();
- g2d.drawString("rotaion: " + rot, 340, 300);
- g2d.drawString("dx: " + dx, 340, 320);
- g2d.drawString("dy: " + dy, 340, 340);
- g2d.setColor(new Color(0, 255, 0, 60));
- for (Polygon p : rock.getBounds()) {
- g2d.drawPolygon(p);
- }
- }
- g2d.setColor(new Color(255, 127, 39, 60));
- if (nextRock != null){
- for (Polygon p : nextRock.getBounds()) {
- g2d.drawPolygon(p);
- }
- }
- g2d.setColor(color2);
- g2d.drawString("moveing: " + String.valueOf((isPlayerMoveing())),
- 340, 280);
- g2d.drawString("Current Task: " + CurrentTask, 340, 360);
- //g2d.drawString("Model Cache: " + org.powerbot.game.client.ModelCapture.modelCache.size(), 340, 380);
- g2d.drawString("Favourited Worlds: " + String.valueOf(WS.areFavouritWorldsSelected()), 340, 400);
- g.setColor(Color.RED);
- for (SceneObject r : SceneEntities.getLoaded()){
- if (compaireID(r.getId() ,RuniteRockID)){
- g2d.drawString(String.valueOf(RockInuse(r)), r.getCentralPoint().x, r.getCentralPoint().y - 10);
- }else if (compaireID(r.getId() ,AddeRockID)){
- g2d.drawString(String.valueOf(RockInuse(r)), r.getCentralPoint().x, r.getCentralPoint().y - 10);
- }else if (compaireID(r.getId() ,MithRockID)){
- g2d.drawString(String.valueOf(RockInuse(r)), r.getCentralPoint().x, r.getCentralPoint().y - 10);
- }
- }
- }
- Point p = new Point(Mouse.getX(),Mouse.getY());
- g.setColor(Color.RED);
- g.drawLine(0, p.y, 800, p.y);
- g.drawLine(p.x, 0, p.x, 800);
- g.setColor(Color.BLUE);
- g.drawOval(p.x-5,p.y-5,10,10);
- g.setColor(color2);
- for (Tile t : Path_bank) {
- if (onMap(t)){
- Point po = Calculations.worldToMap(t.getX(), t.getY());
- g.drawOval(po.x, po.y, 2, 2);
- }
- }
- }
- @Override
- protected void setup() {
- gui.setVisible(true);
- LookupPrices lookupprices = new LookupPrices();
- submit(lookupprices);
- }
- private class UpdateWorldPop extends Strategy implements Task {
- public boolean validate() {
- return CurrentWorldPop == 0 && worldHop == false;
- }
- public void run() {
- CurrentTask = "Getting World Pop";
- if (WS.isLoggedIn()){
- if (Tabs.getCurrent() != Tabs.FRIENDS){
- Tabs.FRIENDS.open();
- String cWorld = Widgets.get(550, 18).getText();
- setWorld = Integer.parseInt(cWorld.replaceAll("[^0-9]", ""));
- log.info(cWorld.replaceAll("[^0-9]", ""));
- }
- if (setWorld != 0){
- WS.exitToLobby();
- }
- }
- if (setWorld == 0){
- loginToRndWorld();
- } else if (WS.isAtLobby() && !WS.loginErrorVisible() && !WS.isLoggingIn()) {
- if (WS.ValidateEmailMessageVisible()) {
- WS.SkipValidateEmailMessage();
- }
- if (!WS.worldSelectTabSelected()) {
- WS.showSelectWorldTab();
- }
- if (WS.worldSelectTabSelected()) {
- int world = setWorld;
- boolean correctWorld = WS.selectWorld(world, true);
- if (!correctWorld) {
- correctWorld = WS.selectWorld(world, false);
- }
- if (correctWorld) {
- CurrentWorldNum = WS.getCurrentWorld();
- CurrentWorldPop = WS.getWorldPopulation(world);
- if (WS.playGame()){
- }
- int count = 0;
- do {
- if (Widgets.get(906, 119).validate() && Widgets.get(906, 119).visible()) {
- if (highRisk){
- Widgets.get(906,118).click(true);
- }else {
- Widgets.get(906,117).click(true);
- break;
- }
- }
- Time.sleep(Random.nextInt(900, 1100));
- count += 1;
- } while ((count < 60)
- && (Game.getClientState() == 9
- || Game.getClientState() == 7 || WS
- .isLoggingIn())
- && !Widgets.get(906, 115).isOnScreen()
- && !WS.loginErrorVisible());
- RockTimer.reset();
- }
- }
- }
- }
- }
- private class DropGems extends Strategy implements Task {
- Item dropItem = null;
- public boolean validate() {
- for (final Item item : Inventory.getItems()) {
- for (int x = 0; x <= Gems.values().length -1; x ++){
- if ((item.getId() == Gems.values()[x].getCutID()) && Gems.values()[x].getRank() <= topGemToDrop){
- dropItem = item;
- return true;
- } else if (item.getId() == Gems.values()[x].ID && cutGems && Gems.values()[x].getLVL() > craftingLVL && Gems.values()[x].getRank() <= topGemToDrop){
- dropItem = item;
- return true;
- }else if (!cutGems && item.getId() == Gems.values()[x].ID && Gems.values()[x].getRank() <= topGemToDrop){
- dropItem = item;
- return true;
- }
- }
- }
- return false;
- }
- public void run() {
- CurrentTask = "Hover Mouse";
- if (dropItem != null){
- dropItem.getWidgetChild().interact("Drop");
- Time.sleep(100, 300);
- }
- }
- }
- private class CutGems extends Strategy implements Task {
- public boolean validate() {
- return cutGems && Inventory.getCount(Gems.SAPPHIRE.getAllIDs()) >= 1;
- }
- public void run() {
- CurrentTask = "Cut Gems";
- if (craftingLVL == 0){
- craftingLVL = Skills.getLevel(Skills.CRAFTING);
- }else {
- for (final Item item : Inventory.getItems()) {
- for (int x = 0; x <= Gems.values().length -1; x ++){
- if (item.getId() == Gems.values()[x].getID() && Gems.values()[x].getLVL() <= craftingLVL){
- if (Players.getLocal().getAnimation() == 889){
- Time.sleep(500, 1000);
- }else{
- item.getWidgetChild().interact("Craft");
- Time.sleep(400, 600);
- if (Widgets.get(905, 14).validate() && Widgets.get(905, 14).visible()){
- Widgets.get(905, 14).click(true);
- Time.sleep(400, 600);
- }
- }
- }
- }
- }
- }
- }
- }
- private class RockChanged extends Strategy implements Task {
- public boolean validate() {
- return setting1801 != Settings.get(1801)
- || (Players.getLoaded().length > 1 && respawnTimer
- .isRunning() == false);
- }
- public void run() {
- CurrentTask = "Rock Changed";
- setting1801 = Settings.get(1801);
- UpdateRockCatch();
- }
- }
- public void UpdateRockCatch() {
- if (area_mine.contains(Players.getLocal().getLocation())){
- boolean RockStatusCatchNew[] = new boolean[15];
- int count = 0;
- for (Rocks r : Rocks.values()) {
- try {
- if (count < Rocks.values().length) {
- RockStatusCatchNew[count] = (SceneEntities.getAt(
- r.getLocation()).getId() == r.getDownID() ? false
- : true);
- // log.info(String.valueOf(RockStatusCatchNew[count]) +
- // count + " " + r.getType().toString());
- count++;
- }
- } catch (Exception ex) {
- log.info(ex.getMessage());
- log.info("Exception");
- }
- }
- count = 0;
- for (boolean b : RockStatusCatchNew) {
- if (count < Rocks.values().length) {
- try {
- if (b != RockStatusCatch[count]) {
- if (b == true) {
- RespawnTime[count] = 0;
- } else {
- if (Rocks.values()[count].getType() == Rock.MITH) {
- RespawnTime[count] = (long) (((4f - ((CurrentWorldPop) / 1000f)) * 60f * 1000f)
- + System.currentTimeMillis());
- } else if (Rocks.values()[count].getType() == Rock.ADDY) {
- RespawnTime[count] = (long) ((8f - ((CurrentWorldPop) / 500f)) * 60f * 1000f)
- + System.currentTimeMillis();
- } else if (Rocks.values()[count].getType() == Rock.RUNE) {
- RespawnTime[count] = (long) ((1500f - ((3f * CurrentWorldPop) / 8f)) * 1000f)
- + System.currentTimeMillis();
- }
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- log.info("Exception");
- }
- }
- RockStatusCatch[count] = b;
- count++;
- }
- respawnTimer.reset();
- }
- }
- public boolean isTileOnScreen(Tile tile) {
- return Calculations.isOnScreen(new Tile(tile.getX() + 1, tile.getY() + 1, tile.getPlane()).getCentralPoint())
- && Calculations.isOnScreen(new Tile(tile.getX() - 1 , tile.getY() + 1, tile.getPlane()).getCentralPoint())
- && Calculations.isOnScreen(new Tile(tile.getX() - 1, tile.getY() - 1, tile.getPlane()).getCentralPoint())
- && Calculations.isOnScreen(new Tile(tile.getX() + 1, tile.getY() - 1, tile.getPlane()).getCentralPoint());
- }
- private boolean isPlayerMoveing(){
- return Players.getLocal().getPassiveAnimation() == 824 || Players.getLocal().getPassiveAnimation() == 819;
- }
- private class MouseHover extends Strategy implements Task {
- public boolean validate() {
- return !mouseHoverTimer.isRunning() && Inventory.getCount() != 28 && WS.isLoggedIn() && Players.getLocal().getAnimation() == 624;
- }
- public void run() {
- CurrentTask = "Hover Mouse";
- SceneObject NextRock = getNextRock();
- if (NextRock != null && !NextRock.isOnScreen()){
- Locatable l = (NextRock.getLocation());
- Camera.turnTo(l);
- Point RockPt = Calculations.worldToMap(NextRock.getLocation().getX(), NextRock.getLocation().getY());
- if (!Mouse.getLocation().equals(RockPt)){
- Mouse.move(RockPt);
- }
- } else if (NextRock != null && !NextRock.contains(Mouse.getLocation())){
- Mouse.move(NextRock.getCentralPoint(), 10, 10);
- }
- mouseHoverTimer.reset();
- }
- }
- private class CloseMayMadness extends Strategy implements Task {
- public boolean validate() {
- return WS.isLoggedIn() && Widgets.get(1272, 24).validate();
- }
- public void run() {
- CurrentTask = "Close May Ad";
- if (Widgets.get(1272, 24).validate()) {
- Widgets.get(1272, 24).click(true);
- Time.sleep(300,500);
- }
- }
- }
- private class ClearLastClickTile extends Strategy implements Task {
- public boolean validate() {
- return !LastClicked.equals(new Tile(0,0,0)) && WS.isLoggedIn() && !isPlayerMoveing();
- }
- public void run() {
- CurrentTask = "Reset Last Clicked Tile";
- LastClicked = new Tile(0,0,0);
- }
- }
- private class RunIntoMine extends Strategy implements Task {
- public boolean validate() {
- return Inventory.getCount() != 28 && WS.isLoggedIn() && Players.getLocal().getLocation().equals(new Tile(1053,4521,0));
- }
- public void run() {
- CurrentTask = "Run into mine";
- new Tile(1055,4514,0).clickOnMap();
- }
- }
- private class InventorySelect extends Strategy implements Task {
- public boolean validate() {
- return WS.isLoggedIn() && Tabs.getCurrent() != Tabs.INVENTORY;
- }
- public void run() {
- CurrentTask = "Select Inventory";
- if (Widgets.get(548, 93).validate() && Tabs.getCurrent() != Tabs.INVENTORY){
- Widgets.get(548, 93).click(true);
- Time.sleep(Random.nextInt(100, 300));
- }
- }
- }
- private class CloseLoginError extends Strategy implements Task {
- public boolean validate() {
- return WS.isAtLobby() && WS.loginErrorVisible();
- }
- public void run() {
- CurrentTask = "Close login error message";
- WS.closeLogonErrorMessage();
- }
- }
- private class Resting extends Strategy implements Task {
- public boolean validate() {
- if (Inventory.getCount() < 28 && !worldHop) {
- if (SceneEntities.getNearest(dungExitDoorID) != null && Walking.getEnergy() <= 60) {
- Tile next = nextSpawnLocation();
- if (next == null ? true : Calculations.distanceTo(next) <= 1){
- final SceneObject rock = getRock();
- if (rock == null) {
- if (Players.getLocal().getAnimation() != RestAnim[0]) {
- if (Players.getLocal().getAnimation() != RestAnim[1]) {
- if (Players.getLocal().getAnimation() != RestAnim[2]) {
- return true;
- }
- }
- }
- }
- }
- }}
- return false;
- }
- public void run() {
- CurrentTask = "Resting";
- WidgetChild runChild = Widgets.get(548).getChild(168);
- if (runChild.validate()) {
- runChild.click(false);
- if (Menu.contains("Rest")) {
- Menu.select("Rest");
- Time.sleep(Random.nextInt(1000, 1500));
- } else {
- Mouse.move(Random.nextInt(1,500), Random.nextInt(1,500));
- }
- }
- }
- }
- private boolean faceingTile (Player P, Tile t){
- Tile PlayerTile = P.getLocation();
- int rot = P.getOrientation();
- int dx = PlayerTile.getX() - t.getX();
- int dy = PlayerTile.getY() - t.getY();
- if (dy == -1 && dx == -1){
- return rot == 45;
- }else if (dy == 1 && dx == 1){
- return rot == 225;
- }else if (dy == -1 && dx == 1){
- return rot == 135;
- }else if (dy == 1 && dx == -1){
- return rot == 315;
- }else if (dy == -1 && dx == 0) {
- return rot == 90;
- }else if (dx == -1 && dy == 0){
- return rot == 0;
- }else if (dy == 1 && dx == 0) {
- return rot == 270;
- }else if (dx == 1 && dy == 0){
- return rot == 180;
- }
- return false;
- }
- private class LookupPrices extends Strategy implements Task {
- public boolean validate() {
- return true;
- }
- public void run() {
- CurrentTask = "Lookup Prices";
- RuniteOrePrice = lookup(RuniteOreID);
- MithOrePrice = lookup(MithOreID);
- AddOrePrice = lookup(AddOreID);
- }
- }
- private boolean RockInuse(SceneObject Rock){
- for (Player P : Players.getLoaded()){
- if (!P.equals(Players.getLocal()) && P.getAnimation() == 624 && faceingTile(P, Rock.getLocation())){
- return true;
- }
- }
- return false;
- }
- private SceneObject getRock(){
- UpdateRockCatch();
- SceneObject RuniteRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- if (politeMode){
- return compaireID(ob.getId() ,RuniteRockID) && (!RockInuse(ob) || faceingTile(Players.getLocal(), ob.getLocation()));
- } else {
- return compaireID(ob.getId() ,RuniteRockID);
- }
- }
- });
- if (politeMode && RuniteRock == null){
- RuniteRock = SceneEntities.getNearest(RuniteRockID);
- }
- if (RuniteRock != null && mineRunite && area_mine.contains(RuniteRock.getLocation())){
- CurrentRock = RuniteRock;
- return RuniteRock;
- }
- SceneObject AddRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- if (politeMode){
- return compaireID(ob.getId() ,AddeRockID) && (!RockInuse(ob) || faceingTile(Players.getLocal(), ob.getLocation()));
- } else {
- return compaireID(ob.getId() ,AddeRockID);
- }
- }
- });
- if (politeMode && AddRock == null){
- AddRock = SceneEntities.getNearest(AddeRockID);
- }
- if (AddRock != null && mineAdd && area_mine.contains(AddRock.getLocation())){
- CurrentRock = AddRock;
- return AddRock;
- }
- SceneObject MithRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- if (politeMode){
- return compaireID(ob.getId() ,MithRockID) && (!RockInuse(ob) || faceingTile(Players.getLocal(), ob.getLocation()));
- } else {
- return compaireID(ob.getId() ,MithRockID);
- }
- }
- });
- if (politeMode && MithRock == null){
- MithRock = SceneEntities.getNearest(MithRockID);
- }
- if (MithRock != null && mineMith && area_mine.contains(MithRock.getLocation())){
- CurrentRock = MithRock;
- return MithRock;
- }
- CurrentRock = null;
- return null;
- }
- private boolean compaireID(int id, int... IDs){
- for (int ID : IDs){
- if (ID == id){
- return true;
- }
- }
- return false;
- }
- private SceneObject getNextRock(){
- final SceneObject CurrentRock = getRock();
- if (CurrentRock != null){
- SceneObject RuniteRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- if (politeMode){
- return compaireID(ob.getId() ,RuniteRockID) && !RockInuse(ob) && !ob.getLocation().equals(CurrentRock.getLocation());
- } else {
- return compaireID(ob.getId() ,RuniteRockID) && !ob.getLocation().equals(CurrentRock.getLocation());
- }
- }
- });
- if (politeMode && RuniteRock == null){
- RuniteRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- return compaireID(ob.getId() ,RuniteRockID) && !ob.getLocation().equals(CurrentRock.getLocation());
- }
- });
- }
- if (RuniteRock != null && mineRunite && area_mine.contains(RuniteRock.getLocation())){
- NextRock = RuniteRock;
- return RuniteRock;
- }
- SceneObject AddRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- if (politeMode){
- return compaireID(ob.getId() ,AddeRockID) && !RockInuse(ob) && !ob.getLocation().equals(CurrentRock.getLocation());
- } else {
- return compaireID(ob.getId() ,AddeRockID) && !ob.getLocation().equals(CurrentRock.getLocation());
- }
- }
- });
- if (politeMode && AddRock == null){
- AddRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- return compaireID(ob.getId() ,AddeRockID) && !ob.getLocation().equals(CurrentRock.getLocation());
- }
- });
- }
- if (AddRock != null && mineAdd && area_mine.contains(AddRock.getLocation())){
- NextRock = AddRock;
- return AddRock;
- }
- SceneObject MithRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- if (politeMode){
- return compaireID(ob.getId() ,MithRockID) && !RockInuse(ob) && !ob.getLocation().equals(CurrentRock.getLocation());
- } else {
- return compaireID(ob.getId() ,MithRockID) && !ob.getLocation().equals(CurrentRock.getLocation());
- }
- }
- });
- if (politeMode && MithRock == null){
- MithRock = SceneEntities.getNearest(new Filter<SceneObject>(){
- @Override
- public boolean accept(SceneObject ob) {
- return compaireID(ob.getId() ,MithRockID) && !ob.getLocation().equals(CurrentRock.getLocation());
- }
- });
- }
- if (MithRock != null && mineMith && area_mine.contains(MithRock.getLocation())){
- NextRock = MithRock;
- return MithRock;
- }
- NextRock = null;
- return null;
- } else {
- NextRock = null;
- return null;
- }
- }
- private class CamerSetPitch extends Strategy implements Task {
- public boolean validate() {
- return Camera.getPitch() < 85 && WS.isLoggedIn();
- }
- public void run() {
- CurrentTask = "Set camera pitch";
- Camera.setPitch(true);
- }
- }
- private class ActivateRun extends Strategy implements Task {
- public boolean validate() {
- return WS.isLoggedIn() && Walking.getEnergy() >= runPerCent && !Walking.isRunEnabled();
- }
- public void run() {
- CurrentTask = "Activate run";
- if (!Walking.isRunEnabled()){
- Walking.setRun(true);
- runPerCent = Random.nextInt(60, 80);
- }
- }
- }
- private class Antiban extends Strategy implements Task {
- public boolean validate() {
- return Game.isLoggedIn() && Game.getClientState() == 11;
- }
- public void run() {
- switch (Random.nextInt(0, 1000)) {
- case 0:
- CurrentTask = "Antiban";
- Camera.setAngle(Random.nextInt(14,304));
- break;
- case 1:
- CurrentTask = "Antiban";
- Camera.setAngle(Random.nextInt(90,124));
- break;
- case 2:
- CurrentTask = "Antiban";
- Camera.setAngle('N');
- break;
- case 3:
- CurrentTask = "Antiban";
- Mouse.move(Random.nextInt(1,500), Random.nextInt(1,500));
- break;
- }
- }
- }
- private class EnterDung implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Enter Dung";
- final SceneObject door = SceneEntities.getNearest(dunEntDoorID);
- if (door != null && door.isOnScreen() && Players.getLocal().getAnimation() != 13288){
- door.click(true);
- } else if (door != null && !door.isOnScreen() && !isPlayerMoveing()){
- door.getLocation().clickOnMap();
- }
- Time.sleep(Random.nextInt(500, 1000));
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() != 28) && SceneEntities.getNearest(dunEntDoorID) != null && !isPlayerMoveing();
- }
- }
- private class EnterMine implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Enter Mine";
- SceneObject ladder = SceneEntities.getNearest(entLadderID);
- if (ladder != null && ladder.isOnScreen()){
- Mouse.move(ladder.getCentralPoint(),5,5);
- if (ladder.click(true)){
- Time.sleep(Random.nextInt(800, 1500));
- }
- } else if (ladder != null && !ladder.isOnScreen()){
- //Walking.walk(ladder.getLocation());
- }
- ladder = SceneEntities.getNearest(entLadderID);
- if (ladder != null){
- Mouse.move(ladder.getCentralPoint(),5,5);
- if (ladder.interact("Climb-down")){
- Time.sleep(Random.nextInt(1000, 2000));
- }
- }
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() != 28) && SceneEntities.getNearest(entLadderID) != null && SceneEntities.getNearest(entLadderID).isOnScreen() && (!isPlayerMoveing() || Calculations.distanceTo(SceneEntities.getNearest(entLadderID).getLocation()) <= 5);
- }
- }
- private class WalkToMine implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Walk to mine";
- Tile NextTile = GetNextTile(Path_bank, false, 1);
- if (debug){
- log.info(NextTile.toString());
- }
- if (NextClicked != LastClicked){
- //if (NextTile.clickOnMap()){
- if (NextTile.clickOnMap()){
- LastClicked = NextClicked;
- Time.sleep(Random.nextInt(1000, 2000));
- }
- }
- }
- @Override
- public boolean validate() {
- try{
- return (Inventory.getCount() != 28) && area_top.contains(Players.getLocal().getLocation()) && (SceneEntities.getNearest(entLadderID) == null || !SceneEntities.getNearest(entLadderID).isOnScreen());
- }catch (RuntimeException e ){
- log.info(e.getMessage());
- return false;
- }finally{}
- }
- }
- private class UseBank implements Task, Condition {
- private static final int PIN_WIDGET = 13;
- @Override
- public void run() {
- CurrentTask = "Use bank";
- if (!isBankOpen() && !(Widgets.get(PIN_WIDGET, 1).visible())){
- SceneObject bank = SceneEntities.getNearest(bankBoothID);
- if (bank.isOnScreen()){
- Mouse.move(bank.getCentralPoint(),5,5);
- if (bank.interact("Bank", "Bank booth")){
- Time.sleep(Random.nextInt(1000, 2000));
- }
- }
- }
- if (!isBankOpen() && !(Widgets.get(PIN_WIDGET, 1).visible())){
- NPC banker = NPCs.getNearest(6200);
- if (banker != null && banker.isOnScreen()){
- Mouse.move(banker.getCentralPoint(),5,5);
- if (banker.interact("Bank")){
- Time.sleep(Random.nextInt(700, 1600));
- }
- }
- }
- if (isBankOpen()){
- depositAllExcept(PickaxeID);
- Time.sleep(Random.nextInt(300, 700));
- }
- }
- @Override
- public boolean validate() {
- if (Inventory.getCount() == 28){
- if (area_top.contains(Players.getLocal().getLocation())){
- if (SceneEntities.getNearest(bankBoothID) != null){
- if (SceneEntities.getNearest(bankBoothID).isOnScreen() && (!isPlayerMoveing() || Calculations.distanceTo(SceneEntities.getNearest(bankBoothID).getLocation()) <= 4) && !(Widgets.get(PIN_WIDGET, 1).visible())){
- return true;
- }
- }
- }
- }
- return false;
- }
- }
- public static boolean onMap(final Tile tile) {
- return Calculations.worldToMap(tile.getX(), tile.getY()).getX() != -1;
- }
- public Tile GetNextTile(Tile tiles[], boolean reverse, int rand){
- if (reverse == false){
- for (int x = 0; x < tiles.length; x++){
- Tile NewTile = new Tile (tiles[x].getX() + Random.nextInt(-rand, rand),tiles[x].getY() + Random.nextInt(-rand, rand),0);
- if (onMap(NewTile) && NewTile.isOnMap() && Calculations.distanceTo(NewTile) <= 16){
- NextClicked = tiles[x];
- return NewTile;
- }
- }
- } else {
- for (int x = (tiles.length-1); x>=0; x--){
- Tile NewTile = new Tile (tiles[x].getX() + Random.nextInt(-rand, rand),tiles[x].getY() + Random.nextInt(-rand, rand),0);
- if (onMap(NewTile) && NewTile.isOnMap() && Calculations.distanceTo(NewTile) <= 16){
- NextClicked = tiles[x];
- return NewTile;
- }
- }
- }
- return new Tile(0,0,0);
- }
- private class WalkToBank implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Walk to bank";
- Tile NextTile = GetNextTile(Path_bank, true, 1);
- if (NextClicked != LastClicked){
- if (NextTile.clickOnMap()){
- LastClicked = NextClicked;
- Time.sleep(Random.nextInt(1000, 2000));
- }
- }
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() == 28) && area_top.contains(Players.getLocal().getLocation()) && (SceneEntities.getNearest(bankBoothID) == null || !SceneEntities.getNearest(bankBoothID).isOnScreen());
- }
- }
- private class LeaveMine implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Leave Mine";
- final SceneObject ladder = SceneEntities.getNearest(exitLadderID);
- if (ladder != null && ladder.isOnScreen() && Players.getLocal().getAnimation() != 828){
- ladder.click(true);
- } else if (ladder != null && !ladder.isOnScreen()){
- ladder.getLocation().clickOnMap();
- }
- Time.sleep(Random.nextInt(1500, 2000));
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() == 28) && SceneEntities.getNearest(exitLadderID) != null && !isPlayerMoveing();
- }
- }
- private class LeaveDung implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Leave Dung";
- final SceneObject door = SceneEntities.getNearest(dungExitDoorID);
- if (door != null && door.isOnScreen() && Players.getLocal().getAnimation() != 13288){
- door.click(true);
- System.gc();
- } else if (door != null && !door.isOnScreen()){
- door.getLocation().clickOnMap();
- }
- Time.sleep(Random.nextInt(500, 1000));
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount() == 28) && SceneEntities.getNearest(dungExitDoorID) != null && !isPlayerMoveing();
- }
- }
- private class HightRiskWorld implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "High risk world message";
- if (highRisk){
- Widgets.get(906,118).click(true);
- }else {
- Widgets.get(906,117).click(true);
- }
- Time.sleep(Random.nextInt(300, 500));
- }
- @Override
- public boolean validate() {
- return Widgets.get(906,117).validate() && Widgets.get(906,117).visible();
- }
- }
- private class MembDetection implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Members message";
- Widgets.get(906,259).click(true);
- Time.sleep(Random.nextInt(300, 500));
- loginToRndWorld();
- }
- @Override
- public boolean validate() {
- return false;
- //return Widgets.get(906,42).isVisible();
- }
- }
- private class LobbyDetection implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "At lobby";
- loginToRndWorld();
- }
- @Override
- public boolean validate() {
- return WS.isAtLobby() && !WS.loginErrorVisible() && worldHop == true;
- }
- }
- private class SwitchWorld implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Switch world";
- if(Camera.getPitch() < 85 && WS.isLoggedIn()){
- Camera.setPitch(true);
- }
- Time.sleep(Random.nextInt(1000, 2000));
- final SceneObject rock = getRock();
- if (rock == null){
- WS.exitToLobby();
- System.gc();
- Time.sleep(Random.nextInt(1500, 2500));
- loginToRndWorld();
- }
- }
- @Override
- public boolean validate() {
- if (Inventory.getCount() < 28 && worldHop){
- final SceneObject rock = getRock();
- if (rock == null && Players.getLocal().getAnimation() != 624){
- if (SceneEntities.getNearest(dungExitDoorID) != null){
- return true;
- }
- }
- }
- return false;
- }
- }
- private void loginToRndWorld() {
- CheckedCurrentWorldForOres = false;
- if (WS.isAtLobby() && !WS.loginErrorVisible() && !WS.isLoggingIn()) {
- if (WS.ValidateEmailMessageVisible()) {
- WS.SkipValidateEmailMessage();
- }
- if (!WS.worldSelectTabSelected()) {
- WS.showSelectWorldTab();
- }
- if (WS.worldSelectTabSelected()) {
- int rndWorld = 0;
- int loopCount = 0;
- for (long t : ReturnTime) {
- if (t != 0 && loopCount != 0 && t < System.currentTimeMillis() && loopCount != WS.getCurrentWorld()) {
- rndWorld = loopCount;
- log.info("Return to World: " + rndWorld + " memb: "+ (WS.isWorldMembers(rndWorld)) + " WorldID: "+ (WS.WorldToID(rndWorld)));
- break;
- }
- loopCount += 1;
- }
- if (rndWorld == 0) {
- rndWorld = Random.nextInt(1, 139);
- while ((WS.WorldToID(rndWorld) == -1)
- || (WS.isWorldMembers(rndWorld) && !memb)
- || (!WS.isWorldMembers(rndWorld) && !useFreeWorlds)
- || (WS.getCurrentWorld() == rndWorld)
- || (WS.getWorldActivity(rndWorld).contains("High-risk") && !highRisk)
- || (WS.getWorldActivity(rndWorld).contains("Skill Total") && !skillWorlds)
- || ReturnTime[rndWorld] != 0)
- {
- rndWorld = Random.nextInt(1, 139);
- }
- log.info("Random World: " + rndWorld + " memb: "+ (WS.isWorldMembers(rndWorld)) + " WorldID: "+ (WS.WorldToID(rndWorld)));
- }
- boolean correctWorld = WS.selectWorld(rndWorld, true);
- if (!correctWorld) {
- correctWorld = WS.selectWorld(rndWorld, false);
- }
- if (correctWorld) {
- CurrentWorldNum = rndWorld;
- CurrentWorldPop = WS.getWorldPopulation(rndWorld);
- CheckedCurrentWorldForOres = false;
- if (WS.playGame()){
- ReturnTime[rndWorld] = 0;
- }
- int count = 0;
- do {
- if (Widgets.get(906, 119).validate() && Widgets.get(906, 119).visible()) {
- if (highRisk){
- Widgets.get(906,118).click(true);
- }else {
- Widgets.get(906,117).click(true);
- break;
- }
- }
- Time.sleep(Random.nextInt(900, 1100));
- count += 1;
- } while ((count < 60)
- && (Game.getClientState() == 9
- || Game.getClientState() == 7 || WS
- .isLoggingIn())
- && !Widgets.get(906, 115).isOnScreen()
- && !WS.loginErrorVisible());
- RockTimer.reset();
- }
- }
- }
- }
- private class MineRicks implements Task, Condition {
- @Override
- public void run() {
- CurrentTask = "Mine rock";
- final SceneObject rock = getRock();
- if (rock != null) {
- if (rock.isOnScreen()) {
- if (clickLess) {
- if (LastRockClicked != null
- && LastRockClicked.getLocation().equals(
- rock.getLocation())
- && faceingTile(Players.getLocal(),
- rock.getLocation())) {
- Time.sleep(Random.nextInt(800, 1300));
- }
- }
- Time.sleep(Random.nextInt(100, 300));
- if (Players.getLocal().getAnimation() != 624
- || !faceingTile(Players.getLocal(),
- rock.getLocation())) {
- if (rock.interact("Mine")) {
- LastRockClicked = rock;
- Time.sleep(Random.nextInt(1000, 1500));
- }
- SceneObject NextRock = getNextRock();
- if (NextRock != null && !NextRock.isOnScreen()) {
- Locatable l = (NextRock.getLocation());
- Camera.turnTo(l);
- }
- Mouse.move(NextRock.getCentralPoint(), 10, 10);
- }
- } else {
- rock.getLocation().clickOnMap();
- Time.sleep(Random.nextInt(200, 300));
- }
- }
- }
- @Override
- public boolean validate() {
- if (Inventory.getCount() < 28){
- final SceneObject rock = getRock();
- if (rock != null){
- if (compaireID(rock.getId() ,RuniteRockID)){
- if (!RockTimer.isRunning()){
- long RespornTime = (25 - (CurrentWorldPop/160)) * 60 * 1000;
- //long returnTime = Random.nextInt(0, 30000) + RespornTime ;
- ReturnTime[CurrentWorldNum] = System.currentTimeMillis() + RespornTime;
- CheckedCurrentWorldForOres = true;
- }
- } else if (CheckedCurrentWorldForOres == false){
- ReturnTime[CurrentWorldNum] = 0;
- CheckedCurrentWorldForOres = true;
- }
- } else if (rock == null && worldHop == false){
- Tile next = nextSpawnLocation();
- if (next != null && Calculations.distanceTo(next) >= 2 && Players.getLocal().isMoving() == false && rockPrediction){
- if (next.isOnScreen()){
- next.click(true);
- } else {
- next.clickOnMap();
- }
- Time.sleep(300, 800);
- }
- } else if (rock == null && WS.isLoggedIn() && Game.isLoggedIn() && CheckedCurrentWorldForOres == false){
- ReturnTime[CurrentWorldNum] = 0;
- CheckedCurrentWorldForOres = true;
- }
- if (rock != null){
- if (!faceingTile(Players.getLocal(), rock.getLocation()) && !isPlayerMoveing()){
- return true;
- }
- if (Players.getLocal().getAnimation() != 624 && !isPlayerMoveing()){
- Time.sleep(Random.nextInt(100, 300));
- return true;
- }
- }
- }
- return false;
- }
- }
- private Tile nextSpawnLocation(){
- int smallest = 0, count = 0;
- for (long l : RespawnTime){
- if (l < RespawnTime[smallest] && l != 0){
- smallest = count;
- }
- count++;
- }
- return Rocks.values()[smallest].getLocation();
- }
- @Override
- public void messageReceived(MessageEvent m) {
- if (m.getMessage().contains("mine some runite") ){
- RuniteOreCount += 1;
- } else if (m.getMessage().contains("mine some mith")){
- MithOreCount += 1;
- }else if (m.getMessage().contains("mine some ada")){
- AddOreCount += 1;
- }
- }
- public static boolean isBankOpen() {
- return Widgets.get(762).validate();
- }
- public boolean inventoryContains(final int... IDs){
- for (int ID : IDs){
- if (Inventory.getCount(ID) != 0){
- return true;
- }
- }
- return false;
- }
- private final class enterBankPin extends Strategy implements Task {
- private static final int PIN_WIDGET = 13;
- @Override
- public boolean validate() {
- return (Widgets.get(PIN_WIDGET, 1).visible()) && pin[0] != -1 && pin[1] != -1 && pin[2] != -1 && pin[3] != -1;
- }
- @Override
- public void run() {
- CurrentTask = "Bank Pin";
- if (Widgets.get(PIN_WIDGET, 1).visible()) {
- int pos = 1;
- for (int i : pin) {
- int numb = i + 6;
- if (Widgets.get(PIN_WIDGET, numb).click(true)) {
- Time.sleep(300);
- int count = 0;
- pos ++;
- while (Widgets.get(PIN_WIDGET).getChild(pos)
- .getText() == "?") {
- Time.sleep(200);
- if (count >= 4){
- break;
- }
- count ++;
- }
- }
- }
- }
- }
- }
- public void depositAllExcept(final int... IDs) {
- if (inventoryContains(IDs) && isBankOpen()){
- int[] DepositedIDs;
- DepositedIDs = new int[27];
- int Pos = 0;
- int timeout = 0;
- boolean bankAgain = false;
- do {
- for (final Item item : Inventory.getItems()) {
- if (item != null) {
- boolean deposit = true;
- for (final int ID : IDs) {
- if (item.getId() == ID) {
- deposit = false;
- break;
- }
- }
- for (int IDD : DepositedIDs) {
- if (item.getId() == IDD) {
- deposit = false;
- break;
- }
- }
- if (deposit) {
- int count = Inventory.getCount(item.getId());
- if (item.getWidgetChild().interact(
- count > 1 ? "Deposit-All" : "Deposit")) {
- DepositedIDs[Pos] = item.getId();
- Pos += 1;
- Time.sleep(Random.nextInt(100, 300));
- }
- }
- }
- }
- for (final Item item : Inventory.getItems()) {
- boolean validItem = false;
- for (final int ID : IDs) {
- validItem = false;
- if (item.getId() == ID){
- validItem = true;
- break;
- }
- }
- if (!validItem){
- bankAgain = true;
- break;
- }
- }
- timeout += 1;
- } while (bankAgain || timeout >= 5);
- } else {
- if (isBankOpen()){
- if (Widgets.get(762, 34).validate()){
- Widgets.get(762, 34).click(true);
- }
- }
- }
- }
- public boolean ClickTile (Tile t){
- if (onMap(t)){
- Point po = Calculations.worldToMap(t.getX(), t.getY());
- Mouse.click(po, true);
- return true;
- }
- return false;
- }
- //From API
- public static String formatTime(final long time) {
- final StringBuilder t = new StringBuilder();
- final long total_secs = time / 1000;
- final long total_mins = total_secs / 60;
- final long total_hrs = total_mins / 60;
- final int secs = (int) total_secs % 60;
- final int mins = (int) total_mins % 60;
- final int hrs = (int) total_hrs % 24;
- if (hrs != 0) {
- if (hrs < 10) {
- t.append("0");
- }
- t.append(hrs);
- t.append(":");
- }
- if (mins != 0) {
- if (mins < 10) {
- t.append("0");
- }
- t.append(mins);
- t.append(":");
- }
- if (secs < 10) {
- t.append("0");
- }
- t.append(secs);
- return t.toString();
- }
- // Credits to Deprecated for the mouse trail
- public class MouseTrail {
- private final static int SIZE = 25;
- private Point[] points;
- private int index;
- public MouseTrail() {
- points = new Point[SIZE];
- index = 0;
- }
- public void add(Point p) {
- points[index++] = p;
- index %= SIZE;
- }
- public void draw(Graphics graphics) {
- double alpha = 0;
- for (int i = index; i != (index == 0 ? SIZE-1 : index-1); i = (i+1)%SIZE) {
- if (points[i] != null && points[(i+1)%SIZE] != null) {
- graphics.setColor(new Color(0, 255, 0, (int) alpha));
- graphics.drawLine(points[i].x, points[i].y, points[(i+1)%SIZE].x, points[(i+1)%SIZE].y);
- alpha += (255.0/SIZE);
- }
- }
- }
- }
- public static int lookup(int itemID) {
- try {
- final URL url = new URL(
- "http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj="
- + itemID);
- final BufferedReader in = new BufferedReader(new InputStreamReader(
- url.openStream()));
- String input;
- while ((input = in.readLine()) != null) {
- if (input.contains("Current guide price:")) {
- input = in.readLine();
- return Integer.parseInt(formatter(input.substring(4,
- input.lastIndexOf('<'))));
- }
- }
- } catch (Exception e) {
- }
- return -1;
- }
- private static String formatter(String num) {
- try {
- return num.replaceAll("\\.", "").replaceAll("m", "00000")
- .replaceAll("k", "00").replaceAll(",", "");
- } catch (Exception e) {
- }
- return "0";
- }
- public static class WorldSelect {
- private String MembersMessage = "You need a member's account to log in to this world.";
- private String AlreadyLoggedOnMessage = "Your account has not logged out from its last session.";
- private String SkillWorldMessage = "1500";
- private String LoginLimit = "Login limit exceeded";
- private String ProfileTransferMessage = "You have only just left another world";
- private String OfflineWorldMessage = "Could not connect you to the chosen world";
- private String FullWorld = "This world is full. Please use a different world.";
- public boolean fullWorld(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(FullWorld);
- }
- return false;
- }
- public boolean offlineWorld(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(OfflineWorldMessage);
- }
- return false;
- }
- public boolean transferingProfile(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(ProfileTransferMessage);
- }
- return false;
- }
- public boolean LoginLimieExceeded(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(LoginLimit);
- }
- return false;
- }
- public boolean closeLogonErrorMessage(){
- if (isAtLobby() && loginErrorVisible()){
- return Widgets.get(906, 262).click(true);
- }
- return false;
- }
- public boolean ValidateEmailMessageVisible(){
- return Widgets.get(906, 381).validate() && Widgets.get(906, 381).visible();
- }
- public boolean SkipValidateEmailMessage(){
- if (ValidateEmailMessageVisible()){
- Widgets.get(906, 381).click(true);
- return true;
- }
- return false;
- }
- public boolean loginErrorVisible(){
- return isMembersMessageOnScreen() || isAlreadyLoggedOnMessageOnScreen() || isSkillTotalWorldMessageOnScreen() || LoginLimieExceeded() || offlineWorld() || fullWorld();
- }
- public boolean isMembersMessageOnScreen(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(MembersMessage);
- }
- return false;
- }
- public boolean isAlreadyLoggedOnMessageOnScreen(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(AlreadyLoggedOnMessage);
- }
- return false;
- }
- public boolean isSkillTotalWorldMessageOnScreen(){
- if (isAtLobby()){
- return Widgets.get(906, 252).getText().contains(SkillWorldMessage);
- }
- return false;
- }
- public boolean worldSelectTabSelected(){
- return Widgets.get(906, 28).getTextureId() == 4671;
- }
- public boolean areFavouritWorldsSelected(){
- if (isAtLobby() && !loginErrorVisible() && !isLoggingIn()){
- if (Widgets.get(910, 21).validate() && Widgets.get(910, 21).getChildren().length > 2){
- return Widgets.get(910, 21).getChild(4).validate();
- }
- }
- return false;
- }
- public boolean removeFavouritedWorlds(){
- if (isAtLobby() && !loginErrorVisible() && !isLoggingIn()){
- if (Widgets.get(910, 22).validate() && Widgets.get(910, 22).getChildren().length > 2 && Widgets.get(910, 22).getChild(4).validate()){
- Widgets.get(910, 22).getChild(4).click(true);
- Time.sleep(50, 100);
- }
- if (Widgets.get(910, 21).validate() && Widgets.get(910, 21).getChildren().length > 2 && Widgets.get(910, 21).getChild(4).validate()){
- Widgets.get(910, 21).getChild(4).click(true);
- Time.sleep(50, 100);
- }
- } else {
- return false;
- }
- return true;
- }
- public boolean exitToLobby() {
- WidgetChild closeBn = Widgets.get(548, 159);
- if (closeBn.validate()) {
- closeBn.click(true);
- Time.sleep(Random.nextInt(300, 800));
- WidgetChild lobbyBn = Widgets.get(182, 6);
- if (lobbyBn.validate()) {
- lobbyBn.click(true);
- Time.sleep(Random.nextInt(300, 800));
- }
- }
- return Game.getClientState() == -1 || Game.getClientState() == 7;
- }
- public boolean isWorldMembers(int world){
- int worldID = WorldToID(world);
- if (worldID != -1){
- WidgetChild w = Widgets.get(910,74).getChildren()[worldID];
- return w.getText().endsWith("Members");
- }
- return false;
- }
- public String getWorldActivity(int world){
- int worldID = WorldToID(world);
- if (worldID != -1){
- WidgetChild w = Widgets.get(910,72).getChildren()[worldID];
- return w.getText();
- }
- return "";
- }
- public int getWorldPopulation(int world){
- int worldID = WorldToID(world);
- if (worldID != -1){
- WidgetChild w = Widgets.get(910,71).getChildren()[worldID];
- return Integer.parseInt(w.getText());
- }
- return -1;
- }
- public boolean isLoggedIn(){
- return Game.isLoggedIn();
- }
- public boolean isLoggingIn(){
- return Game.getClientState() == 9 || transferingProfile();
- }
- public boolean isAtLobby(){
- return Game.getClientState() == 7;
- }
- public boolean playGame(){
- WidgetChild playBn = Widgets.get(906, 186);
- playBn.click(true);
- Time.sleep(Random.nextInt(400, 700));
- return Game.getClientState() == 9;
- }
- public boolean showSelectWorldTab(){
- WidgetChild WST = Widgets.get(906, 28);
- WST.click(true);
- Time.sleep(Random.nextInt(100, 300));
- return true;
- }
- public boolean worldOnScreen (int world){
- int worldID = WorldToID(world);
- WidgetChild w = Widgets.get(910,77).getChildren()[worldID];
- Rectangle screen = new Rectangle(70,137,612,297);
- int yP = w.getAbsoluteY();
- Rectangle WorldRect = new Rectangle(150,yP, w.getWidth() - 200, w.getHeight());
- return screen.contains(WorldRect);
- }
- public boolean selectWorld (int world, boolean DragScroll){
- if (isAtLobby() && !loginErrorVisible() && !isLoggingIn()){
- if (areFavouritWorldsSelected()){
- removeFavouritedWorlds();
- }
- int worldID = WorldToID(world);
- if (worldID != -1){
- WidgetChild w = Widgets.get(910,77).getChildren()[worldID];
- WidgetChild s = Widgets.get(910, 86).getChildren()[1];
- int worldPos = w.getRelativeY();
- int worldScrollPos = (int)((worldPos) / 8.4);
- int scrollPos = s.getRelativeY();
- Timer safeTimer = new Timer(30000);
- if (DragScroll){
- if (!worldOnScreen(world)){
- scrollPos = s.getRelativeY();
- int scrollOffset = Random.nextInt(2, s.getHeight() - 3);
- Point StartPt = new Point(Random.nextInt(s.getAbsoluteX() + 2,s.getAbsoluteX() + s.getWidth() - 4), s.getAbsoluteY() + scrollOffset);
- Point EndPoint = new Point(Random.nextInt(s.getAbsoluteX() + 2,s.getAbsoluteX() + s.getWidth() - 4), Widgets.get(910, 86).getAbsoluteY() + worldScrollPos + scrollOffset + Random.nextInt(-4, -1));
- Time.sleep(Random.nextInt(20, 200));
- Mouse.move(StartPt);
- //Mouse.drag(EndPoint.x - StartPt.x, EndPoint.y - StartPt.y);
- Mouse.drag(EndPoint);
- Time.sleep(Random.nextInt(20, 200));
- }
- } else {
- if (worldScrollPos > scrollPos){
- while (!worldOnScreen(world) && scrollPos < 247 && safeTimer.isRunning() && !loginErrorVisible() && !isLoggingIn()) {
- scrollPos = Widgets.get(910, 86).getChildren()[1].getRelativeY();
- Mouse.move((Widgets.get(910, 86).getChildren()[5]).getCentralPoint().x, (Widgets.get(910, 86).getChildren()[5]).getCentralPoint().y, (Widgets.get(910, 86).getChildren()[5]).getWidth()/2, (Widgets.get(910, 86).getChildren()[5]).getHeight()/2);
- Mouse.hold(Random.nextInt(200, 600), true);
- }
- }else {
- while (!worldOnScreen(world) && scrollPos > 16 && safeTimer.isRunning() && !loginErrorVisible() && !isLoggingIn()){
- scrollPos = Widgets.get(910, 86).getChildren()[1].getRelativeY();
- Mouse.move((Widgets.get(910, 86).getChildren()[4]).getCentralPoint().x, (Widgets.get(910, 86).getChildren()[4]).getCentralPoint().y, (Widgets.get(910, 86).getChildren()[4]).getWidth()/2, (Widgets.get(910, 86).getChildren()[4]).getHeight()/2);
- Mouse.hold(Random.nextInt(200, 600), true);
- }
- }
- }
- WidgetChild worldBox = Widgets.get(910, 62);
- w = Widgets.get(910,77).getChildren()[worldID];
- Rectangle screen = worldBox.getBoundingRectangle();
- Point worldPt = new Point(Random.nextInt(100, w.getWidth()/2),(w.getAbsoluteY() + Random.nextInt(1, w.getHeight() - 3)));
- if (screen.contains(worldPt)){
- //Mouse.move(worldPt.x, worldPt.y);
- //Time.sleep(Random.nextInt(300, 500));
- //Mouse.click(true);
- Mouse.click(worldPt, true);
- String currentWorld = Widgets.get(910,11).getText();
- if (currentWorld.endsWith(String.valueOf(world))){
- return true;
- } else {
- return false;
- }
- }else {
- return false;
- }
- } else {
- return false;
- }
- }
- return false;
- }
- public int getCurrentWorld(){
- String currentWorld = Widgets.get(910,11).getText();
- return Integer.parseInt(currentWorld.substring(6));
- }
- public int WorldToID (int world){
- WidgetChild worlds[] = Widgets.get(910, 69).getChildren();
- for (WidgetChild w : worlds){
- if (Integer.decode(w.getText()) == world){
- return w.getIndex();
- }
- }
- return -1;
- }
- public int idToWorld (int id){
- WidgetChild worlds[] = Widgets.get(910, 69).getChildren();
- if (worlds.length > id ){
- return Integer.parseInt(worlds[id].getText());
- } else {
- return -1;
- }
- }
- }
- public class RuniteMinerGUI extends JFrame {
- private static final long serialVersionUID = 1L;
- private boolean uptodate = true;
- @Override
- public void paint(Graphics g) {
- super.paintComponents(g);
- g.drawString("Current Version: " + currentVerstion, 5, 310);
- g.drawString("Latest Version: " + latestVerstion, 130, 310);
- if (uptodate){
- g.setColor(Color.green);
- } else {
- g.setColor(Color.red);
- }
- g.drawString(verstionMessage, 246, 310);
- }
- public RuniteMinerGUI() {
- getVerionInfo();
- initComponents();
- //LoadSettings();
- }
- private void thisWindowClosing(WindowEvent e) {
- gui.dispose();
- }
- private void CbRuniteOreStateChanged(ChangeEvent e) {
- mineRunite = CbRuniteOre.isSelected();
- }
- private void CbAddOreStateChanged(ChangeEvent e) {
- mineAdd = CbAddOre.isSelected();
- }
- private void CbMithOreStateChanged(ChangeEvent e) {
- mineMith = CbMithOre.isSelected();
- }
- private void CbMemWorldStateChanged(ChangeEvent e) {
- memb = CbMemWorld.isSelected();
- }
- private void CbHighRiskWorldStateChanged(ChangeEvent e) {
- highRisk = CbHighRiskWorld.isSelected();
- }
- private void CbWorldHopStateChanged(ChangeEvent e) {
- worldHop = !CbWorldHop.isSelected();
- }
- private void CbSkillWorldsStateChanged(ChangeEvent e) {
- skillWorlds = CbSkillWorlds.isSelected();
- }
- private void thisMouseClicked(MouseEvent e) {
- if (e.getY() >= 230){
- openUrl("http://www.powerbot.org/community/topic/679105-runite-miner-world-hops-banks-resource-dungeon/");
- }
- }
- private void CbPoliteModeStateChanged(ChangeEvent e) {
- politeMode = CbPoliteMode.isSelected();
- }
- private void CbClickLessItemStateChanged(ItemEvent e) {
- clickLess = CbClickLess.isSelected();
- }
- private void CbFreeWorldItemStateChanged(ItemEvent e) {
- useFreeWorlds = CbFreeWorld.isSelected();
- }
- private void cbRockPredictionStateChanged(ChangeEvent e) {
- rockPrediction = cbRockPrediction.isSelected();
- }
- private void cbCutGemsStateChanged(ChangeEvent e) {
- cutGems = cbCutGems.isSelected();
- }
- private void cbTopGemDropItemStateChanged(ItemEvent e) {
- if (cbTopGemDrop.getSelectedItem().toString() == "Sapphire"){
- topGemToDrop = Gems.SAPPHIRE.getRank();
- } else if (cbTopGemDrop.getSelectedItem().toString() == "Emerald"){
- topGemToDrop = Gems.EMERALD.getRank();
- } else if (cbTopGemDrop.getSelectedItem().toString() == "Ruby"){
- topGemToDrop = Gems.RUBY.getRank();
- } else if (cbTopGemDrop.getSelectedItem().toString() == "Diamond"){
- topGemToDrop = Gems.DIAMOND.getRank();
- } else if (cbTopGemDrop.getSelectedItem().toString() == "Dragonstone"){
- topGemToDrop = Gems.DRAGONSTONE.getRank();
- } else if (cbTopGemDrop.getSelectedItem().toString() == "Onyx"){
- topGemToDrop = Gems.ONYX.getRank();
- } else if (cbTopGemDrop.getSelectedItem().toString() == "Top gem to drop"){
- topGemToDrop = 0;
- }
- }
- private void BnStartMouseClicked(MouseEvent e) {
- //SaveSettings();
- pin[0] = (Integer) SPin1.getValue();
- pin[1] = (Integer) SPin2.getValue();
- pin[2] = (Integer) SPin3.getValue();
- pin[3] = (Integer) SPin4.getValue();
- startTime = System.currentTimeMillis();
- runPerCent = Random.nextInt(60, 80);
- final MineRicks minerocks = new MineRicks();
- final LobbyDetection lobbydetection = new LobbyDetection();
- final SwitchWorld switchworld = new SwitchWorld();
- final MembDetection membdetection = new MembDetection();
- final HightRiskWorld highriskworld = new HightRiskWorld();
- final LeaveDung leavedung = new LeaveDung();
- final LeaveMine leaveMine = new LeaveMine();
- final WalkToBank walktobank = new WalkToBank();
- final UseBank usebank = new UseBank();
- final WalkToMine walktomine = new WalkToMine();
- final EnterMine entermine = new EnterMine();
- final EnterDung enterdung = new EnterDung();
- final Antiban antiban = new Antiban();
- final ActivateRun activaterun = new ActivateRun();
- final CamerSetPitch camerasetpitch = new CamerSetPitch();
- final Resting resting = new Resting();
- final CloseLoginError closeloginerror = new CloseLoginError();
- final InventorySelect inventoryselect = new InventorySelect();
- final RunIntoMine runintomine = new RunIntoMine();
- final ClearLastClickTile clearlastclicktile = new ClearLastClickTile();
- final CloseMayMadness closemaymadness = new CloseMayMadness();
- final MouseHover mousehover = new MouseHover();
- final enterBankPin enterbankpin = new enterBankPin();
- final RockChanged rockchanged = new RockChanged();
- final UpdateWorldPop updateworldpop = new UpdateWorldPop();
- final CutGems cutgems = new CutGems();
- final DropGems dropgems = new DropGems();
- final Strategy MineRocksStrategy = new Strategy(minerocks,minerocks);
- final Strategy LobbyDetectionStrategy = new Strategy(lobbydetection,lobbydetection);
- final Strategy SwitchWorldStrategy = new Strategy(switchworld,switchworld);
- final Strategy MembDetectionStrategy = new Strategy(membdetection,membdetection);
- final Strategy HighRiskWorldStrategy = new Strategy(highriskworld,highriskworld);
- final Strategy LeaveDungStrategy = new Strategy(leavedung,leavedung);
- final Strategy LeaveMineStrategy = new Strategy(leaveMine,leaveMine);
- final Strategy WalkToBankStrategy = new Strategy(walktobank,walktobank);
- final Strategy UseBankStrategy = new Strategy(usebank,usebank);
- final Strategy WalkToMineStrategy = new Strategy(walktomine,walktomine);
- final Strategy EnterMineStrategy = new Strategy(entermine,entermine);
- final Strategy EnterDungStrategy = new Strategy(enterdung,enterdung);
- final Strategy AntibanStrategy = new Strategy(antiban,antiban);
- final Strategy ActivateRunStrategy = new Strategy(activaterun,activaterun);
- final Strategy CameraSetPitchStrategy = new Strategy(camerasetpitch,camerasetpitch);
- final Strategy RestingStrategy = new Strategy(resting,resting);
- final Strategy CloseLoginErrorStrategy = new Strategy(closeloginerror,closeloginerror);
- final Strategy InventorySelectStrategy = new Strategy(inventoryselect,inventoryselect);
- final Strategy RunIntoMineStrategy = new Strategy (runintomine,runintomine);
- final Strategy ClearLastClickTileStrategy = new Strategy(clearlastclicktile,clearlastclicktile);
- final Strategy CloseMayMadnessStrategy = new Strategy(closemaymadness,closemaymadness);
- final Strategy MouseHoverStrategy = new Strategy(mousehover,mousehover);
- final Strategy EnterBankPinStrategy = new Strategy(enterbankpin,enterbankpin);
- final Strategy RockChangedStrategy = new Strategy(rockchanged,rockchanged);
- final Strategy UpdateWorldPopStrategy = new Strategy(updateworldpop,updateworldpop);
- final Strategy CutGemsStrategy = new Strategy(cutgems,cutgems);
- final Strategy DropGemsStrategy = new Strategy(dropgems,dropgems);
- provide(CutGemsStrategy);
- provide(DropGemsStrategy);
- provide(UpdateWorldPopStrategy);
- provide(EnterBankPinStrategy);
- provide(RockChangedStrategy);
- provide(CloseMayMadnessStrategy);
- provide(ClearLastClickTileStrategy);
- provide(RunIntoMineStrategy);
- provide(InventorySelectStrategy);
- provide(CloseLoginErrorStrategy);
- provide(RestingStrategy);
- provide(ActivateRunStrategy);
- provide(AntibanStrategy);
- provide(EnterDungStrategy);
- provide(EnterMineStrategy);
- provide(WalkToMineStrategy);
- provide(UseBankStrategy);
- provide(WalkToBankStrategy);
- provide(LeaveMineStrategy);
- provide(LeaveDungStrategy);
- provide(HighRiskWorldStrategy);
- provide(MembDetectionStrategy);
- provide(LobbyDetectionStrategy);
- provide(SwitchWorldStrategy);
- provide(MineRocksStrategy);
- provide(MouseHoverStrategy);
- provide(CameraSetPitchStrategy);
- gui.setVisible(false);
- gui.dispose();
- }
- private void SaveSettings(){
- Properties propOut = new Properties();
- File file = new File("./RuneMiner.Settings");
- if(file.exists()) {
- file.delete();
- }
- FileOutputStream fos;
- try {
- fos = new FileOutputStream("./RuneMiner.Settings");
- propOut.setProperty("runite", ""+CbRuniteOre.isSelected());
- propOut.setProperty("addy", ""+CbAddOre.isSelected());
- propOut.setProperty("mith", ""+CbMithOre.isSelected());
- propOut.setProperty("free", ""+CbFreeWorld.isSelected());
- propOut.setProperty("risk", ""+CbHighRiskWorld.isSelected());
- propOut.setProperty("total", ""+CbSkillWorlds.isSelected());
- propOut.setProperty("hop", ""+CbWorldHop.isSelected());
- propOut.setProperty("polite", ""+CbPoliteMode.isSelected());
- propOut.setProperty("less", ""+CbClickLess.isSelected());
- propOut.store(fos, "RuniteMiner");
- } catch (FileNotFoundException e1) {
- } catch (IOException e) {
- }
- }
- private void LoadSettings(){
- Properties propIn = new Properties();
- FileInputStream fis;
- try {
- fis = new FileInputStream("./RuneMiner.Settings");
- propIn.load(fis);
- CbRuniteOre.setSelected(Boolean.parseBoolean(propIn.getProperty("runite")));
- CbAddOre.setSelected(Boolean.parseBoolean(propIn.getProperty("addy")));
- CbMithOre.setSelected(Boolean.parseBoolean(propIn.getProperty("mith")));
- CbFreeWorld.setSelected(Boolean.parseBoolean(propIn.getProperty("free")));
- CbHighRiskWorld.setSelected(Boolean.parseBoolean(propIn.getProperty("risk")));
- CbSkillWorlds.setSelected(Boolean.parseBoolean(propIn.getProperty("total")));
- CbWorldHop.setSelected(Boolean.parseBoolean(propIn.getProperty("hop")));
- CbPoliteMode.setSelected(Boolean.parseBoolean(propIn.getProperty("polite")));
- CbClickLess.setSelected(Boolean.parseBoolean(propIn.getProperty("less")));
- fis.close();
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- }
- }
- private void openUrl(String url) {
- URI uri = null;
- try {
- uri = new URI(url);
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- if (Desktop.isDesktopSupported()) {
- try {
- Desktop.getDesktop().browse(uri);
- } catch (IOException e) { log.info(e.getMessage()); }
- } else { log.info("Hyperlink error");}
- }
- private void getVerionInfo(){
- try {
- final URL url = new URL(
- "http://hogrog.webatu.com/index.html");
- final BufferedReader in = new BufferedReader(new InputStreamReader(
- url.openStream()));
- String input;
- input = in.readLine();
- try
- {
- float v = Float.valueOf(input.trim()).floatValue();
- latestVerstion = v;
- if (currentVerstion == latestVerstion){
- verstionMessage = "Script Up To Date";
- uptodate = true;
- } else {
- verstionMessage = "Update available CLICK HERE";
- uptodate = false;
- }
- }
- catch (NumberFormatException nfe)
- {
- verstionMessage = "Version data unavailable";
- uptodate = false;
- }
- } catch (Exception e) {
- verstionMessage = "Version data unavailable";
- uptodate = false;
- }
- }
- private void initComponents() {
- panel3 = new JPanel();
- CbRuniteOre = new JCheckBox();
- CbAddOre = new JCheckBox();
- CbMithOre = new JCheckBox();
- panel4 = new JPanel();
- CbFreeWorld = new JCheckBox();
- CbMemWorld = new JCheckBox();
- CbHighRiskWorld = new JCheckBox();
- CbSkillWorlds = new JCheckBox();
- CbWorldHop = new JCheckBox();
- CbPoliteMode = new JCheckBox();
- CbClickLess = new JCheckBox();
- cbRockPrediction = new JCheckBox();
- BnStart = new JButton();
- panel5 = new JPanel();
- SPin1 = new JSpinner();
- SPin2 = new JSpinner();
- SPin3 = new JSpinner();
- SPin4 = new JSpinner();
- panel1 = new JPanel();
- cbCutGems = new JCheckBox();
- cbTopGemDrop = new JComboBox();
- //======== this ========
- setTitle("Runite Miner GUI");
- setResizable(false);
- setAlwaysOnTop(true);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- thisWindowClosing(e);
- }
- });
- addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- thisMouseClicked(e);
- }
- });
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //======== panel3 ========
- {
- panel3.setBorder(new TitledBorder("Select Rocks To Mine"));
- // JFormDesigner evaluation mark
- panel3.setBorder(new javax.swing.border.CompoundBorder(
- new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
- "", javax.swing.border.TitledBorder.CENTER,
- javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
- java.awt.Color.red), panel3.getBorder())); panel3.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
- panel3.setLayout(null);
- //---- CbRuniteOre ----
- CbRuniteOre.setText("Runite");
- CbRuniteOre.setSelected(true);
- CbRuniteOre.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbRuniteOreStateChanged(e);
- }
- });
- panel3.add(CbRuniteOre);
- CbRuniteOre.setBounds(6, 20, 133, CbRuniteOre.getPreferredSize().height);
- //---- CbAddOre ----
- CbAddOre.setText("Adamant");
- CbAddOre.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbAddOreStateChanged(e);
- }
- });
- panel3.add(CbAddOre);
- CbAddOre.setBounds(6, 43, 133, CbAddOre.getPreferredSize().height);
- //---- CbMithOre ----
- CbMithOre.setText("Mithril");
- CbMithOre.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbMithOreStateChanged(e);
- }
- });
- panel3.add(CbMithOre);
- CbMithOre.setBounds(6, 66, 133, CbMithOre.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel3.getComponentCount(); i++) {
- Rectangle bounds = panel3.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = panel3.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel3.setMinimumSize(preferredSize);
- panel3.setPreferredSize(preferredSize);
- }
- }
- contentPane.add(panel3);
- panel3.setBounds(200, 10, 175, 105);
- //======== panel4 ========
- {
- panel4.setLayout(null);
- //---- CbFreeWorld ----
- CbFreeWorld.setText("Use Free Worlds");
- CbFreeWorld.setToolTipText("Check this option to use non members worlds.");
- CbFreeWorld.setSelected(true);
- CbFreeWorld.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- CbFreeWorldItemStateChanged(e);
- }
- });
- panel4.add(CbFreeWorld);
- CbFreeWorld.setBounds(0, 0, 170, CbFreeWorld.getPreferredSize().height);
- //---- CbMemWorld ----
- CbMemWorld.setText("Use Members Worlds");
- CbMemWorld.setToolTipText("If this is checked the bot will try to login to members servers");
- CbMemWorld.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbMemWorldStateChanged(e);
- }
- });
- panel4.add(CbMemWorld);
- CbMemWorld.setBounds(0, 23, 170, CbMemWorld.getPreferredSize().height);
- //---- CbHighRiskWorld ----
- CbHighRiskWorld.setText("Use High Risk Worlds");
- CbHighRiskWorld.setToolTipText("If this option is checked the bot will login to high ridk wilderness worlds");
- CbHighRiskWorld.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbHighRiskWorldStateChanged(e);
- }
- });
- panel4.add(CbHighRiskWorld);
- CbHighRiskWorld.setBounds(0, 46, 170, CbHighRiskWorld.getPreferredSize().height);
- //---- CbSkillWorlds ----
- CbSkillWorlds.setText("Use Skill Worlds");
- CbSkillWorlds.setToolTipText("Check this if you have a level over 1500 and the script will use the skill worlds");
- CbSkillWorlds.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbSkillWorldsStateChanged(e);
- }
- });
- panel4.add(CbSkillWorlds);
- CbSkillWorlds.setBounds(0, 69, 170, CbSkillWorlds.getPreferredSize().height);
- //---- CbWorldHop ----
- CbWorldHop.setText("Don't World Hop");
- CbWorldHop.setToolTipText("Check this if you only want to mine in one world");
- CbWorldHop.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbWorldHopStateChanged(e);
- }
- });
- panel4.add(CbWorldHop);
- CbWorldHop.setBounds(0, 92, 170, CbWorldHop.getPreferredSize().height);
- //---- CbPoliteMode ----
- CbPoliteMode.setText("Polite Mode");
- CbPoliteMode.setToolTipText("The bot will avoid stealing rocks where posible");
- CbPoliteMode.setSelected(true);
- CbPoliteMode.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CbPoliteModeStateChanged(e);
- }
- });
- panel4.add(CbPoliteMode);
- CbPoliteMode.setBounds(0, 115, 170, CbPoliteMode.getPreferredSize().height);
- //---- CbClickLess ----
- CbClickLess.setText("Click Less");
- CbClickLess.setToolTipText("Reduces rock detection sensetivity");
- CbClickLess.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- CbClickLessItemStateChanged(e);
- }
- });
- panel4.add(CbClickLess);
- CbClickLess.setBounds(0, 138, 170, CbClickLess.getPreferredSize().height);
- //---- cbRockPrediction ----
- cbRockPrediction.setText("Next Rock Prediction");
- cbRockPrediction.setToolTipText("When no rocks are availible it will run to the next rock to respawn");
- cbRockPrediction.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- cbRockPredictionStateChanged(e);
- }
- });
- panel4.add(cbRockPrediction);
- cbRockPrediction.setBounds(0, 161, 170, CbClickLess.getPreferredSize().height);
- //---- BnStart ----
- BnStart.setText("Start");
- BnStart.setToolTipText("Start the bot");
- BnStart.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- BnStartMouseClicked(e);
- BnStartMouseClicked(e);
- }
- });
- panel4.add(BnStart);
- BnStart.setBounds(0, 184, 170, BnStart.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel4.getComponentCount(); i++) {
- Rectangle bounds = panel4.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = panel4.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel4.setMinimumSize(preferredSize);
- panel4.setPreferredSize(preferredSize);
- }
- }
- contentPane.add(panel4);
- panel4.setBounds(15, 10, 170, 220);
- //======== panel5 ========
- {
- panel5.setBorder(new TitledBorder("Bank Pin"));
- panel5.setToolTipText("Set to -1 for no pin");
- panel5.setLayout(null);
- //---- SPin1 ----
- SPin1.setModel(new SpinnerNumberModel(-1, -1, 9, 1));
- SPin1.setToolTipText("Pin digit 1 (-1 = no pin)");
- panel5.add(SPin1);
- SPin1.setBounds(10, 20, 35, SPin1.getPreferredSize().height);
- //---- SPin2 ----
- SPin2.setModel(new SpinnerNumberModel(-1, -1, 9, 1));
- SPin2.setToolTipText("Pin digit 2 (-1 = no pin)");
- panel5.add(SPin2);
- SPin2.setBounds(50, 20, 35, 20);
- //---- SPin3 ----
- SPin3.setModel(new SpinnerNumberModel(-1, -1, 9, 1));
- SPin3.setToolTipText("Pin digit 3 (-1 = no pin)");
- panel5.add(SPin3);
- SPin3.setBounds(90, 20, 35, 20);
- //---- SPin4 ----
- SPin4.setModel(new SpinnerNumberModel(-1, -1, 9, 1));
- SPin4.setToolTipText("Pin digit 4 (-1 = no pin)");
- panel5.add(SPin4);
- SPin4.setBounds(130, 20, 35, 20);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel5.getComponentCount(); i++) {
- Rectangle bounds = panel5.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = panel5.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel5.setMinimumSize(preferredSize);
- panel5.setPreferredSize(preferredSize);
- }
- }
- contentPane.add(panel5);
- panel5.setBounds(200, 120, 175, 60);
- //======== panel1 ========
- {
- panel1.setBorder(new TitledBorder("Gems"));
- panel1.setLayout(null);
- //---- cbCutGems ----
- cbCutGems.setText("Cut Gems");
- cbCutGems.setToolTipText("Cut gems in you inventory");
- cbCutGems.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- cbCutGemsStateChanged(e);
- }
- });
- panel1.add(cbCutGems);
- cbCutGems.setBounds(15, 20, 135, cbCutGems.getPreferredSize().height);
- //---- cbTopGemDrop ----
- cbTopGemDrop.setToolTipText("Drop gems upto and including the selected gem");
- cbTopGemDrop.setModel(new DefaultComboBoxModel(new String[] {
- "Top gem to drop",
- "Sapphire",
- "Emerald",
- "Ruby",
- "Diamond",
- "Dragonstone",
- "Onyx"
- }));
- cbTopGemDrop.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- cbTopGemDropItemStateChanged(e);
- }
- });
- panel1.add(cbTopGemDrop);
- cbTopGemDrop.setBounds(15, 45, 125, cbTopGemDrop.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel1.getComponentCount(); i++) {
- Rectangle bounds = panel1.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = panel1.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel1.setMinimumSize(preferredSize);
- panel1.setPreferredSize(preferredSize);
- }
- }
- contentPane.add(panel1);
- panel1.setBounds(205, 185, 165, 80);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- Dimension d = new Dimension(415,310);
- contentPane.setMinimumSize(d);
- contentPane.setPreferredSize(d);
- }
- pack();
- setLocationRelativeTo(getOwner());
- }
- private JPanel panel3;
- private JCheckBox CbRuniteOre;
- private JCheckBox CbAddOre;
- private JCheckBox CbMithOre;
- private JPanel panel4;
- private JCheckBox CbFreeWorld;
- private JCheckBox CbMemWorld;
- private JCheckBox CbHighRiskWorld;
- private JCheckBox CbSkillWorlds;
- private JCheckBox CbWorldHop;
- private JCheckBox CbPoliteMode;
- private JCheckBox CbClickLess;
- private JCheckBox cbRockPrediction;
- private JButton BnStart;
- private JPanel panel5;
- private JSpinner SPin1;
- private JSpinner SPin2;
- private JSpinner SPin3;
- private JSpinner SPin4;
- private JPanel panel1;
- private JCheckBox cbCutGems;
- private JComboBox cbTopGemDrop;
- }
- public enum Rock {
- RUNE,
- ADDY,
- MITH;
- }
- public enum Gem {
- SAPPHIRE,
- EMERALD,
- RUBY,
- DIAMOND,
- DRAGONSTONE,
- ONYX;
- }
- public enum Rocks {
- MITH1(Rock.MITH, new Tile(1049,4520,0), 32439, 33401),
- MITH2(Rock.MITH, new Tile(1061,4515,0), 32440, 33402),
- MITH3(Rock.MITH, new Tile(1061,4513,0), 32440, 33402),
- MITH4(Rock.MITH, new Tile(1061,4511,0), 32439, 33401),
- MITH5(Rock.MITH, new Tile(1059,4510,0), 32438, 33400),
- MITH6(Rock.MITH, new Tile(1058,4511,0), 32440, 33402),
- MITH7(Rock.MITH, new Tile(1057,4511,0), 32439, 33401),
- MITH8(Rock.MITH, new Tile(1058,4514,0), 32439, 33401),
- ADDY1(Rock.ADDY, new Tile(1050,4514,0), 32437, 33402),
- ADDY2(Rock.ADDY, new Tile(1049,4513,0), 32436, 33401),
- ADDY3(Rock.ADDY, new Tile(1051,4512,0), 32437, 33402),
- ADDY4(Rock.ADDY, new Tile(1051,4510,0), 32435, 33400),
- RUNE1(Rock.RUNE, new Tile(1051,4516,0), 33078, 33400),
- RUNE2(Rock.RUNE, new Tile(1060,4516,0), 33078, 33400),
- RUNE3(Rock.RUNE, new Tile(1052,4510,0), 33079, 33401)
- ;
- private Rocks(Rock type, Tile location, int upID, int downID) {
- this.type = type;
- this.location = location;
- this.upID = upID;
- this.downID = downID;
- }
- private final Rock type;
- private final Tile location;
- private final int upID;
- private final int downID;
- public Rock getType() {
- return type;
- }
- public Tile getLocation() {
- return location;
- }
- public int getUpID() {
- return upID;
- }
- public int getDownID() {
- return downID;
- }
- }
- public enum Gems {
- SAPPHIRE(Gem.SAPPHIRE, 1623, 20, 1, 1607),
- EMERALD(Gem.EMERALD, 1621, 27, 2, 1605),
- RUBY(Gem.RUBY, 1619, 34, 3, 1603),
- DIAMOND(Gem.DIAMOND, 1617, 43, 4, 1601),
- DRAGONSTONE(Gem.DRAGONSTONE, 1631, 55, 5, 1615),
- ONYX(Gem.ONYX, 6571, 67, 6, 6573)
- ;
- private Gems(Gem type, int ID, int LVL, int rank, int cutID) {
- this.cutID = cutID;
- this.type = type;
- this.ID = ID;
- this.LVL = LVL;
- this.rank = rank;
- }
- private final int[] allIDs = {1623,1621, 1619,1617,1631,6571};
- private final int[] allCutIDs = {1607, 1605, 1603, 1601, 1615, 6573};
- private final Gem type;
- private final int ID;
- private final int LVL;
- private final int rank;
- private final int cutID;
- public int[] getAllCutIDs(){
- return allCutIDs;
- }
- public int[] getAllIDs(){
- return allIDs;
- }
- public int getRank(){
- return rank;
- }
- public int getCutID(){
- return cutID;
- }
- public Gem getType() {
- return type;
- }
- public int getID() {
- return ID;
- }
- public int getLVL(){
- return LVL;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement