Advertisement
deww1

ironPickUpBETA.java

May 14th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 59.29 KB | None | 0 0
  1.  
  2. import org.rsbot.script.*;
  3. import org.rsbot.script.wrappers.*;
  4. import org.rsbot.script.methods.*;
  5. import java.awt.*;
  6. import java.awt.Graphics;
  7. import java.awt.image.BufferedImage;
  8. import java.io.IOException;
  9. import java.net.MalformedURLException;
  10. import java.net.URL;
  11. import javax.imageio.ImageIO;
  12. import org.rsbot.event.listeners.PaintListener;
  13. import org.rsbot.script.Script;
  14. import java.io.BufferedReader;
  15. import java.io.InputStreamReader;
  16. import java.io.PrintWriter;
  17. import java.util.regex.Matcher;
  18. import java.util.regex.Pattern;
  19. import org.rsbot.Configuration;
  20. import java.net.InetAddress;
  21. import java.net.InetSocketAddress;
  22. import java.net.Socket;
  23. import java.net.SocketAddress;
  24.  
  25. @ScriptManifest(authors = {"Dew"}, keywords = {"iron", "Rimmington"}, name = "Iron Picker Uper", description = "<html><style>div{background-color:red; color:white;}</tyle><div><h3>Picks up Iron ore from powerminers in Rimmington Mines<h3></div></html>", version = 2.38, website = "http://www.dewbots.org/")
  26. public class ironPickUpBETA extends Script implements PaintListener {
  27.  
  28.     //<editor-fold defaultstate="collapsed" desc="Variables">
  29.     private int ORE = 440;
  30.     private int BANK1 = 11758;
  31.     private int BANK = 36788;
  32.     private int GP[] = {995};
  33.     RSObject BANK12;
  34.     public int invCount = 0;
  35.     private String status = "Setting up";
  36.     public String status$ = "";
  37.     public String antiBanStatus = "Setting up";
  38.     public boolean isDoingAnti = false;
  39.     ipuAntiban antiban = new ipuAntiban();
  40.     hopper hop = new hopper();
  41.     private int mouseHopx;
  42.     private int mouseHopy;
  43.     public boolean hasStarted = false;
  44.     public long startTime = 0;
  45.     public long millis = 0;
  46.     public long hours = 0;
  47.     public long minutes = 0;
  48.     public long seconds = 0;
  49.     public long last = 0;
  50.     public long noOreTime;
  51.  
  52.     public long millis2 = 0;
  53.     public long minutes2 = 0;
  54.     public long seconds2 = 0;
  55.  
  56.     public int oree;
  57.     public int switches = 0;
  58.     private int oreCollected = 0;
  59.     public int OreCollected = 0;
  60.     private int banked;
  61.     private int oreHr = 0;
  62.     private String MouseSpeed = "Unknown";
  63.     BufferedImage normal = null;
  64.     BufferedImage clicked = null;
  65.     public String cursorU;//Cursor unclicked
  66.     public String cursorC;//Cursor clicked
  67.  
  68.  
  69.     //GUI Stuff
  70.     public boolean useMsRandom = true; //use Mouse Random
  71.     public boolean doUpdate = true; //check for updates
  72.     public boolean wHop = true; //world hop
  73.     private org.rsbot.script.util.Timer timer = new org.rsbot.script.util.Timer(1000 * 30 * 8); //4 mins
  74.     private org.rsbot.script.util.Timer GUITimer = new org.rsbot.script.util.Timer(1000); //1 sec
  75.     public int maxPastWorlds = 10, maxPing = 150, //for worldswitcher
  76.             currentWorld = 0, newWorld = 0, hopped = 0, skillTotal = 0, wSwitches = 0;
  77.     public int pastWorld[] = new int[maxPastWorlds];
  78.     public boolean worldHopping = false;
  79.     public long switchTime = 0;
  80.     //</editor-fold>
  81.  
  82.     //<editor-fold defaultstate="collapsed" desc="Walking/Area">
  83.     RSTile mineTile = new RSTile(2970, 3240);
  84.     RSTile bankTile = new RSTile(3012, 3355);
  85.    
  86.     RSTile[] toBank = new RSTile[]{
  87.                         new RSTile(2969, 3239),
  88.                         new RSTile(2975, 3244),
  89.                         new RSTile(2983, 3253),
  90.                         new RSTile(2991, 3250),
  91.                         new RSTile(2996, 3246),
  92.                         new RSTile(3001, 3242),
  93.                         new RSTile(3007, 3240),
  94.                         new RSTile(3015, 3241),
  95.                         new RSTile(3021, 3241),
  96.                         new RSTile(3026, 3241),
  97.                         new RSTile(3030, 3236),
  98.                         new RSTile(3034, 3236),
  99.                         new RSTile(3038, 3236),
  100.                         new RSTile(3042, 3236),
  101.                         new RSTile(3046, 3236)} ;
  102.     RSTile toMine[] = new RSTile[]{
  103.                         new RSTile(3046, 3236),
  104.                         new RSTile(3042, 3236),
  105.                         new RSTile(3038, 3236),
  106.                         new RSTile(3034, 3236),
  107.                         new RSTile(3030, 3236),
  108.                         new RSTile(3026, 3241),
  109.                         new RSTile(3021, 3241),
  110.                         new RSTile(3015, 3241),
  111.                         new RSTile(3007, 3240),
  112.                         new RSTile(3001, 3242),
  113.                         new RSTile(2996, 3246),
  114.                         new RSTile(2991, 3250),
  115.                         new RSTile(2983, 3253),
  116.                         new RSTile(2975, 3244),
  117.                         new RSTile(2969, 3239) };
  118.  
  119.     ;
  120.  
  121.     private boolean atBank() {
  122.         RSArea area = new RSArea(new RSTile(3043, 3234), new RSTile(3051, 3237));
  123.         return area.contains(getMyPlayer().getLocation());
  124.     }
  125.  
  126.     private boolean atBank1() {
  127.         RSArea area = new RSArea(new RSTile(3018, 3358), new RSTile(3009, 3353));
  128.         return area.contains(getMyPlayer().getLocation());
  129.     }
  130.  
  131.     private boolean atMine() {
  132.         RSArea area = new RSArea(new RSTile(2974, 3244), new RSTile(2965, 3235));
  133.         return area.contains(getMyPlayer().getLocation());
  134.     }
  135.  
  136.     private void walkToMine() {
  137.         if (!atMine()) {
  138.             RSTilePath walkingMine = walking.newTilePath(toMine);
  139.             walkingMine.randomize(random(1, 2), random(1, 2));
  140.             walkingMine.traverse();
  141.             antiban.antiBanCamera();
  142.             status = "Walking to the mine...";
  143.             sleep(random(500, 1000));
  144.             timer.reset();
  145.             invCount = inventory.getCount(ORE);
  146.         }
  147.     }
  148.  
  149.     private void walkToBank() {
  150.         if (!atBank()) {
  151.             RSTilePath walkingBank = walking.newTilePath(toBank);
  152.             walkingBank.randomize(random(1, 2), random(1, 2));
  153.             walkingBank.traverse();
  154.             antiban.antiBanCamera();
  155.             status = "Walking to the bank...";
  156.             sleep(random(500, 1000));
  157.             timer.reset();
  158.         }
  159.     }
  160.     //</editor-fold>
  161.  
  162.     public void pickingUp() {
  163.         noOres();
  164.         if (atMine() && !inventory.isFull()) {
  165.             RSGroundItem ore = groundItems.getNearest(ORE);
  166.             int randNum = random(1, 10);
  167.             if (randNum > 1) {
  168.                 if (ore != null) {
  169.                     if (ore.isOnScreen()) {
  170.                         status = "Picking up ores";
  171.                         ore.doAction("Take");
  172.                         timer.reset();
  173.                     } else {
  174.                         camera.turnTo(ore.getLocation());
  175.                     }
  176.                 } else {
  177.                     noOres();
  178.                     sleep(100, 200);
  179.                 }
  180.             } else {
  181.                 antiban.antiBanCamera();
  182.             }
  183.         }
  184.     }
  185.  
  186.  
  187.     private void noOres() {
  188.         RSGroundItem item = groundItems.getNearest(ORE);
  189.         if (game.isLoggedIn()) {
  190.             if (atMine()) {
  191.                 if (item == null || !item.isOnScreen() || item == null && !item.isOnScreen()) {
  192.                     status = "Waiting for ores";
  193.                     antiban.antiban();
  194.                     if (!timer.isRunning()) {
  195.                         if (wHop == true) {
  196.                             hop.worldHop(false);
  197.                             timer.setEndIn(1000 * 60 * 8);
  198.                         }
  199.                     }
  200.                 }
  201.             }
  202.         }
  203.     }
  204.  
  205.     private void banking1() {
  206.         if (atBank()) {
  207.         RSObject depositBox = objects.getNearest(BANK);
  208.         if (!interfaces.get(11).isValid()) {
  209.             status = "inter 11 is not valid!";
  210.             if (depositBox != null && depositBox.isOnScreen()) {
  211.                 status = "box is on screen.";
  212.                 if (calc.distanceTo(depositBox.getLocation()) < 2) {
  213.                     status = "We are less than two tiles away from box.";
  214.                     log("Distance is less than 2");
  215.                 depositBox.doAction("Deposit");
  216.                 status = "Opening box.";
  217.                 sleep(1200, 2000);
  218.                 } else {
  219.                     walking.walkTileOnScreen(depositBox.getLocation());
  220.                 }
  221.             }
  222.         }
  223.         if (interfaces.get(11).isValid()) {
  224.             status = "inter 11 is valid!";
  225.             interfaces.waitFor(interfaces.get(11), false, 1000*30*2);
  226.             if (game.getCurrentTab() != 4) {
  227.                 status = "current tab is not 4";
  228.             log("box is valid");
  229.             status = "clicking on comp 1 to deposit all";
  230.             interfaces.get(11).getComponent(17).getComponent(1).doAction("Deposit-All");
  231.             sleep(1000, 1500);
  232.             if (bank.getBoxCount() != 28) {
  233.                 status = "count is not 28 closing bank.";
  234.                 bank.close();
  235.                 log("Box is valid");
  236.             }
  237.             log("Box count is 28");
  238.         }
  239.             }
  240.         log("Box is not valid");
  241.         }
  242.     }
  243.    
  244.     private void banking() {
  245.         if (atBank()) {
  246.             RSObject depositBox = objects.getNearest(BANK);
  247.             if (depositBox.isOnScreen()) {
  248.                 depositBox.doAction("Deposit");
  249.                 sleep(random(2000, 4000));
  250.                 mouse.click(349, 280, 5, 5, true);
  251.                 sleep(random(1000, 4000));
  252.                 bank.close();
  253.             }
  254.         }
  255.     }
  256.  
  257.     private void lowHP() {
  258.         combat.getHealth();
  259.         if (combat.getHealth() < 30) {
  260.             if (atBank()) {
  261.                 int rand = random(1, 2);
  262.                 if (rand == 1) {
  263.                     antiban.antiban();
  264.                 } else {
  265.                     antiban.antiBanCamera();
  266.                 }
  267.                 sleep(100, 200);
  268.             }
  269.             if (!atMine() || !atBank()) {
  270.                 walking.setRun(true);
  271.             }
  272.         } else if (combat.getHealth() > 29) {
  273.             return;
  274.         }
  275.     }
  276.  
  277.     private void runCapable() {
  278.         walking.getEnergy();
  279.         if (!walking.isRunEnabled() && walking.getEnergy() >= random(60, 80)) {
  280.             walking.setRun(true);
  281.         }
  282.     }
  283.  
  284.     @Override
  285.     public boolean onStart() {
  286.         if (!game.isFixed()) {
  287.             onFinish();
  288.             log("Please set game to fixed!");
  289.         }
  290.         startTime = System.currentTimeMillis();
  291.         cursorU = "http://i360.photobucket.com/albums/oo47/perez048/mouseReg.png";
  292.         cursorC = "http://i360.photobucket.com/albums/oo47/perez048/mouseClicked.png";
  293.         ipuGUI GUI = new ipuGUI();
  294.         GUI.setVisible(true);
  295.         while (GUI.isVisible()) {
  296.             GUITimer.setEndIn(1000);
  297.         }
  298.         if (!GUITimer.isRunning())
  299.             log("GUITimer has stopped! We will start the script!");
  300. //        if (doUpdate == true) {
  301. //            if (checkForUpdates() == false) {
  302. //                log(Color.BLUE, "Server 1 update failed, attempting server 2.");
  303. //                checkForUpdates2();
  304. //            }
  305. //        }
  306.         log("This is Beta Version 2.35-Fixed some stuff! :)");
  307.         try {
  308.               final URL cursorURL = new URL(cursorU);
  309.               final URL cursor80URL = new URL(cursorC);
  310.             normal = ImageIO.read(cursorURL);
  311.             clicked = ImageIO.read(cursor80URL);
  312.         } catch (MalformedURLException e) {
  313.             log("Unable to buffer cursor.");
  314.         } catch (IOException e) {
  315.             log("Unable to open cursor image.");
  316.         }
  317.  
  318.        
  319.         return true;
  320.     }
  321.  
  322.     public int loop() {
  323.         if (!atBank() || !bank.isDepositOpen()) {
  324.         if (invCount < inventory.getCount(ORE)) {
  325.             oreCollected++;
  326.             invCount = inventory.getCount(ORE);
  327.         }
  328.         runCapable();
  329.         if (!atBank()) {
  330.         noOres();
  331.         }
  332.         lowHP();
  333.         }
  334.         mouseSpeed();
  335.         if(atBank()) {
  336.             if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
  337.                 runCapable();
  338.                 walkToMine();
  339.             }
  340.             if (interfaces.get(11).isValid() && bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
  341.                 banking();
  342.             }
  343.         }
  344.         if (atMine()) {
  345.             if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
  346.                 int rand = random(1, 150);
  347.                 if (rand > 3) {
  348.                     pickingUp();
  349.                 } else {
  350.                     antiban.antiBanCamera();
  351.                 }
  352.             }
  353.             if (bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
  354.                 runCapable();
  355.                 walkToBank();
  356.             }
  357.         }
  358.         if (!atBank() || !atMine()) {
  359.             if (bank.getBoxCount() == 0 || inventory.getCount() < 27) {
  360.                 walkToMine();
  361.             }
  362.             if (bank.getBoxCount() > 0 || inventory.getCount() >= 27) {
  363.                 walkToBank();
  364.             }
  365.         }
  366.         return random(1000,1200);
  367.     }
  368.  
  369.     @Override
  370.     public void onFinish() {
  371.         env.saveScreenshot(false);
  372.         log("Total Ores Collected: "+oreCollected+" ores.");
  373.         if (wHop == true) {
  374.             log("Total world Hops: "+hopped);
  375.         }
  376.         log("http://www.powerbot.org/vb/showthread.php?t=770408 - my script thread. :)");
  377.     }
  378.  
  379.  
  380.     //<editor-fold defaultstate="collapsed" desc="MouseStuff">
  381.     private void mouseSpeed() {
  382.         if (useMsRandom == true) {
  383.             int rand = random(1, 5);
  384.             if (rand == 1) {
  385.                 mouse.setSpeed(random(4, 7));
  386.             }
  387.             if (rand == 2) {
  388.                 mouse.setSpeed(random(5, 10));
  389.             }
  390.             if (rand == 3) {
  391.                 mouse.setSpeed(random(2, 5));
  392.             }
  393.             if (rand == 4) {
  394.                 mouse.setSpeed(random(2, 10));
  395.             }
  396.         } else {
  397.             mouse.setSpeed(random(4, 6));
  398.         }
  399.         mouseSet();
  400.     }
  401.  
  402.     private void mouseSet() {
  403.         if (mouse.getSpeed() >= 1 && mouse.getSpeed() <= 3) {
  404.             MouseSpeed = "Extremely fast";
  405.         }
  406.         if (mouse.getSpeed() >= 4 && mouse.getSpeed() <= 6) {
  407.             MouseSpeed = "Regular";
  408.         }
  409.         if (mouse.getSpeed() >= 7 && mouse.getSpeed() <= 10) {
  410.             MouseSpeed = "Slow";
  411.         }
  412.     }
  413.     //</editor-fold>
  414.  
  415.     //<editor-fold defaultstate="collapsed" desc="antiban">
  416.     public class ipuAntiban {
  417.  
  418.         private void antiban() {
  419.         if (random(1, 2) == 1) {
  420.             antiBan1();
  421.         } else {
  422.             antiBan2();
  423.         }
  424.     }
  425.  
  426.         private void antiBan1() {
  427.         int randomProd = random(1, 40);
  428.         if (randomProd >= 2 && randomProd <= 4) {
  429.             antiBanStatus = "Pause for a few seconds...";
  430.             sleep(1000, 2500);
  431.         }
  432.         if (randomProd >= 32) {
  433.             antiBanStatus = "Moving mouse Randomly..";
  434.             mouse.moveRandomly(100, 600);
  435.         } else {
  436.             sleep(10, 30);
  437.         }
  438.     }
  439.  
  440.         public void antiBan2() {
  441.         int antiType = random(0, 1);
  442.         int b = random(0, 10);
  443.         switch (antiType) {
  444.             case 0:
  445.                 switch (b) {
  446.                     case 1:
  447.                         if (random(0, 10) == 5) {
  448.                             antiBanStatus = "Moving mouse randomly...";
  449.                             mouse.moveSlightly();
  450.                             sleep(200, 600);
  451.                             mouse.moveRandomly(150, 350);
  452.                         }
  453.                         break;
  454.                     case 2:
  455.                         if (random(0, 13) == 2) {
  456.                             antiBanStatus = "Changing camera angle...";
  457.                             camera.setAngle(random(30, 70));
  458.                             sleep(400, 1200);
  459.                         }
  460.                         break;
  461.                     case 3:
  462.                         if (random(0, 24) == 6) {
  463.                             antiBanStatus = "Moving mouse of screen...";
  464.                             mouse.moveOffScreen();
  465.                             sleep(random(600, random(1200, 2000)));
  466.                         }
  467.                         break;
  468.                     case 5:
  469.                         if (random(0, 28) == 0 && !bank.isOpen()) {
  470.                             antiBanStatus = "Checking friends list...";
  471.                             game.openTab(9);
  472.                             sleep(random(1000, 3400));
  473.                         } else if (game.getCurrentTab() != Game.TAB_INVENTORY) {
  474.                             game.openTab(4);
  475.                         }
  476.                     default:
  477.                         break;
  478.                 }
  479.             case 1:
  480.                 switch (random(0, 70)) {
  481.                     case 1:
  482.                         antiBanStatus = "Mouse hopping...";
  483.                         camera.setAngle(random(0, 90));
  484.                         sleep(500, 1000);
  485.                         if (random(1, 3) == 1) {
  486.                             mouseHopx = random(0, 760);
  487.                             mouseHopy = random(0, 500);
  488.                             mouse.hop(mouseHopx, mouseHopy);
  489.                         }
  490.                         break;
  491.                     case 2:
  492.                         antiBanStatus = "Mouse hopping...";
  493.                         camera.setAngle(random(90, 180));
  494.                         sleep(500, 1000);
  495.                         if (random(1, 3) == 1) {
  496.                             mouseHopx = random(0, 760);
  497.                             mouseHopy = random(0, 500);
  498.                             mouse.hop(mouseHopx, mouseHopy);
  499.                         }
  500.                         break;
  501.                     case 3:
  502.                         antiBanStatus = "Mouse hopping...";
  503.                         mouse.moveSlightly();
  504.                         camera.setAngle(random(90, 180));
  505.                         if (random(1, 3) == 1) {
  506.                             mouseHopx = random(0, 760);
  507.                             mouseHopy = random(0, 500);
  508.                             mouse.hop(mouseHopx, mouseHopy);
  509.                         }
  510.                         break;
  511.                     case 4:
  512.                         antiBanStatus = "Mouse hopping...";
  513.                         if (random(1, 3) == 1) {
  514.                             mouseHopx = random(0, 760);
  515.                             mouseHopy = random(0, 500);
  516.                             mouse.hop(mouseHopx, mouseHopy);
  517.                         } else {
  518.                             antiBanStatus = "Mouse hopping...";
  519.                             if (random(1, 3) == 1) {
  520.                                 mouseHopx = random(0, 760);
  521.                                 mouseHopy = random(0, 500);
  522.                                 mouse.hop(mouseHopx, mouseHopy);
  523.                             }
  524.                         }
  525.                         break;
  526.                     case 5:
  527.                         antiBanStatus = "Mouse hopping...";
  528.                         camera.setAngle(random(180, 360));
  529.                         sleep(500, 1000);
  530.                         if (random(1, 3) == 1) {
  531.                             mouseHopx = random(0, 760);
  532.                             mouseHopy = random(0, 500);
  533.                             mouse.hop(mouseHopx, mouseHopy);
  534.                         }
  535.                         break;
  536.                 }
  537.         }
  538.     }
  539.  
  540.         public void antiBanCamera() {
  541.         isDoingAnti = true;
  542.         int rand = random(1, 30);
  543.         if (rand >= 1 && rand <= 3) {
  544.             antiBanStatus = "randomizing Camera Movement...";
  545.             camera.moveRandomly(random(2000, 5500));
  546.             isDoingAnti = false;
  547.         }
  548.         if (rand >= 4 && rand <= 5) {
  549.             antiBanStatus = "randomizing Camera Angle...";
  550.             camera.setAngle(random(10, 100));
  551.             isDoingAnti = false;
  552.         }
  553.         if (rand == 6) {
  554.             antiBanStatus = "randomizing Camera Pitch...";
  555.             camera.setPitch(random(40, 68));
  556.             isDoingAnti = false;
  557.         }
  558.         if (rand == 7) {
  559.             antiBanStatus = "randomizing Camera Pitch...";
  560.             camera.setPitch(random(20, 45));
  561.             isDoingAnti = false;
  562.         }
  563.         if (rand == 8) {
  564.             antiBanStatus = "randomizing Camera Pitch...";
  565.             camera.setPitch(random(68, 90));
  566.             isDoingAnti = false;
  567.         }
  568.         if (rand >= 9) {
  569.             isDoingAnti = false;
  570.         }
  571.     }
  572.     }
  573.     //</editor-fold>
  574.  
  575.     //<editor-fold defaultstate="collapsed" desc="GUI">
  576.     public class ipuGUI extends javax.swing.JFrame {
  577.  
  578.         private static final long serialVersionUID = 1L;
  579.  
  580.         public ipuGUI() {
  581.             initComponents();
  582.         }
  583.  
  584.         private void initComponents() {
  585.  
  586.             jPanel1 = new javax.swing.JPanel();
  587.             jLabel1 = new javax.swing.JLabel();
  588.             switcher = new javax.swing.JCheckBox();
  589.             update = new javax.swing.JCheckBox();
  590.             jLabel2 = new javax.swing.JLabel();
  591.             start = new javax.swing.JButton();
  592.             jLabel5 = new javax.swing.JLabel();
  593.             switcher1 = new javax.swing.JCheckBox();
  594.             jLabel3 = new javax.swing.JLabel();
  595.             jLabel4 = new javax.swing.JLabel();
  596.  
  597.             setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  598.             setTitle("Iron Picker Uper GUI");
  599.             setAlwaysOnTop(true);
  600.             setResizable(false);
  601.             setVisible(true);
  602.  
  603.  
  604.             jPanel1.setBackground(new java.awt.Color(177, 158, 58));
  605.  
  606.             jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
  607.             jLabel1.setForeground(new java.awt.Color(96, 71, 8));
  608.             jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  609.             jLabel1.setText("Iron Picker Uper Settings");
  610.  
  611.             switcher.setBackground(new java.awt.Color(177, 158, 58));
  612.             switcher.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
  613.             switcher.setForeground(new java.awt.Color(96, 71, 8));
  614.             switcher.setText("Don't use World Switcher?");
  615.             switcher.addActionListener(new java.awt.event.ActionListener() {
  616.  
  617.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  618.                     W_H_ActionPreformed(evt);
  619.                 }
  620.             });
  621.  
  622.             update.setVisible(false);
  623.             update.setBackground(new java.awt.Color(177, 158, 58));
  624.             update.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
  625.             update.setForeground(new java.awt.Color(96, 71, 8));
  626.             update.setText("Don't check for Updates");
  627.             update.addActionListener(new java.awt.event.ActionListener() {
  628.  
  629.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  630.                     updaterActionPreformed(evt);
  631.                 }
  632.             });
  633.  
  634.             jLabel2.setForeground(new java.awt.Color(96, 71, 8));
  635.             jLabel2.setText("If unchecked, this will not check for updates");
  636.  
  637.             start.setBackground(new java.awt.Color(177, 158, 58));
  638.             start.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
  639.             start.setForeground(new java.awt.Color(96, 71, 8));
  640.             start.setText("Start Script");
  641.             start.setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
  642.             start.addActionListener(new java.awt.event.ActionListener() {
  643.  
  644.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  645.                     startScriptActionPerformed(evt);
  646.                 }
  647.             });
  648.  
  649.             jLabel5.setForeground(new java.awt.Color(96, 71, 8));
  650.             jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  651.             jLabel5.setText("Script Written by Dew/Deww1(Powerbot)");
  652.             jLabel5.setEnabled(false);
  653.  
  654.             switcher1.setVisible(false);
  655.             switcher1.setBackground(new java.awt.Color(177, 158, 58));
  656.             switcher1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
  657.             switcher1.setForeground(new java.awt.Color(96, 71, 8));
  658.             switcher1.setText("Don't use Mouse Speed Randomizer?");
  659.             switcher1.addActionListener(new java.awt.event.ActionListener() {
  660.  
  661.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  662.                     useMsActionPerformed(evt);
  663.                 }
  664.             });
  665.  
  666.             jLabel3.setForeground(new java.awt.Color(96, 71, 8));
  667.             jLabel3.setText("If no ores are available it will switch worlds");
  668.  
  669.             jLabel4.setVisible(false);
  670.             jLabel4.setForeground(new java.awt.Color(96, 71, 8));
  671.             jLabel4.setText("This will randomize speeds every second");
  672.  
  673.             javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  674.             jPanel1.setLayout(jPanel1Layout);
  675.             jPanel1Layout.setHorizontalGroup(
  676.                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addContainerGap(57, Short.MAX_VALUE).addComponent(start, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(80, 80, 80)).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(update).addContainerGap(237, Short.MAX_VALUE)).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(switcher).addContainerGap(265, Short.MAX_VALUE)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addContainerGap(190, Short.MAX_VALUE).addComponent(jLabel2).addContainerGap()).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup().addContainerGap(165, Short.MAX_VALUE).addComponent(jLabel3).addGap(89, 89, 89)).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE).addContainerGap()).addGroup(jPanel1Layout.createSequentialGroup().addGap(168, 168, 168).addComponent(jLabel4).addContainerGap(97, Short.MAX_VALUE)).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(switcher1).addContainerGap(179, Short.MAX_VALUE)));
  677.             jPanel1Layout.setVerticalGroup(
  678.                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(update).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(switcher).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel3).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(switcher1).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel4).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE).addComponent(start, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap()));
  679.  
  680.             javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  681.             getContentPane().setLayout(layout);
  682.             layout.setHorizontalGroup(
  683.                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
  684.             layout.setVerticalGroup(
  685.                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
  686.  
  687.             pack();
  688.         }
  689.  
  690.         private void useMsActionPerformed(java.awt.event.ActionEvent evt) {
  691.             if (switcher.isSelected()) {
  692.                 useMsRandom = false; //random mouse speed
  693.                 log(Color.GREEN, "We will  NOT be using Random Mouse Speeds!");
  694.             } else {
  695.                 useMsRandom = true; //no random mouse speed
  696.                 log(Color.YELLOW, "We will be using Random Mouse Speeds!");
  697.             }
  698.         }
  699.  
  700.         private void updaterActionPreformed(java.awt.event.ActionEvent evt) {
  701.             if (update.isSelected()) {
  702.                 doUpdate = false; //Don't check
  703.                 log(Color.YELLOW, "We will NOT be checking for updates!");
  704.             } else {
  705.                 doUpdate = true; //Do check
  706.                 log(Color.green, "We will be checking for updates!");
  707.             }
  708.         }
  709.  
  710.         private void W_H_ActionPreformed(java.awt.event.ActionEvent evt) {
  711.             if (switcher.isSelected()) {
  712.                 wHop = false; //world hop
  713.                 log(Color.GREEN, "We will NOT be world hopping!");
  714.             } else {
  715.                 wHop = true; //don't world hop
  716.                 log(Color.YELLOW, "We will be world hopping!");
  717.             }
  718.         }
  719.  
  720.         private void startScriptActionPerformed(java.awt.event.ActionEvent evt) {
  721.             setVisible(false);
  722.             dispose();
  723.         }
  724.         // Variables declaration - do not modify
  725.         private javax.swing.JLabel jLabel1;
  726.         private javax.swing.JLabel jLabel2;
  727.         private javax.swing.JLabel jLabel3;
  728.         private javax.swing.JLabel jLabel4;
  729.         private javax.swing.JLabel jLabel5;
  730.         private javax.swing.JPanel jPanel1;
  731.         private javax.swing.JButton start;
  732.         private javax.swing.JCheckBox switcher;
  733.         private javax.swing.JCheckBox switcher1;
  734.         private javax.swing.JCheckBox update;
  735.         // End of variables declaration
  736.  
  737.     }//</editor-fold>
  738.  
  739.     //<editor-fold defaultstate="collapsed" desc="Updater">
  740. //    private static final String UPDATER_FILE_NAME = "ironPickUp.java";
  741. //    private static final String UPDATER_URL1 = "";
  742. //    private static final String UPDATER_URL = "";
  743. //    private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)");
  744. //
  745. //
  746. //    private boolean checkForUpdates() {
  747. //        try {
  748. //            /* Get the current version from the Script Manifest annotation defined at the top of your script's class */
  749. //            double currentVer = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
  750. //            double newVer = -1;
  751. //            URL url = new URL(UPDATER_URL);
  752. //            /* Open a stream to the newest script file hosted on your server */
  753. //            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  754. //            String line, lines = "";
  755. //            Matcher m;
  756. //            /* Look for the "version = x.x" string in the newer file to figure out the newest version number */
  757. //            while ((line = in.readLine()) != null) {
  758. //                lines += line + "\n";
  759. //                if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
  760. //                    newVer = Double.parseDouble(m.group(1));
  761. //                    break;
  762. //                }
  763. //            }
  764. //            /* Check if the updater was unable to read the newest version number */
  765. //            if (newVer < 0) {
  766. //                in.close();
  767. //                log("Unable to find the new version number. Update failed");
  768. //                return false;
  769. //            }
  770. //            /* Compare the current version to the newest. */
  771. //            if (currentVer == newVer) {
  772. //                in.close();
  773. //                log("You already have the latest version of the script.");
  774. //                return true;
  775. //            }
  776. //            /* The current version is less than the newest version, so we need to download it */
  777. //            log("Update found! Downloading version " + newVer);
  778. //            /* Figure out where to save the file */
  779. //            String scriptFilePath = Configuration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME;
  780. //            PrintWriter out = new PrintWriter(scriptFilePath);
  781. //            /* Print the cached lines from the version checking */
  782. //            out.print(lines);
  783. //            /* Print the rest of the file */
  784. //            while ((line = in.readLine()) != null) {
  785. //                out.println(line);
  786. //            }
  787. //            /* Close the streams */
  788. //            out.close();
  789. //            in.close();
  790. //            log("Successfully saved " + UPDATER_FILE_NAME + " to " + Configuration.Paths.getScriptsSourcesDirectory());
  791. //            log("Compiling...");
  792. //            try {
  793. //                /* Attempt to compile the downloaded version */
  794. //                Runtime.getRuntime().exec(new String[]{
  795. //                            "javac",
  796. //                            "-classpath",
  797. //                            "RSBot.jar",
  798. //                            scriptFilePath
  799. //                        });
  800. //            } catch (Exception ex) {
  801. //                log("Could not compile the script. Please manually compile to finish the update.");
  802. //                return true;
  803. //            }
  804. //            log(Color.orange, "Update successful!");
  805. //            log(Color.green, "The new version will appear near the bottom of the script selector.");
  806. //            log(Color.red, "Stop and restart the script to run the newer version.");
  807. //            return true;
  808. //        } catch (IOException e) {
  809. //            log(e.toString());
  810. //            log("Update failed.");
  811. //        }
  812. //        return false;
  813. //    }
  814. //
  815. //    private boolean checkForUpdates2() {
  816. //        try {
  817. //            /* Get the current version from the Script Manifest annotation defined at the top of your script's class */
  818. //            double currentVer = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
  819. //            double newVer = -1;
  820. //            URL url = new URL(UPDATER_URL1);
  821. //            /* Open a stream to the newest script file hosted on your server */
  822. //            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  823. //            String line, lines = "";
  824. //            Matcher m;
  825. //            /* Look for the "version = x.x" string in the newer file to figure out the newest version number */
  826. //            while ((line = in.readLine()) != null) {
  827. //                lines += line + "\n";
  828. //                if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
  829. //                    newVer = Double.parseDouble(m.group(1));
  830. //                    break;
  831. //                }
  832. //            }
  833. //            /* Check if the updater was unable to read the newest version number */
  834. //            if (newVer < 0) {
  835. //                in.close();
  836. //                log("Unable to find the new version number. Update failed");
  837. //                return false;
  838. //            }
  839. //            /* Compare the current version to the newest. */
  840. //            if (currentVer == newVer) {
  841. //                in.close();
  842. //                log("You already have the latest version of the script.");
  843. //                return false;
  844. //            }
  845. //            /* The current version is less than the newest version, so we need to download it */
  846. //            log("Update found! Downloading version " + newVer);
  847. //            /* Figure out where to save the file */
  848. //            String scriptFilePath = Configuration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME;
  849. //            PrintWriter out = new PrintWriter(scriptFilePath);
  850. //            /* Print the cached lines from the version checking */
  851. //            out.print(lines);
  852. //            /* Print the rest of the file */
  853. //            while ((line = in.readLine()) != null) {
  854. //                out.println(line);
  855. //            }
  856. //            /* Close the streams */
  857. //            out.close();
  858. //            in.close();
  859. //            log("Successfully saved " + UPDATER_FILE_NAME + " to " + Configuration.Paths.getScriptsSourcesDirectory());
  860. //            log("Compiling...");
  861. //            try {
  862. //                /* Attempt to compile the downloaded version */
  863. //                Runtime.getRuntime().exec(new String[]{
  864. //                            "javac",
  865. //                            "-classpath",
  866. //                            "RSBot.jar",
  867. //                            scriptFilePath
  868. //                        });
  869. //            } catch (Exception ex) {
  870. //                log("Could not compile the script. Please manually compile to finish the update.");
  871. //                return false;
  872. //            }
  873. //            log(Color.orange, "Update successful!");
  874. //            log(Color.green, "The new version will appear near the bottom of the script selector.");
  875. //            log(Color.red, "Stop and restart the script to run the newer version.");
  876. //            return true;
  877. //        } catch (IOException e) {
  878. //            log(e.toString());
  879. //            log("Update failed.");
  880. //        }
  881. //        return false;
  882. //    }
  883.     //</editor-fold>
  884.  
  885.     //<editor-fold defaultstate="collapsed" desc="world hopper">
  886.     public class hopper {
  887.  
  888.         public void worldHop(boolean members) {
  889.         worldHop(members, 150, 1000);
  890.     }
  891.  
  892.         public void worldHop(boolean members, int maxping) {
  893.         worldHop(members, maxping, 1000);
  894.     }
  895.  
  896.         public void worldHop(boolean members, int maxping, int maxpop) {
  897.  
  898.         final int LOBBY_PARENT = 906;
  899.         final int WORLD_SELECT_TAB_PARENT = 910;
  900.         final int WORLD_SELECT_COM = 77;
  901.         final int WORLD_NUMBER_COM = 69;
  902.         final int WORLD_POPULATION_COM = 71;
  903.         final int WORLD_TYPE_COM = 74;
  904.         final int WORLD_SELECT_BUTTON_COM = 188;
  905.         final int WORLD_SELECT_BUTTON_BG_COM = 12;
  906.         final int WORLD_SELECT_TAB_ACTIVE = 4671;
  907.         final int WORLD_FULL_BACK_BUTTON_COM = 233;
  908.         final int CURRENT_WORLD_COM = 11;
  909.         final int SORT_POPULATION_BUTTON_PARENT = 30;
  910.         final int SORT_PING_BUTTON_PARENT = 45;
  911.         final int SORT_LOOTSHARE_BUTTON_PARENT = 47;
  912.         final int SORT_TYPE_BUTTON_PARENT = 49;
  913.         final int SORT_ACTIVITY_BUTTON_PARENT = 52;
  914.         final int SORT_WORLD_BUTTON_PARENT = 55;
  915.         final int SCROLL_BAR_PARENT = 86;
  916.         final int HIGH_RISK_WARN_PARENT = 93;
  917.         final int PLAY_BUTTON_COM = 171;
  918.         final int RETURN_TEXT_COM = 221;
  919.         final int SUBSCRIBE_BACK_BUTTON_COM = 233;
  920.         final int CONNECT_ERROR_BACK_BUTTON_COM = 42;
  921.         final int SKILL_WORLD_BACK_BUTTON_COM = 228;
  922.         final int SKILL_WORLD_NUMBER = 113;
  923.  
  924.         long whileTimer = 0;
  925.  
  926.         log("Hopping worlds");
  927.         status$ = "Hopping worlds";
  928.  
  929.         // logout
  930.         while (game.isLoggedIn()) {
  931.             if (game.logout(true)) {
  932.                 sleep(1000, 1500);
  933.                 while (game.getClientState() != 7) {
  934.                     sleep(random(200, 500));
  935.                 }
  936.             }
  937.         }
  938.  
  939.         status$ = "Selecting new world";
  940.         sleep(random(1500, 2000));
  941.  
  942.         // click world select tab (if needed)
  943.         RSComponent worldSelectTab = interfaces.getComponent(LOBBY_PARENT,
  944.                 WORLD_SELECT_BUTTON_BG_COM);
  945.  
  946.         whileTimer = System.currentTimeMillis();
  947.  
  948.         while (worldSelectTab.getBackgroundColor() != WORLD_SELECT_TAB_ACTIVE
  949.                 && System.currentTimeMillis() - whileTimer < 90000) {
  950.             if (interfaces.get(LOBBY_PARENT).getComponent(WORLD_SELECT_BUTTON_BG_COM).doClick()) {
  951.                 //interfaces.getComponent(LOBBY_PARENT, WORLD_SELECT_BUTTON_BG_COM).doClick();
  952.                 sleep(random(1500, 2000));
  953.             }
  954.         }
  955.  
  956.         // get current world
  957.         String cW = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  958.                 CURRENT_WORLD_COM).getText();
  959.         String[] cWS = cW.split(" ");
  960.         currentWorld = Integer.parseInt(cWS[1]);
  961.         newWorld = currentWorld;
  962.  
  963.         // randomly sort worlds
  964.         if (random(0, 10) < 5) {
  965.             RSComponent com = null;
  966.             switch (random(0, 6)) {
  967.                 case 0: // population
  968.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  969.                             SORT_POPULATION_BUTTON_PARENT).getComponent(
  970.                             random(0, 2));
  971.                     break;
  972.                 case 1: // ping
  973.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  974.                             SORT_PING_BUTTON_PARENT).getComponent(random(0, 2));
  975.                     break;
  976.                 case 2: // loot share
  977.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  978.                             SORT_LOOTSHARE_BUTTON_PARENT).getComponent(random(0, 2));
  979.                     break;
  980.                 case 3: // type
  981.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  982.                             SORT_TYPE_BUTTON_PARENT).getComponent(random(0, 2));
  983.                     break;
  984.                 case 4: // activity
  985.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  986.                             SORT_ACTIVITY_BUTTON_PARENT).getComponent(random(0, 2));
  987.                     break;
  988.                 case 5: // world
  989.                     com = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  990.                             SORT_WORLD_BUTTON_PARENT).getComponent(random(0, 2));
  991.                     break;
  992.             }
  993.             if (com.doClick()) {
  994.                 sleep(random(1250, 1500));
  995.             }
  996.         }
  997.  
  998.         // check if we should sort by ptp/ftp
  999.         boolean sort = false;
  1000.         RSComponent[] wt = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1001.                 WORLD_TYPE_COM).getComponents();
  1002.         for (int i = 0; i < 10; i++) {
  1003.             if ((members && !wt[i].getText().contains("Members"))
  1004.                     || (!members && wt[i].getText().contains("Members"))) {
  1005.                 sort = true;
  1006.                 break;
  1007.             }
  1008.         }
  1009.  
  1010.         // sort by ptp/ftp (if needed)
  1011.         if (sort) {
  1012.             status$ = "Sorting worlds by type";
  1013.             if (interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1014.                     SORT_TYPE_BUTTON_PARENT).getComponent(members ? 0 : 1).doClick()) {
  1015.                 sleep(random(1000, 1500));
  1016.             }
  1017.         }
  1018.  
  1019.         /*-PICK-NEXT-WORLD-*/
  1020.         whileTimer = System.currentTimeMillis();
  1021.         while (currentWorld == newWorld
  1022.                 && System.currentTimeMillis() - whileTimer < 90000) {
  1023.             RSComponent worldToHop = null;
  1024.             RSComponent[] comWorldNumber = interfaces.getComponent(
  1025.                     WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
  1026.             int world = 0;
  1027.             int pop = 2000;
  1028.             int ping = -1;
  1029.             boolean member = false;
  1030.             while (worldToHop == null) {
  1031.                 for (int i = 0; i < comWorldNumber.length - 1; i++) {
  1032.                     RSComponent[] comWorldSelect = interfaces.getComponent(
  1033.                             WORLD_SELECT_TAB_PARENT, WORLD_SELECT_COM).getComponents();
  1034.                     RSComponent[] comWorldPopulation = interfaces.getComponent(
  1035.                             WORLD_SELECT_TAB_PARENT, WORLD_POPULATION_COM).getComponents();
  1036.                     RSComponent[] comWorldType = interfaces.getComponent(
  1037.                             WORLD_SELECT_TAB_PARENT, WORLD_TYPE_COM).getComponents();
  1038.                     comWorldNumber = interfaces.getComponent(
  1039.                             WORLD_SELECT_TAB_PARENT, WORLD_NUMBER_COM).getComponents();
  1040.                     try {
  1041.                         world = Integer.parseInt(comWorldNumber[i].getText());
  1042.                     } catch (NumberFormatException nfe) {
  1043.                         world = 0;
  1044.                     } catch (ArrayIndexOutOfBoundsException aie) {
  1045.                         world = 0;
  1046.                     }
  1047.                     if (world == SKILL_WORLD_NUMBER && skillTotal < 1000) {
  1048.                         world = 0;
  1049.                     }
  1050.                     try {
  1051.                         pop = Integer.parseInt(comWorldPopulation[i].getText());
  1052.                     } catch (NumberFormatException nfe) {
  1053.                         pop = 2000;
  1054.                     } catch (ArrayIndexOutOfBoundsException aie) {
  1055.                         pop = 2000;
  1056.                     }
  1057.                     try {
  1058.                         if (comWorldType[i].getText().contains("Members")) {
  1059.                             member = true;
  1060.                         }
  1061.                     } catch (ArrayIndexOutOfBoundsException aie) {
  1062.                     }
  1063.                     if (world != 0 && !isPastWorld(world)
  1064.                             && world != currentWorld && pop < maxpop && pop > 0
  1065.                             && member == members) {
  1066.                         ping = pingHost("world" + world + ".runescape.com",
  1067.                                 maxPing + 50);
  1068.                     } else {
  1069.                         ping = -1;
  1070.                     }
  1071.                     if (ping < maxping && ping > 0) {
  1072.                         log("World " + world + " selected.");
  1073.                         worldToHop = comWorldSelect[i];
  1074.                     }
  1075.                     if (worldToHop != null) {
  1076.                         break;
  1077.                     }
  1078.                 }
  1079.                 sleep(random(50, 150));
  1080.             }
  1081.             if (worldToHop != null) {
  1082.                 int w = -1;
  1083.                 String[] split = interfaces.getComponent(910, 8).getText().split(" ");
  1084.                 try {
  1085.                     w = Integer.parseInt(split[split.length - 1]);
  1086.                 } catch (Exception e) {
  1087.                     w = -1;
  1088.                 }
  1089.                 // click new world
  1090.                 while (w != world) {
  1091.                     if (worldToHop.getLocation().y <= 280
  1092.                             && worldToHop.getLocation().y >= 0) {
  1093.                         status$ = "Clicking new world";
  1094.                         worldToHop.doClick();
  1095.                     } else {
  1096.                         RSComponent scrollBar = interfaces.getComponent(
  1097.                                 WORLD_SELECT_TAB_PARENT, SCROLL_BAR_PARENT);
  1098.                         status$ = "Scrolling to new world";
  1099.                         if (interfaces.scrollTo(worldToHop, scrollBar)) {
  1100.                             status$ = "Clicking new world";
  1101.                             worldToHop.doClick();
  1102.                         }
  1103.                     }
  1104.                     split = interfaces.getComponent(910, 8).getText().split(" ");
  1105.                     try {
  1106.                         w = Integer.parseInt(split[split.length - 1]);
  1107.                     } catch (Exception e) {
  1108.                         w = -1;
  1109.                     }
  1110.                 }
  1111.                 // get new world
  1112.                 sleep(random(1000, 1500));
  1113.                 String cW2 = interfaces.getComponent(WORLD_SELECT_TAB_PARENT,
  1114.                         CURRENT_WORLD_COM).getText();
  1115.                 String[] cWS2 = cW2.split(" ");
  1116.                 newWorld = Integer.parseInt(cWS2[1]);
  1117.             }
  1118.         }
  1119.         /*-END-PICK-NEXT-WORLD-*/
  1120.  
  1121.         // set last & current world/s
  1122.         if (currentWorld != newWorld) {
  1123.             for (int i = 0; i < pastWorld.length; i++) {
  1124.                 if (i < pastWorld.length - 1) {
  1125.                     pastWorld[i] = pastWorld[i + 1];
  1126.                 } else {
  1127.                     pastWorld[i] = currentWorld;
  1128.                 }
  1129.             }
  1130.             currentWorld = newWorld;
  1131.         }
  1132.  
  1133.         while (game.getClientState() != 10) {
  1134.             status$ = "Logging in...";
  1135.             // click play button
  1136.             if (interfaces.getComponent(LOBBY_PARENT, PLAY_BUTTON_COM).doClick()) {
  1137.                 hopped++;
  1138.                 timer.reset();
  1139.             }
  1140.  
  1141.             // check for high risk world warning during login
  1142.             long timeOut = System.currentTimeMillis() + 35000;
  1143.             while (game.getClientState() != 10
  1144.                     && System.currentTimeMillis() < timeOut) {
  1145.                 RSComponent hrParent = interfaces.getComponent(LOBBY_PARENT,
  1146.                         HIGH_RISK_WARN_PARENT);
  1147.                 if (hrParent.isValid()) {
  1148.                     RSComponent LogIn = hrParent.getComponent(random(0,
  1149.                             hrParent.getComponents().length));
  1150.                     if (LogIn != null && LogIn.isValid()) {
  1151.                         if (mouse.getLocation().getX() < 386
  1152.                                 || mouse.getLocation().getX() > 504
  1153.                                 || mouse.getLocation().getY() < 357
  1154.                                 || mouse.getLocation().getY() > 386) {
  1155.                             if (LogIn.doHover()) {
  1156.                                 sleep(random(250, 500));
  1157.                                 if (menu.contains("Log In")) {
  1158.                                     // accept warning / click login
  1159.                                     mouse.click(true);
  1160.                                     log.warning("This is a high risk wilderness world.");
  1161.                                     sleep(random(250, 500));
  1162.                                 }
  1163.                             }
  1164.                         }
  1165.                     }
  1166.                 }
  1167.                 sleep(100);
  1168.             }
  1169.             // check for login errors
  1170.             String returnText = interfaces.getComponent(LOBBY_PARENT, RETURN_TEXT_COM).getText().toLowerCase();
  1171.             if (!game.isLoggedIn()) {
  1172.                 if (returnText.contains("update")) {
  1173.                     status$ = "Stopping script";
  1174.                     log("Runescape has been updated, please reload RSBot.");
  1175.                     stopScript(false);
  1176.                 }
  1177.                 if (returnText.contains("disable")) {
  1178.                     status$ = "Stopping script";
  1179.                     log("Your account is banned/disabled.");
  1180.                     stopScript(false);
  1181.                 }
  1182.                 if (returnText.contains("error connecting")) {
  1183.                     status$ = "Stopping script";
  1184.                     log("STOPPED = line 1045 - error connecting");
  1185.                     interfaces.getComponent(LOBBY_PARENT,
  1186.                             CONNECT_ERROR_BACK_BUTTON_COM).doClick();
  1187.                     stopScript(false);
  1188.                 }
  1189.                 if (returnText.contains("full")) {
  1190.                     log("World Is Full.");
  1191.                     interfaces.getComponent(LOBBY_PARENT,
  1192.                             WORLD_FULL_BACK_BUTTON_COM).doClick();
  1193.                     sleep(random(1000, 1500));
  1194.                     worldHop(members, maxping, maxpop); // try again
  1195.                 }
  1196.                 if (returnText.contains("subscribe")) {
  1197.                     interfaces.getComponent(LOBBY_PARENT,
  1198.                             SUBSCRIBE_BACK_BUTTON_COM).doClick();
  1199.                     if (members) {
  1200.                         status$ = "Stopping script";
  1201.                         log("You neen to be a member to select this world.");
  1202.                         stopScript(false);
  1203.                     } else {
  1204.                         sleep(random(500, 1000));
  1205.                         worldHop(members, maxping, maxpop); // try again
  1206.                     }
  1207.                 }
  1208.                 if (returnText.contains("must have a total")) {
  1209.                     log("STOPPED = line 1069 - must have a total");
  1210.                     interfaces.getComponent(LOBBY_PARENT,
  1211.                             SKILL_WORLD_BACK_BUTTON_COM).doClick();
  1212.                     sleep(random(500, 1000));
  1213.                     worldHop(members, maxping, maxpop); // try again
  1214.                 }
  1215.             }
  1216.         }
  1217.     }
  1218.  
  1219.         private boolean isPastWorld(int world) {
  1220.         for (int i = 0; i < pastWorld.length; i++) {
  1221.             if (pastWorld[i] == world) {
  1222.                 return true;
  1223.             }
  1224.         }
  1225.         return false;
  1226.     }
  1227.  
  1228.         private int pingHost(String host, int timeout) {
  1229.         long start = -1;
  1230.         long end = -1;
  1231.         int total = -1;
  1232.         int defaultPort = 80;
  1233.         Socket theSock = new Socket();
  1234.         try {
  1235.             InetAddress addr = InetAddress.getByName(host);
  1236.             SocketAddress sockaddr = new InetSocketAddress(addr, defaultPort);
  1237.             start = System.currentTimeMillis();
  1238.             theSock.connect(sockaddr, timeout);
  1239.             end = System.currentTimeMillis();
  1240.         } catch (Exception e) {
  1241.             start = -1;
  1242.             end = -1;
  1243.         } finally {
  1244.             if (theSock != null) {
  1245.                 try {
  1246.                     theSock.close();
  1247.                 } catch (IOException e) {
  1248.                 }
  1249.                 if ((start != -1) && (end != -1)) {
  1250.                     total = (int) (end - start);
  1251.                     log(host + "'s ping delay is " + total + "ms.");
  1252.                 } else {
  1253.                     log("Connection timed out or unable to connect to host: "
  1254.                             + host);
  1255.                 }
  1256.             }
  1257.         }
  1258.         return total; // returns -1 if timeout
  1259.  
  1260.     }
  1261.     }
  1262.     //</editor-fold>
  1263.  
  1264.     //<editor-fold defaultstate="collapsed" desc="Paint Stuff">
  1265.         //START: Code generated using Enfilade's Easel
  1266.     private Image getImage(String url) {
  1267.         try {
  1268.             return ImageIO.read(new URL(url));
  1269.         } catch(IOException e) {
  1270.             return null;
  1271.         }
  1272.     }
  1273.  
  1274.     private final Color color1 = new Color(0, 0, 0);
  1275.     private final Color color2 = new Color(240, 240, 240);
  1276.  
  1277.     private final Font font1 = new Font("Times New Roman", 0, 10);
  1278.     private final Font font2 = new Font("Times New Roman", 0, 12);
  1279.  
  1280.     private final Image img1 = getImage("http://i360.photobucket.com/albums/oo47/perez048/paint-2.png");
  1281.  
  1282.     public void onRepaint(Graphics g1) {
  1283.         Graphics2D g = (Graphics2D)g1;
  1284.         if (normal != null) {
  1285.  
  1286.             final int mouse_x = mouse.getLocation().x;
  1287.             final int mouse_y = mouse.getLocation().y;
  1288.             final int mouse_x2 = mouse.getPressLocation().x;
  1289.             final int mouse_y2 = mouse.getPressLocation().y;
  1290.             final long mpt = System.currentTimeMillis()
  1291.                     - mouse.getPressTime();
  1292.             if (mouse.getPressTime() == -1 || mpt >= 1000) {
  1293.                 g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse when its not clicked
  1294.             }
  1295.             if (mpt < 1000) {
  1296.                 g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null); //this show the four squares where you clicked.
  1297.                 g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse as normal when its/just clicked
  1298.             }
  1299.         }
  1300.         if (game.isLoggedIn()) {
  1301.             oreHr = (int) ((oreCollected) * 3600000D / (System.currentTimeMillis() - startTime));
  1302.             millis = System.currentTimeMillis() - startTime;
  1303.             hours = millis / (1000 * 60 * 60);
  1304.             millis -= hours * (1000 * 60 * 60);
  1305.             minutes = millis / (1000 * 60);
  1306.             millis -= minutes * (1000 * 60);
  1307.             seconds = millis / 1000;
  1308.  
  1309.             millis2 = timer.getRemaining() - 60;
  1310.             seconds2 = millis2 / 1000;
  1311.  
  1312.  
  1313.         g.drawImage(img1, -2, 310, null);
  1314.         g.setFont(font1);
  1315.         g.setColor(color1);
  1316.         g.drawString("Ores/hr: "+ oreHr, 263, 443);
  1317.         g.drawString("Ores Collected: " + oreCollected, 263, 428);
  1318.         g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 263, 413);
  1319.         g.setColor(color2);
  1320.         g.drawString("Version: " + ironPickUpBETA.class.getAnnotation(ScriptManifest.class).version(), 91, 385);
  1321.         g.setFont(font2);
  1322.         g.drawString("Status: "+ status, 78, 473);
  1323.         g.setFont(font1);
  1324.         g.setColor(color1);
  1325.         g.drawString("Mouse Speed: "+ MouseSpeed, 16, 416);
  1326.         g.drawString("World Hops: " + hopped, 16, 431);
  1327.         g.drawString("Seconds to Switch: "+seconds2, 16, 446);
  1328.         } else {
  1329.             String s = "Status: " + status$
  1330.                     + " || Times hopped: " + hopped;
  1331.             g.setColor(color1);
  1332.             g.fillRoundRect(240, 104, s.length() * 6, 17, 16, 16);
  1333.             g.setFont(new Font("Arial", 1, 12));
  1334.             g.setColor(color2);
  1335.             g.drawString(s, 250, 117);
  1336.         }
  1337.     }
  1338.     //END: Code generated using Enfilade's Easel
  1339.     //</editor-fold>
  1340.  
  1341.     //<editor-fold defaultstate="collapsed" desc="backup stuff">
  1342. //    public int bankOpen() {
  1343. //        if (atBank() && players.getMyPlayer().isIdle()) {
  1344. //            status = "Opening Bank.";
  1345. //            RSObject bankBooth = objects.getNearest(BANK);
  1346. //            if (random(1, 4) > 1) {
  1347. //                bankBooth.doAction("Use-quickly");
  1348. //            } else {
  1349. //                antiban.antiban();
  1350. //            }
  1351. //        }
  1352. //        return random(800, 1300);
  1353. //    }
  1354. //
  1355. //    public int depositBank() {
  1356. //        status = "Depositing ores";
  1357. //        bank.depositAll();
  1358. //        return random(300, 1100);
  1359. //    }
  1360. //
  1361. //    public int bankClose() {
  1362. //        if (bank.isOpen()) {
  1363. //            status = "Closing Bank.";
  1364. //            bank.close();
  1365. //            sleep(random(200, 1000));
  1366. //        }
  1367. //        return random(300, 800);
  1368. //    }
  1369. //
  1370. //    public void banking() {
  1371. //        if (!bank.isOpen()) {
  1372. //            bankOpen();
  1373. //            antiban.antiban();
  1374. //        }
  1375. //        if (bank.isOpen()) {
  1376. //            depositBank();
  1377. //            antiban.antiban();
  1378. //            sleep(random(100, 500));
  1379. //            banked++;
  1380. //        }
  1381. //
  1382. //        timer.reset();
  1383. //    }
  1384. //    RSTile toBank1[] = new RSTile[]{new RSTile(2970, 3239), new RSTile(2973, 3244),
  1385. //        new RSTile(2975, 3248), new RSTile(2976, 3253),
  1386. //        new RSTile(2978, 3258), new RSTile(2978, 3263),
  1387. //        new RSTile(2978, 3268), new RSTile(2980, 3273),
  1388. //        new RSTile(2986, 3277), new RSTile(2989, 3282),
  1389. //        new RSTile(2992, 3287), new RSTile(2997, 3292),
  1390. //        new RSTile(3001, 3296), new RSTile(3002, 3301),
  1391. //        new RSTile(3006, 3306), new RSTile(3006, 3312),
  1392. //        new RSTile(3006, 3316), new RSTile(3006, 3321),
  1393. //        new RSTile(3006, 3326), new RSTile(3006, 3331),
  1394. //        new RSTile(3006, 3336), new RSTile(3006, 3341),
  1395. //        new RSTile(3006, 3347), new RSTile(3008, 3352),
  1396. //        new RSTile(3008, 3357), new RSTile(3011, 3357),
  1397. //        new RSTile(3012, 3355)};
  1398. //    RSTile toMine1[] = new RSTile[]{new RSTile(3012, 3355), new RSTile(3011, 3359),
  1399. //        new RSTile(3008, 3359), new RSTile(3008, 3355),
  1400. //        new RSTile(3008, 3351), new RSTile(3008, 3346),
  1401. //        new RSTile(3008, 3341), new RSTile(3008, 3336),
  1402. //        new RSTile(3008, 3331), new RSTile(3007, 3326),
  1403. //        new RSTile(3007, 3321), new RSTile(3007, 3316),
  1404. //        new RSTile(3007, 3311), new RSTile(3002, 3305),
  1405. //        new RSTile(2997, 3300), new RSTile(2996, 3296),
  1406. //        new RSTile(2994, 3291), new RSTile(2994, 3286),
  1407. //        new RSTile(2994, 3281), new RSTile(2995, 3275),
  1408. //        new RSTile(2992, 3270), new RSTile(2988, 3266),
  1409. //        new RSTile(2983, 3262), new RSTile(2981, 3257),
  1410. //        new RSTile(2978, 3252), new RSTile(2973, 3248),
  1411. //        new RSTile(2971, 3244), new RSTile(2970, 3240)};
  1412.     //</editor-fold>
  1413. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement