Advertisement
asciicat

ironPickUp.java Iron Ore Looter 2.61

Jun 17th, 2011
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 80.51 KB | None | 0 0
  1. //http://www.mediafire.com/?q8njoooq842mnts
  2. // <editor-fold defaultstate="collapsed" desc="Imports">
  3. import org.rsbot.script.*;
  4. import org.rsbot.script.methods.GrandExchange.GEItem;
  5. import org.rsbot.script.wrappers.*;
  6. import org.rsbot.script.methods.*;
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.Script;
  9. import org.rsbot.Configuration;
  10.  
  11. import java.awt.*;
  12. import java.awt.Graphics;
  13. import java.awt.image.BufferedImage;
  14. import java.awt.event.MouseEvent;
  15. import java.awt.event.MouseListener;
  16.  
  17.  
  18. import javax.imageio.ImageIO;
  19.  
  20. import java.io.BufferedReader;
  21. import java.io.InputStreamReader;
  22. import java.io.PrintWriter;
  23. import java.io.IOException;
  24.  
  25. import java.util.regex.Matcher;
  26. import java.util.regex.Pattern;
  27.  
  28. import java.net.InetAddress;
  29. import java.net.InetSocketAddress;
  30. import java.net.Socket;
  31. import java.net.SocketAddress;
  32. import java.net.MalformedURLException;
  33. import java.net.URL;// </editor-fold>
  34.  
  35. @ScriptManifest(authors = {"Dew/Deww1"}, keywords = {"iron", "Rimmington", "coal", "Guild Mine"}, name = "Iron Picker Uper", description = "Picks up Iron ore from powerminers in Rimmington Mines", version = 2.61, website = "http://www.dewbots.org/")
  36. public class ironPickUp extends Script implements PaintListener, MouseListener {
  37.  
  38.     //<editor-fold defaultstate="collapsed" desc="Variables">
  39.     private final int ORE[] = {440, 453};
  40.     private final int BANK[] = {36788, 11758};
  41.     private final int LADDER[] = {2113, 6226};
  42.  
  43.     RSObject BANK12;
  44.  
  45.     public int invCount = 0;
  46.     public int oree;
  47.     public int switches = 0;
  48.     public int OreCollected = 0;
  49.     /*
  50.      * Area ID: 0 = None
  51.      * Area ID: 1 = Rimmington Mines
  52.      * Area ID: 2 = Guild Mines
  53.      */
  54.     public int areaID = 0; //area ID
  55.    
  56.     private int mouseHopx;
  57.     private int mouseHopy;
  58.     private int oreCollected = 0;
  59.     private int oreHr = 0;
  60.     private int price = 0;
  61.     private int priceHr = 0;
  62.     public int orePrice;
  63.  
  64.     private Double ver = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
  65.  
  66.     private String status = "Setting up";
  67.     private String MouseSpeed = "Unknown";
  68.  
  69.     public String status$ = "";
  70.     public String antiBanStatus = "Setting up";
  71.     public String cursorU;//Cursor unclicked
  72.     public String cursorC;//Cursor clicked
  73.     public String area = "";
  74.  
  75.     boolean showPaint1 = false; //close Paint
  76.     boolean showPaint2 = true; //General tab
  77.     boolean showPaint3 = false; //money tab
  78.     Point p;
  79.  
  80.     public boolean isDoingAnti = false;
  81.     public boolean hasStarted = false;
  82.     public boolean takeBreaks = false;
  83.  
  84.     ipuAntiban antiban = new ipuAntiban();
  85.     hopper hop = new hopper();
  86.     ipuGUI gui = new ipuGUI();
  87.  
  88.     public long startTime = 0;
  89.     public long millis = 0;
  90.     public long hours = 0;
  91.     public long minutes = 0;
  92.     public long seconds = 0;
  93.     public long last = 0;
  94.     public long noOreTime;
  95.     public long millis2 = 0;
  96.     public long minutes2 = 0;
  97.     public long seconds2 = 0;
  98.  
  99.     BufferedImage normal = null;
  100.     BufferedImage clicked = null;
  101.  
  102.     Rectangle hide = new Rectangle(6, 312, 75, 24); //hide paint button
  103.     Rectangle genTab = new Rectangle(446, 313, 70, 24); //general tab button
  104.     Rectangle monTab = new Rectangle(376, 315, 68, 23); //money tab button
  105.  
  106.     private org.rsbot.script.util.Timer timer = new org.rsbot.script.util.Timer(1000 * 30 * 8); //4 mins
  107.     private org.rsbot.script.util.Timer GUITimer = new org.rsbot.script.util.Timer(1000); //1 sec
  108.  
  109.     //GUI Stuff
  110.     public boolean useMsRandom = false; //use Mouse Random
  111.     public boolean doUpdate = false; //check for updates
  112.     public boolean wHop = false; //world hop
  113.     public boolean shot = false; //screenshot at end?
  114.     public boolean devMode = false; //development(debug) mode - display all logs
  115.     public int maxPastWorlds = 10, maxPing = 150, //for worldswitcher
  116.             currentWorld = 0, newWorld = 0, hopped = 0, skillTotal = 0, wSwitches = 0;
  117.     public int pastWorld[] = new int[maxPastWorlds];
  118.     public boolean worldHopping = false;
  119.     public long switchTime = 0;
  120.     //</editor-fold>
  121.  
  122.     //<editor-fold defaultstate="collapsed" desc="Walking/Area">
  123.     RSTile mineTile = new RSTile(2970, 3240);
  124.     RSTile bankTile = new RSTile(3012, 3355);
  125.    
  126.     RSTile[] toBank = new RSTile[]{
  127.                         new RSTile(2969, 3239),
  128.                         new RSTile(2975, 3244),
  129.                         new RSTile(2983, 3253),
  130.                         new RSTile(2991, 3250),
  131.                         new RSTile(2996, 3246),
  132.                         new RSTile(3001, 3242),
  133.                         new RSTile(3007, 3240),
  134.                         new RSTile(3015, 3241),
  135.                         new RSTile(3021, 3241),
  136.                         new RSTile(3026, 3241),
  137.                         new RSTile(3030, 3236),
  138.                         new RSTile(3034, 3236),
  139.                         new RSTile(3038, 3236),
  140.                         new RSTile(3042, 3236),
  141.                         new RSTile(3046, 3236)} ;
  142.     RSTile toMine[] = new RSTile[]{
  143.                         new RSTile(3046, 3236),
  144.                         new RSTile(3042, 3236),
  145.                         new RSTile(3038, 3236),
  146.                         new RSTile(3034, 3236),
  147.                         new RSTile(3030, 3236),
  148.                         new RSTile(3026, 3241),
  149.                         new RSTile(3021, 3241),
  150.                         new RSTile(3015, 3241),
  151.                         new RSTile(3007, 3240),
  152.                         new RSTile(3001, 3242),
  153.                         new RSTile(2996, 3246),
  154.                         new RSTile(2991, 3250),
  155.                         new RSTile(2983, 3253),
  156.                         new RSTile(2975, 3244),
  157.                         new RSTile(2969, 3239) };
  158.     RSTile toLadder[] = new RSTile[] { new RSTile(3013, 3355),
  159.                 new RSTile(3013, 3359), new RSTile(3021, 3358),
  160.                 new RSTile(3024, 3352), new RSTile(3028, 3347),
  161.                 new RSTile(3029, 3341), new RSTile(3026, 3337),
  162.                 new RSTile(3021, 3339) };
  163.     RSTile toLadder0[] = new RSTile[] { new RSTile(3013, 3355),
  164.                 new RSTile(3013, 3359), new RSTile(3021, 3358),
  165.                 new RSTile(3024, 3352), new RSTile(3028, 3347),
  166.                 new RSTile(3029, 3341), new RSTile(3026, 3337),
  167.                 new RSTile(3021, 3339) };
  168.     RSTile toLadder2[] = new RSTile[] { new RSTile(3038, 9737),
  169.                 new RSTile(3032, 9738), new RSTile(3026, 9739),
  170.                 new RSTile(3021, 9739) };
  171.     RSTile toMine2[] = new RSTile[] { new RSTile(3021, 9739),
  172.                 new RSTile(3026, 9739), new RSTile(3032, 9738),
  173.                 new RSTile(3038, 9737) };
  174.     RSTile toBank2[] = new RSTile[] { new RSTile(3021, 3339),
  175.                 new RSTile(3028, 3337), new RSTile(3029, 3346),
  176.                 new RSTile(3025, 3354), new RSTile(3018, 3359),
  177.                 new RSTile(3014, 3355) };
  178.  
  179.     private boolean atBank() {
  180.         RSArea area = new RSArea(new RSTile(3043, 3234), new RSTile(3051, 3237));
  181.         return area.contains(getMyPlayer().getLocation());
  182.     }
  183.     private boolean atBank1() {
  184.         RSArea area = new RSArea(new RSTile(3008, 3352), new RSTile(3018, 3358));
  185.         return area.contains(getMyPlayer().getLocation());
  186.     }
  187.     private boolean atMine() {//rimmmington mine
  188.         RSArea area = new RSArea(new RSTile(2974, 3244), new RSTile(2965, 3235));
  189.         return area.contains(getMyPlayer().getLocation());
  190.     }
  191.     private boolean atMine1() {//guild mine
  192.         RSArea area = new RSArea(new RSTile(3026, 9734), new RSTile(3054, 9748));
  193.         return area.contains(getMyPlayer().getLocation());
  194.     }
  195.     private boolean atLadder0() {//ladder on ground zero
  196.         RSArea area = new RSArea(new RSTile(3014, 3336), new RSTile(3024, 3343));
  197.         return area.contains(getMyPlayer().getLocation());
  198.     }
  199.     private boolean atLadder1() {//ladder on ground -1
  200.         RSArea area = new RSArea(new RSTile(3017, 9737), new RSTile(3026, 9741));
  201.         return area.contains(getMyPlayer().getLocation());
  202.     }
  203.     private boolean inFally() {//check if i am on ground level in fally
  204.         RSArea area = new RSArea(new RSTile(3004,3329), new RSTile(3036,3368));
  205.         return area.contains(getMyPlayer().getLocation());
  206.     }
  207.     private boolean AtBank(String s) {
  208.         if (s == "Guild Mine") {
  209.             atBank1();
  210.             if (atBank1()) {
  211.                 return true;
  212.             }
  213.         } else if (s == "Rimmington Mines") {
  214.             atBank();
  215.             if (atBank()) {
  216.                 return true;
  217.             }
  218.         }
  219.         return false;
  220.     }
  221.     private boolean AtMine(String s) {
  222.         if (s =="Guild Mine") {
  223.             atMine1();
  224.             if (atMine1()) {
  225.                 return true;
  226.             }
  227.         } else if(s == "Rimmington Mines") {
  228.             atMine();
  229.             if (atMine()) {
  230.                 return true;
  231.             }
  232.         }
  233.         return false;
  234.     }
  235.  
  236.     private void walkToMine() {
  237.         if (area.equals("Rimmington Mines")) {
  238.             if (!AtMine(area)) {
  239.                 RSTilePath walkingMine = walking.newTilePath(toMine);
  240.                 walkingMine.randomize(random(1, 2), random(1, 2));
  241.                 walkingMine.traverse();
  242.                 antiban.antiBanCamera();
  243.                 status = "Walking to the mine...";
  244.                 sleep(random(500, 1000));
  245.                 timer.reset();
  246.                 invCount = inventory.getCount(ORE);
  247.             }
  248.         } else if (area.equals("Guild Mine")) {
  249.             if (!AtMine(area)) {
  250.                 if (!atLadder0()) {
  251.                     RSTilePath walkingMine = walking.newTilePath(toLadder);
  252.                     walkingMine.randomize(random(1,2), random(1,2));
  253.                     walkingMine.traverse();
  254.                     antiban.antiBanCamera();
  255.                     status = "Walking to the Ladder";
  256.                     sleep(random(500, 1000));
  257.                     timer.reset();
  258.                     invCount = inventory.getCount(ORE);
  259.                 }
  260.                 if (atLadder0()) {
  261.                     RSObject lad = objects.getNearest(LADDER);
  262.                     if (lad != null) {
  263.                         if (lad.isOnScreen()) {
  264.                             lad.doClick();
  265.                         } else {
  266.                             walking.walkTileMM(lad.getLocation());
  267.                         }
  268.                     } else {
  269.                         walkToMine();
  270.                     }
  271.                 }
  272.                 if (atLadder1()) {
  273.                     RSTilePath walkingMine = walking.newTilePath(toMine2);
  274.                     walkingMine.randomize(random(1,2), random(1,2));
  275.                     walkingMine.traverse();
  276.                     status = "Walking to Mine";
  277.                     sleep(random(500,1000));
  278.                     timer.reset();
  279.                     invCount = inventory.getCount(ORE);
  280.                 }
  281.             }
  282.         }
  283.     }
  284.  
  285.     private void walkToBank() {
  286.         if (area.equals("Rimmington Mines")) {
  287.             if (!AtBank(area)) {
  288.                 RSTilePath walkingBank = walking.newTilePath(toBank);
  289.                 walkingBank.randomize(random(1, 2), random(1, 2));
  290.                 walkingBank.traverse();
  291.                 antiban.antiBanCamera();
  292.                 status = "Walking to the bank...";
  293.                 sleep(random(500, 1000));
  294.                 timer.reset();
  295.             }
  296.         } else if (area.equals("Guild Mine")) {
  297.             if (!AtBank(area)) {
  298.                 if (!inFally()) {
  299.                     RSTilePath walkingMine = walking.newTilePath(toLadder2);
  300.                     walkingMine.randomize(random(1,2), random(1,2));
  301.                     walkingMine.traverse();
  302.                     antiban.antiBanCamera();
  303.                     status = "Walking to the Ladder";
  304.                     sleep(random(500, 1000));
  305.                     timer.reset();
  306.                     invCount = inventory.getCount(ORE);
  307.                 }
  308.                 if (inFally()) {
  309.                     RSTilePath walkingMine = walking.newTilePath(toBank2);
  310.                     walkingMine.randomize(random(1,2), random(1,2));
  311.                     walkingMine.traverse();
  312.                     status = "Walking to Mine";
  313.                     sleep(random(500,1000));
  314.                     timer.reset();
  315.                     invCount = inventory.getCount(ORE);
  316.                 }
  317.                 if (atLadder1()) {
  318.                     RSObject lad = objects.getNearest(LADDER);
  319.                     if (lad != null) {
  320.                         if (lad.isOnScreen()) {
  321.                             lad.doClick();
  322.                             sleep(1500, 3000);
  323.                         } else {
  324.                             walking.walkTileMM(lad.getLocation());
  325.                         }
  326.                     } else {
  327.                         walkToBank();
  328.                     }
  329.                 }
  330.             }
  331.         }
  332.     }
  333.     //</editor-fold>
  334.  
  335.     // <editor-fold defaultstate="collapsed" desc="pickup/noore stuff">
  336.     public void pickingUp() {
  337.         noOres();
  338.         if (AtMine(area) && !inventory.isFull()) {
  339.             RSGroundItem ore = groundItems.getNearest(ORE);
  340.             int randNum = random(1, 10);
  341.             if (randNum > 1) {
  342.                 if (ore != null) {
  343.                     if (ore.isOnScreen()) {
  344.                         status = "Picking up ores";
  345.                         ore.doAction("Take");
  346.                         timer.reset();
  347.                     } else {
  348.                         if (area.equals("Rimmington Mines")) {
  349.                             camera.turnTo(ore.getLocation());
  350.                         } else if (area.equals("Guild Mine")) {
  351.                             walking.walkTileMM(ore.getLocation());
  352.                         }
  353.                     }
  354.                 } else {
  355.                     noOres();
  356.                     sleep(100, 200);
  357.                 }
  358.             } else {
  359.                 antiban.antiBanCamera();
  360.             }
  361.         }
  362.     }
  363.  
  364.     private void noOres() {
  365.         RSGroundItem item = groundItems.getNearest(ORE);
  366.         if (game.isLoggedIn()) {
  367.             if (AtMine(area)) {
  368.                 if (item == null || !item.isOnScreen() || item == null && !item.isOnScreen()) {
  369.                     status = "Waiting for ores";
  370.                     antiban.antiban();
  371.                     if (!timer.isRunning()) {
  372.                         if (wHop == true) {
  373.                             hop.worldHop(false);
  374.                             timer.setEndIn(1000 * 60 * 8);
  375.                         }
  376.                     }
  377.                 }
  378.             }
  379.         }
  380.     }// </editor-fold>
  381.    
  382.     // <editor-fold defaultstate="collapsed" desc="banking">
  383.     private void banking(String loc) {
  384.         RSObject bank1 = objects.getNearest(BANK[0]); //rimmington bank
  385.         if (loc == "Rimmington Mines") {
  386.             if (AtBank(area)) {
  387.                 if (bank1 != null) {
  388.                     if (bank1.isOnScreen()) {
  389.                         bank1.doAction("Deposit");
  390.                         sleep(random(2000, 4000));
  391.                         mouse.click(349, 280, 5, 5, true);
  392.                         sleep(random(1000, 4000));
  393.                         bank.close();
  394.                     } else {
  395.                         walking.walkTileMM(bank1.getLocation(), 2);
  396.                     }
  397.                 }
  398.             }
  399.         } else if (loc == "Guild Mine") {
  400.             banking();
  401.         }
  402.     }
  403.     public int bankOpen() {
  404.         if (AtBank(area) && players.getMyPlayer().isIdle()) {
  405.             status = "Opening Bank.";
  406.             RSObject bankBooth = objects.getNearest(BANK[1]);
  407.             if (random(1, 4) > 1) {
  408.                 bankBooth.doAction("Use-quickly");
  409.             } else {
  410.                 antiban.antiban();
  411.             }
  412.         }
  413.         return random(800, 1300);
  414.     }
  415.  
  416.     public int depositBank() {
  417.         status = "Depositing ores";
  418.         bank.depositAll();
  419.         return random(300, 1100);
  420.     }
  421.  
  422.     public int bankClose() {
  423.         if (bank.isOpen()) {
  424.             status = "Closing Bank.";
  425.             bank.close();
  426.             sleep(random(200, 1000));
  427.         }
  428.         return random(300, 800);
  429.     }
  430.  
  431.     public void banking() {
  432.         if (!bank.isOpen()) {
  433.             bankOpen();
  434.             antiban.antiban();
  435.         }
  436.         if (bank.isOpen()) {
  437.             depositBank();
  438.             antiban.antiban();
  439.             sleep(random(100, 500));
  440.         }
  441.  
  442.         timer.reset();
  443.     }
  444.     // </editor-fold>
  445.  
  446.     // <editor-fold defaultstate="collapsed" desc="extras">
  447.     private void lowHP() {
  448.         combat.getHealth();
  449.         if (combat.getHealth() < 30) {
  450.             if (atBank()) {
  451.                 int rand = random(1, 2);
  452.                 if (rand == 1) {
  453.                     antiban.antiban();
  454.                 } else {
  455.                     antiban.antiBanCamera();
  456.                 }
  457.                 sleep(100, 200);
  458.             }
  459.             if (!atMine() || !atBank()) {
  460.                 walking.setRun(true);
  461.             }
  462.         }
  463.     }
  464.  
  465.     private void runCapable() {
  466.         if (takeBreaks && !walking.isRunEnabled() && walking.getEnergy() < 30) {
  467.             //TODO add resting
  468.         }
  469.         if (!walking.isRunEnabled() && walking.getEnergy() >= random(60, 80)) {
  470.             walking.setRun(true);
  471.         }
  472.     }
  473.     /**
  474.      *
  475.      * @param text the string to send
  476.      * @param dev am I using developement mode
  477.      * @param dev1 just for developement mode only
  478.      * @return true if successfully sent
  479.      */
  480.     public boolean logger(String text, boolean dev, boolean dev1) {
  481.         if (dev && dev1 || dev) {
  482.             log(Color.DARK_GRAY, "dev: "+text);
  483.             this.log(color1, p);
  484.         }
  485.         if (!dev && !dev1 || !dev1) {
  486.             log(text);
  487.         }
  488.         return false;
  489.     }
  490.     // </editor-fold>
  491.  
  492.     // <editor-fold defaultstate="collapsed" desc="OnStart">
  493.     @Override
  494.     public boolean onStart() {
  495.         while (!game.isLoggedIn()) {
  496.             //sleep(500);
  497.         }
  498.         if (!game.isFixed()) {
  499.             onFinish();
  500.             log("Please set game to fixed!");
  501.         }
  502.         cursorU = "http://i360.photobucket.com/albums/oo47/perez048/mouseReg.png";
  503.         cursorC = "http://i360.photobucket.com/albums/oo47/perez048/mouseClicked.png";
  504.         ipuGUI GUI = new ipuGUI();
  505.         GUI.setVisible(true);
  506.         while (GUI.isVisible()) {
  507.             GUITimer.setEndIn(1000);
  508.         }
  509.         log("Iron Pick Up Version: " + ver);
  510.         try {
  511.             final URL cursorURL = new URL(cursorU);
  512.             final URL cursor80URL = new URL(cursorC);
  513.             normal = ImageIO.read(cursorURL);
  514.             clicked = ImageIO.read(cursor80URL);
  515.         } catch (MalformedURLException e) {
  516.             log("Unable to buffer cursor.");
  517.         } catch (IOException e) {
  518.             log("Unable to open cursor image.");
  519.         }
  520.         startTime = System.currentTimeMillis();
  521.         shot = GUI.screenshot.isSelected();
  522.         wHop = GUI.hopper.isSelected();
  523.         useMsRandom = GUI.mousespeed.isSelected();
  524.         doUpdate = GUI.updater.isSelected();
  525.         devMode = GUI.devMode.isSelected();
  526.         log("Screenshot on end = " + shot);
  527.         log("World hopping = " + wHop);
  528.         log("Random Mouse = " + useMsRandom);
  529.         log("Check for updates = " + doUpdate);
  530.         log(Color.red, "Debug mode activated");
  531.         log("loading ore prices..... please wait");
  532.         if (GUI.locations.getSelectedItem().toString().equals("Rimmington Mines")) {
  533.             GEItem orePrice1 = grandExchange.lookup(ORE[0]);
  534.             orePrice = orePrice1.getGuidePrice();
  535.             log("Iron ore is: " + orePrice);
  536.         } else if (GUI.locations.getSelectedItem().toString().equals("Guild Mine")) {
  537.             GEItem orePrice1 = grandExchange.lookup(ORE[1]);
  538.             orePrice = orePrice1.getGuidePrice();
  539.             log("Coal ore is: " + orePrice);
  540.         }
  541.         area = GUI.locations.getSelectedItem().toString();
  542.         if (doUpdate) {
  543.             checkForUpdates();
  544.         }
  545.         return true;
  546.  
  547.     }// </editor-fold>
  548.  
  549.     // <editor-fold defaultstate="collapsed" desc="Loop">
  550.     public int loop() {
  551.         if (!AtBank(area) || !bank.isDepositOpen() || !bank.isOpen()) {
  552.             if (invCount < inventory.getCount(ORE)) {
  553.                 oreCollected++;
  554.                 invCount = inventory.getCount(ORE);
  555.             }
  556.             runCapable();
  557.             if (!AtBank(area)) {
  558.                 noOres();
  559.             }
  560.             lowHP();
  561.         }
  562.         mouseSpeed();
  563.         if (AtBank(area)) {
  564.             logger("we are at bank...", devMode, true);
  565.             if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
  566.                 logger("Inv less than 27, walking to mine...", devMode, true);
  567.                 runCapable();
  568.                 walkToMine();
  569.             }
  570.             if (bank.isDepositOpen() && bank.getBoxCount() > 1 || inventory.getCount() >= 27) {
  571.                 logger("Inv more than 26, banking", devMode, true);
  572.                 banking(area);
  573.             }
  574.         }
  575.         if (AtMine(area)) {
  576.             logger("we are at mine...", devMode, true);
  577.             if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
  578.                 logger("inv less than 27, picking up ores...", devMode, true);
  579.                 int rand = random(1, 150);
  580.                 if (rand > 3) {
  581.                     pickingUp();
  582.                 } else {
  583.                     antiban.antiBanCamera();
  584.                 }
  585.             }
  586.             if (bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
  587.                 logger("Inv more than 26, walking to bank...", devMode, true);
  588.                 runCapable();
  589.                 walkToBank();
  590.             }
  591.         }
  592.         if (!AtBank(area) || !AtMine(area)) {
  593.             logger("Not at Bank OR Mine...", devMode, true);
  594.             if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
  595.                 logger("Inv less than 27, walking to mine...", devMode, true);
  596.                 walkToMine();
  597.             }
  598.             if (bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
  599.                 logger("Inv more than 26, walking to bank...", devMode, true);
  600.                 walkToBank();
  601.             }
  602.         }
  603.         return random(1000, 1200);
  604.     }// </editor-fold>
  605.  
  606.     // <editor-fold defaultstate="collapsed" desc="onFinish">
  607.     @Override
  608.     public void onFinish() {
  609.         if (shot == true) {
  610.             env.saveScreenshot(false);
  611.         }
  612.         log("Total Ores Collected: " + oreCollected + " ores.");
  613.         if (wHop == true) {
  614.             log("Total world Hops: " + hopped);
  615.         }
  616.         log("http://www.powerbot.org/vb/showthread.php?t=770408 - my script thread. :)");
  617.     }// </editor-fold>
  618.  
  619.  
  620.     //<editor-fold defaultstate="collapsed" desc="MouseStuff">
  621.     private void mouseSpeed() {
  622.         if (useMsRandom == true) {
  623.             int rand = random(1, 5);
  624.             if (rand == 1) {
  625.                 mouse.setSpeed(random(4, 7));
  626.             }
  627.             if (rand == 2) {
  628.                 mouse.setSpeed(random(5, 10));
  629.             }
  630.             if (rand == 3) {
  631.                 mouse.setSpeed(random(2, 5));
  632.             }
  633.             if (rand == 4) {
  634.                 mouse.setSpeed(random(2, 10));
  635.             }
  636.         } else {
  637.             mouse.setSpeed(random(4, 6));
  638.         }
  639.         mouseSet();
  640.     }
  641.  
  642.     private void mouseSet() {
  643.         if (mouse.getSpeed() >= 1 && mouse.getSpeed() <= 3) {
  644.             MouseSpeed = "Extremely fast";
  645.         }
  646.         if (mouse.getSpeed() >= 4 && mouse.getSpeed() <= 6) {
  647.             MouseSpeed = "Regular";
  648.         }
  649.         if (mouse.getSpeed() >= 7 && mouse.getSpeed() <= 10) {
  650.             MouseSpeed = "Slow";
  651.         }
  652.     }
  653.     //</editor-fold>
  654.  
  655.     //<editor-fold defaultstate="collapsed" desc="antiban">
  656.     public class ipuAntiban {
  657.  
  658.         private void antiban() {
  659.         if (random(1, 2) == 1) {
  660.             antiBan1();
  661.         } else {
  662.             antiBan2();
  663.         }
  664.     }
  665.  
  666.         private void antiBan1() {
  667.         int randomProd = random(1, 40);
  668.         if (randomProd >= 2 && randomProd <= 4) {
  669.             antiBanStatus = "Pause for a few seconds...";
  670.             sleep(1000, 2500);
  671.         }
  672.         if (randomProd >= 32) {
  673.             antiBanStatus = "Moving mouse Randomly..";
  674.             mouse.moveRandomly(100, 600);
  675.         } else {
  676.             sleep(10, 30);
  677.         }
  678.     }
  679.  
  680.         public void antiBan2() {
  681.         int antiType = random(0, 1);
  682.         int b = random(0, 10);
  683.         switch (antiType) {
  684.             case 0:
  685.                 switch (b) {
  686.                     case 1:
  687.                         if (random(0, 10) == 5) {
  688.                             antiBanStatus = "Moving mouse randomly...";
  689.                             mouse.moveSlightly();
  690.                             sleep(200, 600);
  691.                             mouse.moveRandomly(150, 350);
  692.                         }
  693.                         break;
  694.                     case 2:
  695.                         if (random(0, 13) == 2) {
  696.                             antiBanStatus = "Changing camera angle...";
  697.                             camera.setAngle(random(30, 70));
  698.                             sleep(400, 1200);
  699.                         }
  700.                         break;
  701.                     case 3:
  702.                         if (random(0, 24) == 6) {
  703.                             antiBanStatus = "Moving mouse of screen...";
  704.                             mouse.moveOffScreen();
  705.                             sleep(random(600, random(1200, 2000)));
  706.                         }
  707.                         break;
  708.                     case 5:
  709.                         if (random(0, 28) == 0 && !bank.isOpen()) {
  710.                             antiBanStatus = "Checking friends list...";
  711.                             game.openTab(9);
  712.                             sleep(random(1000, 3400));
  713.                         } else if (game.getCurrentTab() != Game.TAB_INVENTORY) {
  714.                             game.openTab(4);
  715.                         }
  716.                     default:
  717.                         break;
  718.                 }
  719.             case 1:
  720.                 switch (random(0, 70)) {
  721.                     case 1:
  722.                         antiBanStatus = "Mouse hopping...";
  723.                         camera.setAngle(random(0, 90));
  724.                         sleep(500, 1000);
  725.                         if (random(1, 3) == 1) {
  726.                             mouseHopx = random(0, 760);
  727.                             mouseHopy = random(0, 500);
  728.                             mouse.hop(mouseHopx, mouseHopy);
  729.                         }
  730.                         break;
  731.                     case 2:
  732.                         antiBanStatus = "Mouse hopping...";
  733.                         camera.setAngle(random(90, 180));
  734.                         sleep(500, 1000);
  735.                         if (random(1, 3) == 1) {
  736.                             mouseHopx = random(0, 760);
  737.                             mouseHopy = random(0, 500);
  738.                             mouse.hop(mouseHopx, mouseHopy);
  739.                         }
  740.                         break;
  741.                     case 3:
  742.                         antiBanStatus = "Mouse hopping...";
  743.                         mouse.moveSlightly();
  744.                         camera.setAngle(random(90, 180));
  745.                         if (random(1, 3) == 1) {
  746.                             mouseHopx = random(0, 760);
  747.                             mouseHopy = random(0, 500);
  748.                             mouse.hop(mouseHopx, mouseHopy);
  749.                         }
  750.                         break;
  751.                     case 4:
  752.                         antiBanStatus = "Mouse hopping...";
  753.                         if (random(1, 3) == 1) {
  754.                             mouseHopx = random(0, 760);
  755.                             mouseHopy = random(0, 500);
  756.                             mouse.hop(mouseHopx, mouseHopy);
  757.                         } else {
  758.                             antiBanStatus = "Mouse hopping...";
  759.                             if (random(1, 3) == 1) {
  760.                                 mouseHopx = random(0, 760);
  761.                                 mouseHopy = random(0, 500);
  762.                                 mouse.hop(mouseHopx, mouseHopy);
  763.                             }
  764.                         }
  765.                         break;
  766.                     case 5:
  767.                         antiBanStatus = "Mouse hopping...";
  768.                         camera.setAngle(random(180, 360));
  769.                         sleep(500, 1000);
  770.                         if (random(1, 3) == 1) {
  771.                             mouseHopx = random(0, 760);
  772.                             mouseHopy = random(0, 500);
  773.                             mouse.hop(mouseHopx, mouseHopy);
  774.                         }
  775.                         break;
  776.                 }
  777.         }
  778.     }
  779.  
  780.         public void antiBanCamera() {
  781.         isDoingAnti = true;
  782.         int rand = random(1, 30);
  783.         if (rand >= 1 && rand <= 3) {
  784.             antiBanStatus = "randomizing Camera Movement...";
  785.             camera.moveRandomly(random(2000, 5500));
  786.             isDoingAnti = false;
  787.         }
  788.         if (rand >= 4 && rand <= 5) {
  789.             antiBanStatus = "randomizing Camera Angle...";
  790.             camera.setAngle(random(10, 100));
  791.             isDoingAnti = false;
  792.         }
  793.         if (rand == 6) {
  794.             antiBanStatus = "randomizing Camera Pitch...";
  795.             camera.setPitch(random(40, 68));
  796.             isDoingAnti = false;
  797.         }
  798.         if (rand == 7) {
  799.             antiBanStatus = "randomizing Camera Pitch...";
  800.             camera.setPitch(random(20, 45));
  801.             isDoingAnti = false;
  802.         }
  803.         if (rand == 8) {
  804.             antiBanStatus = "randomizing Camera Pitch...";
  805.             camera.setPitch(random(68, 90));
  806.             isDoingAnti = false;
  807.         }
  808.         if (rand >= 9) {
  809.             isDoingAnti = false;
  810.         }
  811.     }
  812.     }
  813.     //</editor-fold>
  814.    
  815.     // <editor-fold defaultstate="collapsed" desc="GUI">
  816. public class ipuGUI extends javax.swing.JFrame {
  817.     private static final long serialVersionUID = 1L;
  818.  
  819.     /** Creates new form ipuGUI */
  820.     public ipuGUI() {
  821.         initComponents();
  822.     }
  823.  
  824.     /** This method is called from within the constructor to
  825.      * initialize the form.
  826.      * WARNING: Do NOT modify this code. The content of this method is
  827.      * always regenerated by the Form Editor.
  828.      */
  829.  
  830.     @SuppressWarnings("unchecked")
  831.     // <editor-fold defaultstate="collapsed" desc="Generated Code">
  832.     private void initComponents() {
  833.  
  834.         main = new javax.swing.JPanel();
  835.         devMode = new javax.swing.JCheckBox();
  836.         tabbed = new javax.swing.JTabbedPane();
  837.         info = new javax.swing.JPanel();
  838.         jScrollPane1 = new javax.swing.JScrollPane();
  839.         jTextArea1 = new javax.swing.JTextArea();
  840.         gen = new javax.swing.JPanel();
  841.         screenshot = new javax.swing.JCheckBox();
  842.         hopper = new javax.swing.JCheckBox();
  843.         mousespeed = new javax.swing.JCheckBox();
  844.         updater = new javax.swing.JCheckBox();
  845.         loc = new javax.swing.JPanel();
  846.         locations = new javax.swing.JComboBox();
  847.         jScrollPane2 = new javax.swing.JScrollPane();
  848.         requirements = new javax.swing.JTextArea();
  849.         jLabel2 = new javax.swing.JLabel();
  850.         extra = new javax.swing.JPanel();
  851.         jScrollPane3 = new javax.swing.JScrollPane();
  852.         credits = new javax.swing.JTextArea();
  853.         changes = new javax.swing.JPanel();
  854.         jScrollPane4 = new javax.swing.JScrollPane();
  855.         jTextArea4 = new javax.swing.JTextArea();
  856.         title = new javax.swing.JLabel();
  857.         start = new javax.swing.JButton();
  858.         viewthread = new javax.swing.JButton();
  859.         donate = new javax.swing.JButton();
  860.  
  861.         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  862.         setTitle("Iron Picker Uper GUI");
  863.         setAlwaysOnTop(true);
  864.         setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  865.         setName("main"); // NOI18N
  866.         setResizable(false);
  867.         addWindowListener(new java.awt.event.WindowAdapter() {
  868.             public void windowClosed(java.awt.event.WindowEvent evt) {
  869.                 formWindowClosed(evt);
  870.             }
  871.         });
  872.  
  873.         jTextArea1.setColumns(20);
  874.         jTextArea1.setEditable(false);
  875.         jTextArea1.setLineWrap(true);
  876.         jTextArea1.setRows(5);
  877.         jTextArea1.setText("This script was Developed by Deww1 of Powerbot.\n\nPlease sell all ores 5% over the guide price in the Grand Exchange.\nIf you do not, I will be forced to close this script.\n\nIf you find any bugs, post them here:\nhttp://www.powerbot.org/vb/showthread.php?t=770408\n\nThis script collects ores from powerminers in Rimmington Mines, or the Guild Mine\nMore locations to be added soon.\nUpdated script! View change log!");
  878.         jTextArea1.setWrapStyleWord(true);
  879.         jScrollPane1.setViewportView(jTextArea1);
  880.  
  881.         javax.swing.GroupLayout infoLayout = new javax.swing.GroupLayout(info);
  882.         info.setLayout(infoLayout);
  883.         infoLayout.setHorizontalGroup(
  884.             infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  885.             .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
  886.         );
  887.         infoLayout.setVerticalGroup(
  888.             infoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  889.             .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
  890.         );
  891.  
  892.         tabbed.addTab("Info", info);
  893.  
  894.         screenshot.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  895.         screenshot.setText("Take a Screenshot when script stops?");
  896. //        screenshot.addActionListener(new java.awt.event.ActionListener() {
  897. //            public void actionPerformed(java.awt.event.ActionEvent evt) {
  898. //                screenshotActionPerformed(evt);
  899. //            }
  900. //        });
  901.  
  902.         hopper.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  903.         hopper.setText("Use the Built In World Hopper?");
  904. //        hopper.addActionListener(new java.awt.event.ActionListener() {
  905. //            public void actionPerformed(java.awt.event.ActionEvent evt) {
  906. //                hopperActionPerformed(evt);
  907. //            }
  908. //        });
  909.  
  910.         mousespeed.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  911.         mousespeed.setText("Use Custom Mouse Speed Changer?");
  912. //        mousespeed.addActionListener(new java.awt.event.ActionListener() {
  913. //            public void actionPerformed(java.awt.event.ActionEvent evt) {
  914. //                mousespeedActionPerformed(evt);
  915. //            }
  916. //        });
  917.  
  918.         updater.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  919.         updater.setText("Do you wish to check for updates?");
  920. //        updater.addActionListener(new java.awt.event.ActionListener() {
  921. //            public void actionPerformed(java.awt.event.ActionEvent evt) {
  922. //                updaterActionPerformed(evt);
  923. //            }
  924. //        });
  925.  
  926.         devMode.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  927.         devMode.setText("Debug Mode(Logs all messages)");
  928.  
  929.         javax.swing.GroupLayout genLayout = new javax.swing.GroupLayout(gen);
  930.         gen.setLayout(genLayout);
  931.         genLayout.setHorizontalGroup(
  932.             genLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  933.             .addGroup(genLayout.createSequentialGroup()
  934.                 .addContainerGap()
  935.                 .addGroup(genLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  936.                     .addGroup(genLayout.createSequentialGroup()
  937.                         .addComponent(screenshot)
  938.                         .addContainerGap(200, Short.MAX_VALUE))
  939.                     .addGroup(genLayout.createSequentialGroup()
  940.                         .addComponent(hopper, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  941.                         .addGap(244, 244, 244))
  942.                     .addGroup(genLayout.createSequentialGroup()
  943.                         .addComponent(mousespeed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  944.                         .addGap(210, 210, 210))
  945.                     .addGroup(genLayout.createSequentialGroup()
  946.                         .addComponent(updater)
  947.                         .addContainerGap(218, Short.MAX_VALUE))
  948.                     .addGroup(genLayout.createSequentialGroup()
  949.                         .addComponent(devMode)
  950.                         .addContainerGap(236, Short.MAX_VALUE))))
  951.         );
  952.         genLayout.setVerticalGroup(
  953.             genLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  954.             .addGroup(genLayout.createSequentialGroup()
  955.                 .addGap(15, 15, 15)
  956.                 .addComponent(screenshot)
  957.                 .addGap(18, 18, 18)
  958.                 .addComponent(hopper)
  959.                 .addGap(18, 18, 18)
  960.                 .addComponent(mousespeed)
  961.                 .addGap(18, 18, 18)
  962.                 .addComponent(updater)
  963.                 .addGap(18, 18, 18)
  964.                 .addComponent(devMode)
  965.                 .addContainerGap(31, Short.MAX_VALUE))
  966.         );
  967.  
  968.         tabbed.addTab("General Tab", gen);
  969.  
  970.         locations.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
  971.         locations.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
  972.             "Pick a Location", "Rimmington Mines", "Guild Mine" }));
  973.  
  974.         requirements.setColumns(20);
  975.         requirements.setEditable(false);
  976.         requirements.setLineWrap(true);
  977.         requirements.setRows(5);
  978.         requirements.setText("Rimmington Mines:\nNo Requirements, Apx. 400-600 ores/hr\n\nGuild Mines:\n60 Mining Required, Not Tested - Give quotes/proggies");
  979.         requirements.setWrapStyleWord(true);
  980.         jScrollPane2.setViewportView(requirements);
  981.  
  982.         jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  983.         jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  984.         jLabel2.setText("Pick a location to pick up ores from.");
  985.  
  986.         javax.swing.GroupLayout locLayout = new javax.swing.GroupLayout(loc);
  987.         loc.setLayout(locLayout);
  988.         locLayout.setHorizontalGroup(
  989.             locLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  990.             .addGroup(locLayout.createSequentialGroup()
  991.                 .addContainerGap()
  992.                 .addGroup(locLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  993.                     .addGroup(locLayout.createSequentialGroup()
  994.                         .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)
  995.                         .addContainerGap())
  996.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, locLayout.createSequentialGroup()
  997.                         .addComponent(locations, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)
  998.                         .addGap(60, 60, 60))))
  999.             .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
  1000.         );
  1001.         locLayout.setVerticalGroup(
  1002.             locLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1003.             .addGroup(locLayout.createSequentialGroup()
  1004.                 .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
  1005.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  1006.                 .addComponent(locations, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
  1007.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
  1008.                 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
  1009.         );
  1010.  
  1011.         tabbed.addTab("Locations", loc);
  1012.  
  1013.         credits.setColumns(20);
  1014.         credits.setEditable(false);
  1015.         credits.setLineWrap(true);
  1016.         credits.setRows(5);
  1017.         credits.setText("Credits:\nDeww1 - Main Script Programming\njtryba - Creating the implemented World Switcher\nEnfilade - Creating the Built in Updater(not working)\nEnfilade - Paint assistant\n\nExtras:\nI am trying to get Script Writer Status, so that my updater can soon work, but I can't do it without you guys. I need you guys to post in my thread! I need at least 100 positive feedback posts on the Iron Pick Up thread, so you can soon get updates without going to the thread! :)");
  1018.         credits.setWrapStyleWord(true);
  1019.         jScrollPane3.setViewportView(credits);
  1020.  
  1021.         javax.swing.GroupLayout extraLayout = new javax.swing.GroupLayout(extra);
  1022.         extra.setLayout(extraLayout);
  1023.         extraLayout.setHorizontalGroup(
  1024.             extraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1025.             .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
  1026.         );
  1027.         extraLayout.setVerticalGroup(
  1028.             extraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1029.             .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
  1030.         );
  1031.  
  1032.         tabbed.addTab("Extras/Credits", extra);
  1033.  
  1034.         jTextArea4.setColumns(20);
  1035.         jTextArea4.setEditable(false);
  1036.         jTextArea4.setLineWrap(true);
  1037.         jTextArea4.setRows(5);
  1038.         jTextArea4.setText("V 2: Initial Public Release\n \nV 2.1:\nUpdated paint\nMore accurate ore count\n2-step updater(checks two servers)\nmore informative finish() thread\n\nV. 2.23(BETA):\nNew bank location(Port Sarim)\nDownfalls:\nVery inaccurate paint info.(if you can help msg me)\n\nV 2.35(BETA):\nbanking is now more fluid(only tested for around 30 minutes)\nMuch more accurate paint\nnew banking path! :)\n\nV 2.38:\nScript now works with 2.42! - redownload the script, and it should work! :)\n\nV 2.39:\nFixed a nullPointerException - Script should now work.\n\nV 2.58:\nNew GUI\nNew location: Guild Mine (requires 60 mining) - Picks up Coal\n\nV 2.6:\nFinally got my Script Writer Rank so..\nUpdater now works\nfeel free to test it out! :)\nDebug feature in General: Displays all stesp take in the script in the logs.\nonly apply if having bot troubles...");
  1039.         jTextArea4.setWrapStyleWord(true);
  1040.         jScrollPane4.setViewportView(jTextArea4);
  1041.  
  1042.         javax.swing.GroupLayout changesLayout = new javax.swing.GroupLayout(changes);
  1043.         changes.setLayout(changesLayout);
  1044.         changesLayout.setHorizontalGroup(
  1045.             changesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1046.             .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE)
  1047.         );
  1048.         changesLayout.setVerticalGroup(
  1049.             changesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1050.             .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
  1051.         );
  1052.  
  1053.         tabbed.addTab("Change Log", changes);
  1054.  
  1055.         title.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
  1056.         title.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  1057.         title.setText("Iron Pick Up Settings - Script Developed by: Deww1");
  1058.  
  1059.         start.setText("Start Script");
  1060.         start.addActionListener(new java.awt.event.ActionListener() {
  1061.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1062.                 startActionPerformed(evt);
  1063.             }
  1064.         });
  1065.  
  1066.         viewthread.setText("View Thread");
  1067.         viewthread.addActionListener(new java.awt.event.ActionListener() {
  1068.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1069.                 viewthreadActionPerformed(evt);
  1070.             }
  1071.         });
  1072.  
  1073.         donate.setText("Donate");
  1074.         donate.addActionListener(new java.awt.event.ActionListener() {
  1075.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1076.                 donateActionPerformed(evt);
  1077.             }
  1078.         });
  1079.  
  1080.         javax.swing.GroupLayout mainLayout = new javax.swing.GroupLayout(main);
  1081.         main.setLayout(mainLayout);
  1082.         mainLayout.setHorizontalGroup(
  1083.             mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1084.             .addComponent(title, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
  1085.             .addComponent(tabbed, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 468, Short.MAX_VALUE)
  1086.             .addGroup(mainLayout.createSequentialGroup()
  1087.                 .addContainerGap()
  1088.                 .addComponent(start, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
  1089.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  1090.                 .addComponent(viewthread, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
  1091.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  1092.                 .addComponent(donate, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
  1093.                 .addContainerGap())
  1094.         );
  1095.         mainLayout.setVerticalGroup(
  1096.             mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1097.             .addGroup(mainLayout.createSequentialGroup()
  1098.                 .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
  1099.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  1100.                 .addComponent(tabbed, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
  1101.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  1102.                 .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1103.                     .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  1104.                         .addComponent(start, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
  1105.                         .addComponent(viewthread, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
  1106.                     .addComponent(donate, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE))
  1107.                 .addContainerGap())
  1108.         );
  1109.  
  1110.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  1111.         getContentPane().setLayout(layout);
  1112.         layout.setHorizontalGroup(
  1113.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1114.             .addComponent(main, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  1115.         );
  1116.         layout.setVerticalGroup(
  1117.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1118.             .addGroup(layout.createSequentialGroup()
  1119.                 .addComponent(main, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  1120.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1121.         );
  1122.  
  1123.         getAccessibleContext().setAccessibleName("ipuGUI");
  1124.  
  1125.         pack();
  1126.     }// </editor-fold>
  1127.  
  1128.     private void formWindowClosed(java.awt.event.WindowEvent evt) {
  1129.        stopScript();
  1130.     }
  1131.     private void screenshotActionPerformed(java.awt.event.ActionEvent evt) {
  1132.         if (screenshot.isSelected()) {
  1133.             shot = true;
  1134.             log("We will take a screenshot when we finish");
  1135.         } else {
  1136.             shot = false;
  1137.             log("We will not take a screenshot when we finish");
  1138.         }
  1139.     }
  1140.     private void hopperActionPerformed(java.awt.event.ActionEvent evt) {
  1141.         if (hopper.isSelected()) {
  1142.                 wHop = true; //world hop
  1143.                 log(Color.RED, "We will NOT be world hopping!");
  1144.             } else {
  1145.                 wHop = false; //don't world hop
  1146.                 log("We will be world hopping!");
  1147.             }
  1148.     }
  1149.     private void mousespeedActionPerformed(java.awt.event.ActionEvent evt) {
  1150.         if (mousespeed.isSelected()) {
  1151.                 useMsRandom = true; //random mouse speed
  1152.                 log(Color.RED, "We will  NOT be using Random Mouse Speeds!");
  1153.             } else {
  1154.                 useMsRandom = false; //no random mouse speed
  1155.                 log("We will be using Random Mouse Speeds!");
  1156.             }
  1157.     }
  1158.     private void startActionPerformed(java.awt.event.ActionEvent evt) {
  1159.         setVisible(false);
  1160.         //dispose();
  1161.     }
  1162.     private void viewthreadActionPerformed(java.awt.event.ActionEvent evt) {
  1163.         String info = "http://www.powerbot.org/vb/showthread.php?t=770408";
  1164.             try {
  1165.                 java.awt.Desktop.getDesktop().browse(java.net.URI.create(info));
  1166.             } catch (Exception e) {
  1167.                 log("Error:" + e.getLocalizedMessage());
  1168.             }
  1169.     }
  1170.     private void donateActionPerformed(java.awt.event.ActionEvent evt) {
  1171.         String donate = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PJNGPMGCA4TVU";
  1172.             try {
  1173.                 java.awt.Desktop.getDesktop().browse(
  1174.                         java.net.URI.create(donate));
  1175.             } catch (Exception e) {
  1176.                 log("Error:" + e.getLocalizedMessage());
  1177.             }
  1178.     }
  1179.     private void updaterActionPerformed(java.awt.event.ActionEvent evt) {
  1180.             if (updater.isSelected()) {
  1181.                 doUpdate = true; //Don't check
  1182.                 log(Color.RED, "We will NOT be checking for updates!");
  1183.             } else {
  1184.                 doUpdate = false; //Do check
  1185.                 log("We will be checking for updates!");
  1186.             }
  1187.         }
  1188.  
  1189.  
  1190.     // Variables declaration - do not modify
  1191.     private javax.swing.JCheckBox devMode;
  1192.     private javax.swing.JPanel changes;
  1193.     private javax.swing.JTextArea credits;
  1194.     private javax.swing.JButton donate;
  1195.     private javax.swing.JPanel extra;
  1196.     private javax.swing.JPanel gen;
  1197.     private javax.swing.JCheckBox hopper;
  1198.     private javax.swing.JPanel info;
  1199.     private javax.swing.JLabel jLabel2;
  1200.     private javax.swing.JScrollPane jScrollPane1;
  1201.     private javax.swing.JScrollPane jScrollPane2;
  1202.     private javax.swing.JScrollPane jScrollPane3;
  1203.     private javax.swing.JScrollPane jScrollPane4;
  1204.     private javax.swing.JTextArea jTextArea1;
  1205.     private javax.swing.JTextArea jTextArea4;
  1206.     private javax.swing.JPanel loc;
  1207.     private javax.swing.JComboBox locations;
  1208.     private javax.swing.JPanel main;
  1209.     private javax.swing.JCheckBox mousespeed;
  1210.     private javax.swing.JTextArea requirements;
  1211.     private javax.swing.JCheckBox screenshot;
  1212.     private javax.swing.JButton start;
  1213.     private javax.swing.JTabbedPane tabbed;
  1214.     private javax.swing.JLabel title;
  1215.     private javax.swing.JCheckBox updater;
  1216.     private javax.swing.JButton viewthread;
  1217.     // End of variables declaration
  1218.  
  1219. }
  1220. // </editor-fold>
  1221.  
  1222.     //<editor-fold defaultstate="collapsed" desc="Updater">
  1223.     private static final String UPDATER_FILE_NAME = "ironPickUp.java";
  1224.     private static final String UPDATER_URL = "http://scripters.powerbot.org/542806/scriptdir/ironPickUp.java";
  1225.     private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)");
  1226.  
  1227.  
  1228.     private boolean checkForUpdates() {
  1229.         try {
  1230.             /* Get the current version from the Script Manifest annotation defined at the top of your script's class */
  1231.             double currentVer = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
  1232.             double newVer = -1;
  1233.             URL url = new URL(UPDATER_URL);
  1234.             /* Open a stream to the newest script file hosted on your server */
  1235.             BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  1236.             String line, lines = "";
  1237.             Matcher m;
  1238.             /* Look for the "version = x.x" string in the newer file to figure out the newest version number */
  1239.             while ((line = in.readLine()) != null) {
  1240.                 lines += line + "\n";
  1241.                 if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
  1242.                     newVer = Double.parseDouble(m.group(1));
  1243.                     break;
  1244.                 }
  1245.             }
  1246.             /* Check if the updater was unable to read the newest version number */
  1247.             if (newVer < 0) {
  1248.                 in.close();
  1249.                 log("Unable to find the new version number. Update failed");
  1250.                 return false;
  1251.             }
  1252.             /* Compare the current version to the newest. */
  1253.             if (currentVer == newVer) {
  1254.                 in.close();
  1255.                 log("You already have the latest version of the script.");
  1256.                 return true;
  1257.             }
  1258.             /* The current version is less than the newest version, so we need to download it */
  1259.             log("Update found! Downloading version " + newVer);
  1260.             /* Figure out where to save the file */
  1261.             String scriptFilePath = Configuration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME;
  1262.             PrintWriter out = new PrintWriter(scriptFilePath);
  1263.             /* Print the cached lines from the version checking */
  1264.             out.print(lines);
  1265.             /* Print the rest of the file */
  1266.             while ((line = in.readLine()) != null) {
  1267.                 out.println(line);
  1268.             }
  1269.             /* Close the streams */
  1270.             out.close();
  1271.             in.close();
  1272.             log(Color.RED,"Successfully saved " + UPDATER_FILE_NAME + " to " + Configuration.Paths.getScriptsSourcesDirectory());
  1273.             log(Color.MAGENTA, "File saved, now all you have to do is go to your RSBot directory, and compile\n the script!");
  1274.             log(Color.orange, "Update successful!");
  1275.  
  1276.             //log(Color.green, "The new version will appear near the bottom of the script selector.");
  1277.             //log(Color.red, "Stop and restart the script to run the newer version.");
  1278.             return true;
  1279.         } catch (IOException e) {
  1280.             log(e.toString());
  1281.             log("Update failed.");
  1282.         }
  1283.         return false;
  1284.     }
  1285.     //</editor-fold>
  1286.  
  1287.     //<editor-fold defaultstate="collapsed" desc="world hopper">
  1288.     public class hopper {
  1289.  
  1290.         public void worldHop(boolean members) {
  1291.         worldHop(members, 150, 1000);
  1292.     }
  1293.  
  1294.         public void worldHop(boolean members, int maxping) {
  1295.         worldHop(members, maxping, 1000);
  1296.     }
  1297.  
  1298.         public void worldHop(boolean members, int maxping, int maxpop) {
  1299.  
  1300.         final int LOBBY_PARENT = 906;
  1301.         final int WORLD_SELECT_TAB_PARENT = 910;
  1302.         final int WORLD_SELECT_COM = 77;
  1303.         final int WORLD_NUMBER_COM = 69;
  1304.         final int WORLD_POPULATION_COM = 71;
  1305.         final int WORLD_TYPE_COM = 74;
  1306.         final int WORLD_SELECT_BUTTON_COM = 188;
  1307.         final int WORLD_SELECT_BUTTON_BG_COM = 12;
  1308.         final int WORLD_SELECT_TAB_ACTIVE = 4671;
  1309.         final int WORLD_FULL_BACK_BUTTON_COM = 233;
  1310.         final int CURRENT_WORLD_COM = 11;
  1311.         final int SORT_POPULATION_BUTTON_PARENT = 30;
  1312.         final int SORT_PING_BUTTON_PARENT = 45;
  1313.         final int SORT_LOOTSHARE_BUTTON_PARENT = 47;
  1314.         final int SORT_TYPE_BUTTON_PARENT = 49;
  1315.         final int SORT_ACTIVITY_BUTTON_PARENT = 52;
  1316.         final int SORT_WORLD_BUTTON_PARENT = 55;
  1317.         final int SCROLL_BAR_PARENT = 86;
  1318.         final int HIGH_RISK_WARN_PARENT = 93;
  1319.         final int PLAY_BUTTON_COM = 171;
  1320.         final int RETURN_TEXT_COM = 221;
  1321.         final int SUBSCRIBE_BACK_BUTTON_COM = 233;
  1322.         final int CONNECT_ERROR_BACK_BUTTON_COM = 42;
  1323.         final int SKILL_WORLD_BACK_BUTTON_COM = 228;
  1324.         final int SKILL_WORLD_NUMBER = 113;
  1325.  
  1326.         long whileTimer = 0;
  1327.  
  1328.         log("Hopping worlds");
  1329.         status$ = "Hopping worlds";
  1330.  
  1331.         // logout
  1332.         while (game.isLoggedIn()) {
  1333.             if (game.logout(true)) {
  1334.                 sleep(1000, 1500);
  1335.                 while (game.getClientState() != 7) {
  1336.                     sleep(random(200, 500));
  1337.                 }
  1338.             }
  1339.         }
  1340.  
  1341.         status$ = "Selecting new world";
  1342.         sleep(random(1500, 2000));
  1343.  
  1344.         // click world select tab (if needed)
  1345.         RSComponent worldSelectTab = interfaces.getComponent(LOBBY_PARENT,
  1346.                 WORLD_SELECT_BUTTON_BG_COM);
  1347.  
  1348.         whileTimer = System.currentTimeMillis();
  1349.  
  1350.         while (worldSelectTab.getBackgroundColor() != WORLD_SELECT_TAB_ACTIVE
  1351.                 && System.currentTimeMillis() - whileTimer < 90000) {
  1352.             if (interfaces.get(LOBBY_PARENT).getComponent(WORLD_SELECT_BUTTON_BG_COM).doClick()) {
  1353.                 //interfaces.getComponent(LOBBY_PARENT, WORLD_SELECT_BUTTON_BG_COM).doClick();
  1354.                 sleep(random(1500, 2000));
  1355.             }
  1356.         }
  1357.  
  1358.         // get current world
  1359.         String cW = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1360.                 CURRENT_WORLD_COM).getText();
  1361.         String[] cWS = cW.split(" ");
  1362.         currentWorld = Integer.parseInt(cWS[1]);
  1363.         newWorld = currentWorld;
  1364.  
  1365.         // randomly sort worlds
  1366.         if (random(0, 10) < 5) {
  1367.             RSComponent com = null;
  1368.             switch (random(0, 6)) {
  1369.                 case 0: // population
  1370.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1371.                             SORT_POPULATION_BUTTON_PARENT).getComponent(
  1372.                             random(0, 2));
  1373.                     break;
  1374.                 case 1: // ping
  1375.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1376.                             SORT_PING_BUTTON_PARENT).getComponent(random(0, 2));
  1377.                     break;
  1378.                 case 2: // loot share
  1379.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1380.                             SORT_LOOTSHARE_BUTTON_PARENT).getComponent(random(0, 2));
  1381.                     break;
  1382.                 case 3: // type
  1383.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1384.                             SORT_TYPE_BUTTON_PARENT).getComponent(random(0, 2));
  1385.                     break;
  1386.                 case 4: // activity
  1387.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1388.                             SORT_ACTIVITY_BUTTON_PARENT).getComponent(random(0, 2));
  1389.                     break;
  1390.                 case 5: // world
  1391.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1392.                             SORT_WORLD_BUTTON_PARENT).getComponent(random(0, 2));
  1393.                     break;
  1394.             }
  1395.             if (com.doClick()) {
  1396.                 sleep(random(1250, 1500));
  1397.             }
  1398.         }
  1399.  
  1400.         // check if we should sort by ptp/ftp
  1401.         boolean sort = false;
  1402.         RSComponent[] wt = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1403.                 WORLD_TYPE_COM).getComponents();
  1404.         for (int i = 0; i < 10; i++) {
  1405.             if ((members && !wt[i].getText().contains("Members"))
  1406.                     || (!members && wt[i].getText().contains("Members"))) {
  1407.                 sort = true;
  1408.                 break;
  1409.             }
  1410.         }
  1411.  
  1412.         // sort by ptp/ftp (if needed)
  1413.         if (sort) {
  1414.             status$ = "Sorting worlds by type";
  1415.             if (interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1416.                     SORT_TYPE_BUTTON_PARENT).getComponent(members ? 0 : 1).doClick()) {
  1417.                 sleep(random(1000, 1500));
  1418.             }
  1419.         }
  1420.  
  1421.         /*-PICK-NEXT-WORLD-*/
  1422.         whileTimer = System.currentTimeMillis();
  1423.         while (currentWorld == newWorld
  1424.                 && System.currentTimeMillis() - whileTimer < 90000) {
  1425.             RSComponent worldToHop = null;
  1426.             RSComponent[] comWorldNumber = interfaces.getComponent(
  1427.                     WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
  1428.             int world = 0;
  1429.             int pop = 2000;
  1430.             int ping = -1;
  1431.             boolean member = false;
  1432.             while (worldToHop == null) {
  1433.                 for (int i = 0; i < comWorldNumber.length - 1; i++) {
  1434.                     RSComponent[] comWorldSelect = interfaces.getComponent(
  1435.                             WORLD_SELECT_TAB_PARENT, WORLD_SELECT_COM).getComponents();
  1436.                     RSComponent[] comWorldPopulation = interfaces.getComponent(
  1437.                             WORLD_SELECT_TAB_PARENT, WORLD_POPULATION_COM).getComponents();
  1438.                     RSComponent[] comWorldType = interfaces.getComponent(
  1439.                             WORLD_SELECT_TAB_PARENT, WORLD_TYPE_COM).getComponents();
  1440.                     comWorldNumber = interfaces.getComponent(
  1441.                             WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
  1442.                     try {
  1443.                         world = Integer.parseInt(comWorldNumber[i].getText());
  1444.                     } catch (NumberFormatException nfe) {
  1445.                         world = 0;
  1446.                     } catch (ArrayIndexOutOfBoundsException aie) {
  1447.                         world = 0;
  1448.                     }
  1449.                     if (world == SKILL_WORLD_NUMBER && skillTotal < 1000) {
  1450.                         world = 0;
  1451.                     }
  1452.                     try {
  1453.                         pop = Integer.parseInt(comWorldPopulation[i].getText());
  1454.                     } catch (NumberFormatException nfe) {
  1455.                         pop = 2000;
  1456.                     } catch (ArrayIndexOutOfBoundsException aie) {
  1457.                         pop = 2000;
  1458.                     }
  1459.                     try {
  1460.                         if (comWorldType[i].getText().contains("Members")) {
  1461.                             member = true;
  1462.                         }
  1463.                     } catch (ArrayIndexOutOfBoundsException aie) {
  1464.                     }
  1465.                     if (world != 0 && !isPastWorld(world)
  1466.                             && world != currentWorld && pop < maxpop && pop > 0
  1467.                             && member == members) {
  1468.                         ping = pingHost("world" + world + ".runescape.com",
  1469.                                 maxPing + 50);
  1470.                     } else {
  1471.                         ping = -1;
  1472.                     }
  1473.                     if (ping < maxping && ping > 0) {
  1474.                         log("World " + world + " selected.");
  1475.                         worldToHop = comWorldSelect[i];
  1476.                     }
  1477.                     if (worldToHop != null) {
  1478.                         break;
  1479.                     }
  1480.                 }
  1481.                 sleep(random(50, 150));
  1482.             }
  1483.             if (worldToHop != null) {
  1484.                 int w = -1;
  1485.                 String[] split = interfaces.getComponent(910, 8).getText().split(" ");
  1486.                 try {
  1487.                     w = Integer.parseInt(split[split.length - 1]);
  1488.                 } catch (Exception e) {
  1489.                     w = -1;
  1490.                 }
  1491.                 // click new world
  1492.                 while (w != world) {
  1493.                     if (worldToHop.getLocation().y <= 280
  1494.                             && worldToHop.getLocation().y >= 0) {
  1495.                         status$ = "Clicking new world";
  1496.                         worldToHop.doClick();
  1497.                     } else {
  1498.                         RSComponent scrollBar = interfaces.getComponent(
  1499.                                 WORLD_SELECT_TAB_PARENT, SCROLL_BAR_PARENT);
  1500.                         status$ = "Scrolling to new world";
  1501.                         if (interfaces.scrollTo(worldToHop, scrollBar)) {
  1502.                             status$ = "Clicking new world";
  1503.                             worldToHop.doClick();
  1504.                         }
  1505.                     }
  1506.                     split = interfaces.getComponent(910, 8).getText().split(" ");
  1507.                     try {
  1508.                         w = Integer.parseInt(split[split.length - 1]);
  1509.                     } catch (Exception e) {
  1510.                         w = -1;
  1511.                     }
  1512.                 }
  1513.                 // get new world
  1514.                 sleep(random(1000, 1500));
  1515.                 String cW2 = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1516.                         CURRENT_WORLD_COM).getText();
  1517.                 String[] cWS2 = cW2.split(" ");
  1518.                 newWorld = Integer.parseInt(cWS2[1]);
  1519.             }
  1520.         }
  1521.         /*-END-PICK-NEXT-WORLD-*/
  1522.  
  1523.         // set last & current world/s
  1524.         if (currentWorld != newWorld) {
  1525.             for (int i = 0; i < pastWorld.length; i++) {
  1526.                 if (i < pastWorld.length - 1) {
  1527.                     pastWorld[i] = pastWorld[i + 1];
  1528.                 } else {
  1529.                     pastWorld[i] = currentWorld;
  1530.                 }
  1531.             }
  1532.             currentWorld = newWorld;
  1533.         }
  1534.  
  1535.         while (game.getClientState() != 10) {
  1536.             status$ = "Logging in...";
  1537.             // click play button
  1538.             if (interfaces.getComponent(LOBBY_PARENT, PLAY_BUTTON_COM).doClick()) {
  1539.                 hopped++;
  1540.                 timer.reset();
  1541.             }
  1542.  
  1543.             // check for high risk world warning during login
  1544.             long timeOut = System.currentTimeMillis() + 35000;
  1545.             while (game.getClientState() != 10
  1546.                     && System.currentTimeMillis() < timeOut) {
  1547.                 RSComponent hrParent = interfaces.getComponent(LOBBY_PARENT,
  1548.                         HIGH_RISK_WARN_PARENT);
  1549.                 if (hrParent.isValid()) {
  1550.                     RSComponent LogIn = hrParent.getComponent(random(0,
  1551.                             hrParent.getComponents().length));
  1552.                     if (LogIn != null && LogIn.isValid()) {
  1553.                         if (mouse.getLocation().getX() < 386
  1554.                                 || mouse.getLocation().getX() > 504
  1555.                                 || mouse.getLocation().getY() < 357
  1556.                                 || mouse.getLocation().getY() > 386) {
  1557.                             if (LogIn.doHover()) {
  1558.                                 sleep(random(250, 500));
  1559.                                 if (menu.contains("Log In")) {
  1560.                                     // accept warning / click login
  1561.                                     mouse.click(true);
  1562.                                     log.warning("This is a high risk wilderness world.");
  1563.                                     sleep(random(250, 500));
  1564.                                 }
  1565.                             }
  1566.                         }
  1567.                     }
  1568.                 }
  1569.                 sleep(100);
  1570.             }
  1571.             // check for login errors
  1572.             String returnText = interfaces.getComponent(LOBBY_PARENT, RETURN_TEXT_COM).getText().toLowerCase();
  1573.             if (!game.isLoggedIn()) {
  1574.                 if (returnText.contains("update")) {
  1575.                     status$ = "Stopping script";
  1576.                     log("Runescape has been updated, please reload RSBot.");
  1577.                     stopScript(false);
  1578.                 }
  1579.                 if (returnText.contains("disable")) {
  1580.                     status$ = "Stopping script";
  1581.                     log("Your account is banned/disabled.");
  1582.                     stopScript(false);
  1583.                 }
  1584.                 if (returnText.contains("error connecting")) {
  1585.                     status$ = "Stopping script";
  1586.                     log("STOPPED = line 1045 - error connecting");
  1587.                     interfaces.getComponent(LOBBY_PARENT,
  1588.                             CONNECT_ERROR_BACK_BUTTON_COM).doClick();
  1589.                     stopScript(false);
  1590.                 }
  1591.                 if (returnText.contains("full")) {
  1592.                     log("World Is Full.");
  1593.                     interfaces.getComponent(LOBBY_PARENT,
  1594.                             WORLD_FULL_BACK_BUTTON_COM).doClick();
  1595.                     sleep(random(1000, 1500));
  1596.                     worldHop(members, maxping, maxpop); // try again
  1597.                 }
  1598.                 if (returnText.contains("subscribe")) {
  1599.                     interfaces.getComponent(LOBBY_PARENT,
  1600.                             SUBSCRIBE_BACK_BUTTON_COM).doClick();
  1601.                     if (members) {
  1602.                         status$ = "Stopping script";
  1603.                         log("You neen to be a member to select this world.");
  1604.                         stopScript(false);
  1605.                     } else {
  1606.                         sleep(random(500, 1000));
  1607.                         worldHop(members, maxping, maxpop); // try again
  1608.                     }
  1609.                 }
  1610.                 if (returnText.contains("must have a total")) {
  1611.                     log("STOPPED = line 1069 - must have a total");
  1612.                     interfaces.getComponent(LOBBY_PARENT,
  1613.                             SKILL_WORLD_BACK_BUTTON_COM).doClick();
  1614.                     sleep(random(500, 1000));
  1615.                     worldHop(members, maxping, maxpop); // try again
  1616.                 }
  1617.             }
  1618.         }
  1619.     }
  1620.  
  1621.         private boolean isPastWorld(int world) {
  1622.         for (int i = 0; i < pastWorld.length; i++) {
  1623.             if (pastWorld[i] == world) {
  1624.                 return true;
  1625.             }
  1626.         }
  1627.         return false;
  1628.     }
  1629.  
  1630.         private int pingHost(String host, int timeout) {
  1631.         long start = -1;
  1632.         long end = -1;
  1633.         int total = -1;
  1634.         int defaultPort = 80;
  1635.         Socket theSock = new Socket();
  1636.         try {
  1637.             InetAddress addr = InetAddress.getByName(host);
  1638.             SocketAddress sockaddr = new InetSocketAddress(addr, defaultPort);
  1639.             start = System.currentTimeMillis();
  1640.             theSock.connect(sockaddr, timeout);
  1641.             end = System.currentTimeMillis();
  1642.         } catch (Exception e) {
  1643.             start = -1;
  1644.             end = -1;
  1645.         } finally {
  1646.             if (theSock != null) {
  1647.                 try {
  1648.                     theSock.close();
  1649.                 } catch (IOException e) {
  1650.                 }
  1651.                 if ((start != -1) && (end != -1)) {
  1652.                     total = (int) (end - start);
  1653.                     log(host + "'s ping delay is " + total + "ms.");
  1654.                 } else {
  1655.                     log("Connection timed out or unable to connect to host: "
  1656.                             + host);
  1657.                 }
  1658.             }
  1659.         }
  1660.         return total; // returns -1 if timeout
  1661.  
  1662.     }
  1663.     }
  1664.     //</editor-fold>
  1665.  
  1666.     //<editor-fold defaultstate="collapsed" desc="Paint Stuff">
  1667.         //START: Code generated using Enfilade's Easel
  1668.     private Image getImage(String url) {
  1669.         try {
  1670.             return ImageIO.read(new URL(url));
  1671.         } catch(IOException e) {
  1672.             return null;
  1673.         }
  1674.     }
  1675.  
  1676.     private final Color color1 = new Color(0, 0, 0);
  1677.     private final Color color2 = new Color(240, 240, 240);
  1678.     private final Color color3 = new Color(255, 255, 255);
  1679.     private final Color color4 = new Color(153, 153, 153, 185);
  1680.     private final Color color5 = new Color(153, 153, 153, 155);
  1681.     private final Color color6 = new Color(212, 222, 150);
  1682.     private final Color color7 = new Color(204, 204, 0, 130);
  1683.  
  1684.  
  1685.  
  1686.  
  1687.     private final Font font1 = new Font("Times New Roman", 0, 10);
  1688.     private final Font font2 = new Font("Times New Roman", 0, 12);
  1689.  
  1690.  
  1691.     private final Image img1 = getImage("http://i360.photobucket.com/albums/oo47/perez048/paint-2.png");
  1692.  
  1693.     public void onRepaint(Graphics g1) {
  1694.         Graphics2D g = (Graphics2D)g1;
  1695.         if (normal != null) {
  1696.  
  1697.             final int mouse_x = mouse.getLocation().x;
  1698.             final int mouse_y = mouse.getLocation().y;
  1699.             final int mouse_x2 = mouse.getPressLocation().x;
  1700.             final int mouse_y2 = mouse.getPressLocation().y;
  1701.             final long mpt = System.currentTimeMillis()
  1702.                     - mouse.getPressTime();
  1703.             if (mouse.getPressTime() == -1 || mpt >= 1000) {
  1704.                 g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse when its not clicked
  1705.             }
  1706.             if (mpt < 1000) {
  1707.                 g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null); //this show the four squares where you clicked.
  1708.                 g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse as normal when its/just clicked
  1709.             }
  1710.         }
  1711.         if (game.isLoggedIn()) {
  1712.             long time = System.currentTimeMillis() - startTime;
  1713.             int pricePH = (int) (price * 3600000D / time);
  1714.             int Price = (orePrice*oreCollected);
  1715.             price = orePrice*oreCollected;
  1716.             priceHr = (int) ((price) * 3600000D / (System.currentTimeMillis() - startTime));
  1717.             oreHr = (int) ((oreCollected) * 3600000D / (System.currentTimeMillis() - startTime));
  1718.             millis = System.currentTimeMillis() - startTime;
  1719.             hours = millis / (1000 * 60 * 60);
  1720.             millis -= hours * (1000 * 60 * 60);
  1721.             minutes = millis / (1000 * 60);
  1722.             millis -= minutes * (1000 * 60);
  1723.             seconds = millis / 1000;
  1724.  
  1725.             millis2 = timer.getRemaining() - 60;
  1726.             seconds2 = millis2 / 1000;
  1727.             if (showPaint1) { //paint closed
  1728.                 g.setColor(color1);
  1729.                 g.fillRect(6, 312, 75, 24);
  1730.                 g.setFont(font1);
  1731.                 g.setColor(color3);
  1732.                 g.drawString("Open Paint", 14, 331);
  1733.             } else if (showPaint2) { //general tab
  1734.                 g.drawImage(img1, -2, 310, null);
  1735.                 g.setFont(font1);
  1736.                 g.setColor(color1);
  1737.                 g.drawString("Ores/hr: "+oreHr, 264, 443);
  1738.                 g.drawString("Ores Collected: "+oreCollected, 262, 428);
  1739.                 g.drawString("Run Time: "+hours+":"+minutes+":"+seconds, 263, 413);
  1740.                 g.setColor(color2);
  1741.                 g.drawString("Version: "+ver, 91, 385);
  1742.                 g.setFont(font2);
  1743.                 g.drawString("Status: "+status, 78, 473);
  1744.                 g.setFont(font1);
  1745.                 g.setColor(color1);
  1746.                 g.drawString("Mouse Speed: "+MouseSpeed, 16, 416);
  1747.                 g.drawString("World Hops: "+hopped, 16, 431);
  1748.                 g.drawString("Time to Switch: "+seconds2, 15, 446);
  1749.                 g.setColor(color6);
  1750.                 g.fillRect(446, 313, 70, 24);
  1751.                 g.setFont(font2);
  1752.                 g.setColor(color1);
  1753.                 g.drawString("General Tab", 453, 332);
  1754.                 g.setColor(color4);
  1755.                 g.fillRect(376, 315, 68, 23);
  1756.                 g.setColor(color1);
  1757.                 g.drawString("Money Tab", 381, 333);
  1758.                 g.setColor(color5);
  1759.                 g.fillRect(6, 312, 75, 24);
  1760.                 g.setColor(color1);
  1761.                 g.drawString("Close Paint", 14, 331);
  1762.             } else if (showPaint3) { //money tab
  1763.                 g.drawImage(img1, -2, 310, null);
  1764.                 g.setFont(font1);
  1765.                 g.setColor(color1);
  1766.                 g.drawString("Run Time: "+hours+":"+minutes+":"+seconds, 264, 422);
  1767.                 g.setColor(color2);
  1768.                 g.drawString("Version: "+ver, 91, 385);
  1769.                 g.setFont(font2);
  1770.                 g.drawString("Status: "+status, 78, 473);
  1771.                 g.setFont(font1);
  1772.                 g.setColor(color1);
  1773.                 g.drawString("Total Money Made: "+Price, 22, 419);
  1774.                 g.drawString("Total Money per/hr: "+pricePH, 22, 443);
  1775.                 g.drawString("Ores Collected: "+oreCollected, 262, 448);
  1776.                 g.setColor(color6);
  1777.                 g.fillRect(446, 313, 70, 24);
  1778.                 g.setFont(font2);
  1779.                 g.setColor(color1);
  1780.                 g.drawString("General Tab", 453, 332);
  1781.                 g.setColor(color5);
  1782.                 g.fillRect(376, 315, 68, 23);
  1783.                 g.setColor(color1);
  1784.                 g.drawString("Money Tab", 381, 333);
  1785.                 g.setColor(color4);
  1786.                 g.fillRect(6, 312, 75, 24);
  1787.                 g.setColor(color1);
  1788.                 g.drawString("Close Paint", 14, 331);
  1789.             }
  1790.             //END: Code generated using Enfilade's Easel
  1791.         } else {
  1792.             String s = "Status: " + status$
  1793.                     + " || Times hopped: " + hopped;
  1794.             g.setColor(color1);
  1795.             g.fillRoundRect(240, 104, s.length() * 6, 17, 16, 16);
  1796.             g.setFont(new Font("Arial", 1, 12));
  1797.             g.setColor(color2);
  1798.             g.drawString(s, 250, 117);
  1799.         }
  1800.     }
  1801.     //END: Code generated using Enfilade's Easel
  1802.     @Override
  1803.     public void mouseClicked(MouseEvent e) {
  1804.         p = e.getPoint();
  1805.         if(hide.contains(p) && !showPaint1){
  1806.             showPaint1 = true;
  1807.             showPaint2 = false;
  1808.             showPaint3 = false;
  1809.         } else if (hide.contains(p) && showPaint1)  {
  1810.             showPaint1 = false;
  1811.             showPaint2 = true;
  1812.             showPaint3 = false;
  1813.         }
  1814.         if (genTab.contains(p) && !showPaint2) {
  1815.             showPaint2 = true;
  1816.             showPaint1 = false;
  1817.             showPaint3 = false;
  1818.         }
  1819.         if (monTab.contains(p) && !showPaint3) {
  1820.             showPaint3 = true;
  1821.             showPaint2 = false;
  1822.             showPaint1 = false;
  1823.         }
  1824.  
  1825.     }
  1826.     @Override
  1827.     public void mouseEntered(MouseEvent e) {
  1828.         // TODO Auto-generated method stub
  1829.     }
  1830.     @Override
  1831.     public void mouseExited(MouseEvent e) {
  1832.         // TODO Auto-generated method stub
  1833.     }
  1834.     @Override
  1835.     public void mousePressed(MouseEvent e) {
  1836.         // TODO Auto-generated method stub
  1837.     }
  1838.     @Override
  1839.     public void mouseReleased(MouseEvent e) {
  1840.         // TODO Auto-generated method stub
  1841.     }
  1842.     //</editor-fold>
  1843.  
  1844.     //<editor-fold defaultstate="collapsed" desc="backup stuff">
  1845. //    public int bankOpen() {
  1846. //        if (atBank() && players.getMyPlayer().isIdle()) {
  1847. //            status = "Opening Bank.";
  1848. //            RSObject bankBooth = objects.getNearest(BANK);
  1849. //            if (random(1, 4) > 1) {
  1850. //                bankBooth.doAction("Use-quickly");
  1851. //            } else {
  1852. //                antiban.antiban();
  1853. //            }
  1854. //        }
  1855. //        return random(800, 1300);
  1856. //    }
  1857. //
  1858. //    public int depositBank() {
  1859. //        status = "Depositing ores";
  1860. //        bank.depositAll();
  1861. //        return random(300, 1100);
  1862. //    }
  1863. //
  1864. //    public int bankClose() {
  1865. //        if (bank.isOpen()) {
  1866. //            status = "Closing Bank.";
  1867. //            bank.close();
  1868. //            sleep(random(200, 1000));
  1869. //        }
  1870. //        return random(300, 800);
  1871. //    }
  1872. //
  1873. //    public void banking() {
  1874. //        if (!bank.isOpen()) {
  1875. //            bankOpen();
  1876. //            antiban.antiban();
  1877. //        }
  1878. //        if (bank.isOpen()) {
  1879. //            depositBank();
  1880. //            antiban.antiban();
  1881. //            sleep(random(100, 500));
  1882. //            banked++;
  1883. //        }
  1884. //
  1885. //        timer.reset();
  1886. //    }
  1887. //    RSTile toBank1[] = new RSTile[]{new RSTile(2970, 3239), new RSTile(2973, 3244),
  1888. //        new RSTile(2975, 3248), new RSTile(2976, 3253),
  1889. //        new RSTile(2978, 3258), new RSTile(2978, 3263),
  1890. //        new RSTile(2978, 3268), new RSTile(2980, 3273),
  1891. //        new RSTile(2986, 3277), new RSTile(2989, 3282),
  1892. //        new RSTile(2992, 3287), new RSTile(2997, 3292),
  1893. //        new RSTile(3001, 3296), new RSTile(3002, 3301),
  1894. //        new RSTile(3006, 3306), new RSTile(3006, 3312),
  1895. //        new RSTile(3006, 3316), new RSTile(3006, 3321),
  1896. //        new RSTile(3006, 3326), new RSTile(3006, 3331),
  1897. //        new RSTile(3006, 3336), new RSTile(3006, 3341),
  1898. //        new RSTile(3006, 3347), new RSTile(3008, 3352),
  1899. //        new RSTile(3008, 3357), new RSTile(3011, 3357),
  1900. //        new RSTile(3012, 3355)};
  1901. //    RSTile toMine1[] = new RSTile[]{new RSTile(3012, 3355), new RSTile(3011, 3359),
  1902. //        new RSTile(3008, 3359), new RSTile(3008, 3355),
  1903. //        new RSTile(3008, 3351), new RSTile(3008, 3346),
  1904. //        new RSTile(3008, 3341), new RSTile(3008, 3336),
  1905. //        new RSTile(3008, 3331), new RSTile(3007, 3326),
  1906. //        new RSTile(3007, 3321), new RSTile(3007, 3316),
  1907. //        new RSTile(3007, 3311), new RSTile(3002, 3305),
  1908. //        new RSTile(2997, 3300), new RSTile(2996, 3296),
  1909. //        new RSTile(2994, 3291), new RSTile(2994, 3286),
  1910. //        new RSTile(2994, 3281), new RSTile(2995, 3275),
  1911. //        new RSTile(2992, 3270), new RSTile(2988, 3266),
  1912. //        new RSTile(2983, 3262), new RSTile(2981, 3257),
  1913. //        new RSTile(2978, 3252), new RSTile(2973, 3248),
  1914. //        new RSTile(2971, 3244), new RSTile(2970, 3240)};
  1915.     //</editor-fold>
  1916. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement