Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 27.97 KB | None | 0 0
  1. import javax.swing.*;
  2. import javax.swing.border.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.awt.event.MouseEvent;
  6. import java.awt.event.MouseMotionListener;
  7.  
  8. import org.rsbot.script.*;
  9. import org.rsbot.script.methods.Skills;
  10. import org.rsbot.script.methods.*;
  11. import org.rsbot.script.methods.Camera;
  12. import org.rsbot.script.wrappers.*;
  13. import org.rsbot.event.listeners.PaintListener;
  14. import org.rsbot.event.listeners.ServerMessageListener;
  15. import org.rsbot.event.events.ServerMessageEvent;
  16. import org.rsbot.script.methods.Game;
  17. import org.rsbot.script.internal.*;
  18.  
  19. @ScriptManifest(authors = {"Harrison"}, keywords = "Mining", name = "Heroic Miner", version = 1.5, description = "Multi Locational miner. Now with the option to Powermine.")
  20. public class heroicMiner extends Script implements PaintListener, ServerMessageListener, MouseMotionListener  {
  21.  
  22.     private RSTile nearestRock;
  23.     public static RSTile draynorBankTile = new RSTile(3093, 3245);
  24.     public static RSTile swampMineTile = new RSTile(3147, 3149);
  25.     public static RSTile guildLadder = new RSTile(3021, 9739);
  26.     public static RSTile guildFrontMiddle = new RSTile(3034, 9737);
  27.    
  28.     public RSTile[] toDraynorBank = { new RSTile(3148, 3163), new RSTile(3144, 3175), new RSTile(3140, 3188), new RSTile(3138, 3200), new RSTile(3129, 3208),
  29.                                         new RSTile(3118, 3216), new RSTile(3109, 3228), new RSTile(3102, 3234), new RSTile(3092, 3245) };
  30.     public RSTile[] toSwampMine = { new RSTile(3098, 3233), new RSTile(3106, 3224), new RSTile(3118, 3217), new RSTile(3125, 3209), new RSTile(3134, 3202),
  31.                                         new RSTile(3140, 3190), new RSTile(3142, 3180), new RSTile(3145, 3169), new RSTile(3147, 3161), new RSTile(3146, 3148) };
  32.     public RSTile[] toVarrWestMine = { new RSTile(3174, 3428), new RSTile(3171, 3415), new RSTile(3171, 3403), new RSTile(3175, 3389), new RSTile(3178, 3381),
  33.                                         new RSTile(3183, 3371), new RSTile(3175, 3367) };
  34.     public RSTile[] toVarrWestBank = { new RSTile(3186, 3376), new RSTile(3176, 3388), new RSTile(3170, 3397), new RSTile(3171, 3411), new RSTile(3171, 3422),
  35.                                         new RSTile(3182, 3429), new RSTile(3182, 3436) };
  36.     public RSTile[] fallyMineBankB = { new RSTile(3022, 3338), new RSTile(3024, 3351), new RSTile(3013, 3357) };
  37.     public RSTile[] fallyBankMineB = { new RSTile(3013, 3357), new RSTile(3024, 3351), new RSTile(3022, 3338) };
  38.     public RSArea swampArea = new RSArea(new RSTile(3150, 3155), new RSTile(3143, 3144));
  39.     public RSArea draynorBankArea = new RSArea(new RSTile(3092, 3240), new RSTile(3097, 3246));
  40.     public RSArea varrwestBank  = new RSArea(new RSTile(3178, 3447), new RSTile(3195, 3431));
  41.     public RSArea varrwestMine = new RSArea(new RSTile(3171, 3363), new RSTile(3185, 3379));
  42.     public RSArea fallyEastBank = new RSArea(new RSTile(3019, 3359), new RSTile(3008, 3354));
  43.     public RSArea fallyMineGuild = new RSArea(new RSTile(3017, 9732), new RSTile(3055, 9755));
  44.     public RSArea fallyMineArea = new RSArea(new RSTile(3031, 3360), new RSTile(3008, 3330));
  45.  
  46.    
  47.     public static int[] ironRock = { 11954, 11955, 11956 };
  48.     public static int[] coalRock = { 2096, 2097, 5770, 5771, 5772, 11930, 11931, 11932, 11963, 11964, 14850, 14851, 14852, 31068, 31069, 31070, 32426 };
  49.     public static int[] pickID = {1265, 1269, 1267, 1273, 1271, 1275, 14107, 15259, 15261};
  50.     public int[] thebankid = {11402, 11758, 11402, 2213};
  51.     private int startExp = 0;
  52.     private int startlvl = 0;
  53.     private int gainedExp = 0;
  54.     private int oresMined = 0;
  55.     private int gemsMined = 0;
  56.     private int hourlyOre = 0;
  57.     private int oreHour = 0;
  58.     private int expHour = 0;
  59.     private int fallyMineGuildUpLadder = 6226;
  60.     private int fallyMineGuildDownLadder = 2113;
  61.  
  62.    
  63.     public RSObject ore, nextOre;
  64.     public int currentID;
  65.     public int rockID;
  66.     public RSObject lastOre;
  67.     public long startTime = System.currentTimeMillis();
  68.    
  69.     String location = "Unknown";
  70.     //== Points & Timers ==
  71.     private Point mPlayer;
  72.     private Timer pTimer;
  73.     minerGUI gui;
  74.     //=== Booleans ===
  75.     private boolean barHover = false;
  76.     private boolean abRunOnce = false;
  77.     boolean lumSwampCoal = false;
  78.     boolean varrwestIron = false;
  79.     boolean fallyMinngGuild = false;
  80.     boolean lumSwampCoalPwr = false;
  81.     boolean varrwestIronPwr = false;
  82.     boolean fallyMinngGuildPwr = false;
  83.     public boolean lumSwampMine(){
  84.             if (swampArea.contains(getMyPlayer().getLocation())) {
  85.                 location = "Lumby Swamp Mine";
  86.                 return true;
  87.             } else return false;
  88.         }
  89.     public boolean draynorBank(){
  90.             if (draynorBankArea.contains(getMyPlayer().getLocation())) {
  91.                 location = "Draynor Bank";
  92.                 return true;
  93.             } else return false;
  94.         }
  95.     public boolean varrwestMine(){
  96.             if (varrwestMine.contains(getMyPlayer().getLocation())) {
  97.                 location = "Varrock West Mine";
  98.                 return true;
  99.             } else return false;
  100.         }
  101.     public boolean varrwestBank(){
  102.             if (varrwestBank.contains(getMyPlayer().getLocation())) {
  103.                 location = "Varrock West Bank";
  104.                 return true;
  105.             } else return false;
  106.         }
  107.     public boolean fallyEastMine(){
  108.             if (fallyMineGuild.contains(getMyPlayer().getLocation())) {
  109.                 location = "Falador Mining Guild";
  110.                 return true;
  111.             } else return false;
  112.         }
  113.     public boolean fallyMineArea(){
  114.             if(fallyMineArea.contains(getMyPlayer().getLocation())) {
  115.                 location = "Falador Mining Area";
  116.                 return true;
  117.             } else return false;
  118.         }
  119.     public boolean fallyEastBank(){
  120.             if(fallyEastBank.contains(getMyPlayer().getLocation())) {
  121.                 return true;
  122.             } else return false;
  123.         }
  124.        
  125.        
  126.     /************************************************************************************************************************************************************************\
  127.      ************************************************************************************************************************************************************************
  128.      ************************************************************************************************************************************************************************
  129.      ************************************************************************************************************************************************************************
  130.      ************************************************************************************************************************************************************************
  131.      ************************************************************************************************************************************************************************
  132.     \************************************************************************************************************************************************************************/
  133.    
  134.     public boolean onStart() {
  135.         gui = new minerGUI();
  136.         gui.setVisible(true);
  137.         while (gui.isVisible()) {
  138.             sleep(1000);
  139.         }
  140.         startTime = System.currentTimeMillis();
  141.         log("Please login in then run this script.");
  142.         log("If you don't you will encounter problems with Exp Gain.");
  143.         startExp = skills.getCurrentExp(Skills.MINING);
  144.         startlvl = skills.getCurrentLevel(Skills.MINING);
  145.         return true;
  146.     }
  147.    
  148.     public RSObject getSecondNearest(int... ids) {
  149.     RSObject cur = null;
  150.     double dist = -1;
  151.     RSTile[] tiles = varrwestMine.getTileArray();
  152.     for (int x = 0; x < tiles.length; x++) {
  153.             RSObject o = objects.getTopAt(tiles[x]);
  154.         if (o != null) {
  155.         boolean isObject = false;
  156.         for (int id : ids) {
  157.             if (o.getID() == id) {
  158.             isObject = true;
  159.             break;
  160.             }
  161.         }
  162.         if (isObject) {
  163.             double distTmp = calc.distanceBetween(ore.getLocation(), o.getLocation());    
  164.  
  165.                     String strCurrentRockLoc = ore.getLocation().toString();
  166.                     String strPossRockLoc = o.getLocation().toString();
  167.             if (cur == null && !( o.getLocation().equals(ore.getLocation())) ) {
  168.                         dist = distTmp;
  169.             cur = o;
  170.             }
  171.                     if (distTmp < dist && !( o.getLocation().equals(ore.getLocation())) ) {
  172.                         cur = o;
  173.             dist = distTmp;
  174.             }
  175.         }
  176.             }
  177.     }
  178.     return cur;
  179. }
  180.  
  181. public void MineIron() {
  182.     ore = objects.getNearest( ironRock );
  183.     RSComponent fullInventoryIFace = interfaces.get(210).getComponent(1);
  184.     if ( fullInventoryIFace.isValid() )
  185.         //isInventoryFull = true;
  186.     if ( ore == null) {
  187.         ore = objects.getNearest( ironRock );
  188.         if ( ore != null ) {
  189.             if ( !(calc.tileOnScreen(ore.getLocation())) ) {
  190.                 camera.turnToObject(ore);
  191.             }
  192.             if ( !(calc.tileOnScreen(ore.getLocation())) ){
  193.                 walking.walkTo(ore.getLocation());
  194.             }
  195.         }
  196.     }
  197.  
  198.     if ( ore != null ) {
  199.  
  200.     currentID = objects.getTopAt(ore.getLocation()).getID();
  201.  
  202.     if ( currentID == 11956 || currentID == 11955 ) {
  203.         if ( nextOre != null ) {
  204.             if ( !(calc.tileOnScreen(nextOre.getLocation())) ) {
  205.                 camera.turnToObject(nextOre);
  206.             }
  207.             if ( !(calc.tileOnScreen(nextOre.getLocation())) ){
  208.                 walking.walkTileMM(nextOre.getLocation());
  209.             }
  210.             ore = nextOre;
  211.         }
  212.     }
  213.  
  214.     if ( !(getMyPlayer().isMoving()) && !onHorizontalOrVertTile(ore.getLocation()) ) {
  215.         ore.doAction("Mine");
  216.     } else if ( getMyPlayer().getAnimation() == -1 && onHorizontalOrVertTile(ore.getLocation()) ) {
  217.         ore.doAction("Mine");
  218.     }
  219.  
  220.     nextOre = getSecondNearest( ironRock );
  221.    
  222.     if (nextOre != null) {
  223.         if ( !(calc.tileOnScreen(nextOre.getLocation())) )
  224.             camera.turnToObject(nextOre);  
  225.         mouse.move( calc.tileToScreen(nextOre.getLocation()), 13, 13 );  
  226.     } else {
  227.         ore = null;
  228.     }
  229.  
  230.     }
  231. }
  232.    
  233.     public boolean onHorizontalOrVertTile(RSTile tile){
  234.     boolean bool = false;    
  235.     if ( getMyPlayer().getLocation().getX() == tile.getX() || getMyPlayer().getLocation().getY() == tile.getY() ) {
  236.         if ( calc.distanceTo(tile) == 1 ) {
  237.             bool = true;
  238.         } else
  239.             bool = false;
  240.     }
  241.     return bool;
  242. }
  243.  
  244.    
  245.     public void MineCoal() {
  246.     ore = objects.getNearest( coalRock );
  247.     RSComponent fullInventoryIFace = interfaces.get(210).getComponent(1);
  248.     if ( fullInventoryIFace.isValid() )
  249.         //isInventoryFull = true;
  250.     if ( ore == null) {
  251.         antiban2();
  252.         ore = objects.getNearest( coalRock );
  253.         if ( ore != null ) {
  254.             if ( !(calc.tileOnScreen(ore.getLocation())) ) {
  255.                 camera.turnToObject(ore);
  256.             }
  257.             if ( !(calc.tileOnScreen(ore.getLocation())) ){
  258.                 walking.walkTo(ore.getLocation());
  259.             }
  260.         }
  261.     }
  262.  
  263.     if ( ore != null ) {
  264.  
  265.     currentID = objects.getTopAt(ore.getLocation()).getID();
  266.  
  267.     if ( currentID == 11552 || currentID == 11553 ) {
  268.         if ( nextOre != null ) {
  269.             if ( !(calc.tileOnScreen(nextOre.getLocation())) ) {
  270.                 camera.turnToObject(nextOre);
  271.             }
  272.             if ( !(calc.tileOnScreen(nextOre.getLocation())) ){
  273.                 walking.walkTileMM(nextOre.getLocation());
  274.             }
  275.             ore = nextOre;
  276.         }
  277.     }
  278.  
  279.     if ( !(getMyPlayer().isMoving()) && !onHorizontalOrVertTile(ore.getLocation()) ) {
  280.         ore.doAction("Mine");
  281.         antiban2();
  282.     } else if ( getMyPlayer().getAnimation() == -1 && onHorizontalOrVertTile(ore.getLocation()) ) {
  283.         ore.doAction("Mine");
  284.         antiban2();
  285.     }
  286.  
  287.     nextOre = getSecondNearest( coalRock );
  288.    
  289.     if (nextOre != null) {
  290.         if ( !(calc.tileOnScreen(nextOre.getLocation())) )
  291.             camera.turnToObject(nextOre);  
  292.         mouse.move( calc.tileToScreen(nextOre.getLocation()), 13, 13 );  
  293.     } else {
  294.         ore = null;
  295.     }
  296.  
  297.     }
  298. }
  299.     private void antiban2() {
  300.         switch (random (0, 10)) {
  301.         case 0:
  302.             mouse.move(random(-200, 700), random(200, 400));
  303.             break;
  304.         case 1:
  305.             camera.setAngle(random(0, 180));
  306.             camera.setPitch(random(0, 100));
  307.             break;
  308.        
  309.         }
  310.         }
  311.        
  312.     private void antiban() {
  313.         switch (random(0, 20)) {
  314.         case 0:
  315.             game.openTab(Game.TAB_STATS);
  316.             mouse.move(704 + random(-30, 29), 223 + random(-13, 13));
  317.             sleep(random(500, 1250));
  318.             game.openTab(Game.TAB_INVENTORY);
  319.             break;
  320.         case 1:
  321.             game.openTab(Game.TAB_FRIENDS);
  322.             sleep(random(500, 1250));
  323.             game.openTab(Game.TAB_INVENTORY);
  324.             break;
  325.         case 2:
  326.             camera.setAngle(random(0, 180));
  327.             camera.setPitch(random(0, 100));
  328.             break;
  329.         default:
  330.         }
  331.         abRunOnce = true;
  332.     }
  333.     private void bank() {
  334.         RSObject bankBooth = objects.getNearest(thebankid);
  335.             if (bankBooth != null && !bank.isOpen()) {
  336.                 bankBooth.doAction("Use-quickly");
  337.             }
  338.             if (bankBooth != null && bank.isOpen()) {
  339.                 bank.depositAllExcept(pickID);
  340.                 bank.close();
  341.             }
  342.     }
  343.  
  344.     public int loop() {
  345.         mouse.setSpeed(random(3, 5));
  346.         switch (getState()) {
  347.             case toDraynorBank:
  348.                 walking.walkPathMM(toDraynorBank, 1 ,1);
  349.                 return (random(1000, 2500));
  350.  
  351.             case toSwampMine:
  352.                 walking.walkPathMM(toSwampMine, 2 ,2);
  353.                 return (random(1000, 2000));
  354.            
  355.             case toVarrWestBank:
  356.                 walking.walkPathMM(toVarrWestBank, 1, 1);
  357.                 return (random(1000, 2000));
  358.            
  359.             case toVarrWestMine:
  360.                 walking.walkPathMM(toVarrWestMine, 0, 0);
  361.                 return (random(1000, 2000));
  362.            
  363.             case fallyMineBankB:
  364.                 walking.walkPathMM(fallyMineBankB, 2, 2);
  365.                 return (random(1000, 2000));
  366.                
  367.             case fallyBankMineB:
  368.                 walking.walkPathMM(fallyBankMineB, 2, 2);
  369.                 return (random(1000, 2000));
  370.            
  371.             case guildFrontMiddle:
  372.                 if (walking.getDestination() != null && calc.distanceBetween(walking.getDestination(), guildFrontMiddle) < random(2, 3))
  373.                     return random(50, 100);
  374.                     if (calc.distanceTo(guildFrontMiddle) < random(2, 3))
  375.                     return random(50, 100);
  376.                     walking.walkTileMM(walking.getClosestTileOnMap(guildFrontMiddle), random(1, 3), random(1, 3));
  377.                 return random(600, 900);
  378.            
  379.             case toMineGuildLadder:
  380.                 if (walking.getDestination() != null && calc.distanceBetween(walking.getDestination(), guildLadder) < random(2, 3))
  381.                     return random(50, 100);
  382.                     if (calc.distanceTo(guildLadder) < random(2, 3))
  383.                     return random(50, 100);
  384.                     walking.walkTileMM(walking.getClosestTileOnMap(guildLadder), random(1, 3), random(1, 3));
  385.                 return random(600, 900);
  386.                
  387.             case nuller:
  388.                 return random(250, 600);
  389.             case dropIt:
  390.                 mouse.setSpeed(random(5, 7));
  391.                 inventory.dropAllExcept(pickID);
  392.                 return random(250, 600);
  393.  
  394.         }
  395.         return 100;
  396.     }
  397.  
  398.     private enum State {
  399.         toDraynorBank, toSwampMine, toVarrWestBank, toVarrWestMine, toMineGuildLadder, fallyBankMineB, fallyMineBankB, guildFrontMiddle, sleep, nuller, dropIt
  400.     }
  401.  
  402.     private State getState() {
  403.             game.openTab(Game.TAB_INVENTORY);
  404.             if ( walking.getEnergy() >= random(60,102)) {
  405.                 walking.setRun(true);
  406.             }
  407.         if (lumSwampCoal == true) {
  408.             try {
  409.             if (inventory.isFull() && !draynorBank()) {
  410.                 return State.toDraynorBank;
  411.             } else if (inventory.isFull() && draynorBank()) {
  412.                 bank();
  413.                 return State.nuller;
  414.             } else if (!inventory.isFull() && !lumSwampMine()) {
  415.                 return State.toSwampMine;
  416.             } else if (lumSwampMine() && !inventory.isFull()) {
  417.                 MineCoal();
  418.                 return State.nuller;
  419.             } else if (!draynorBank() && !lumSwampMine() && !inventory.isFull()) {
  420.                 return State.toSwampMine;
  421.             } else if (!draynorBank() && !lumSwampMine() && inventory.isFull()) {
  422.                 return State.toDraynorBank;
  423.             }
  424.             } catch (Exception e) {
  425.             return State.sleep;
  426.             }
  427.         }
  428.         if (lumSwampCoalPwr == true) {
  429.          try {
  430.             if(inventory.isFull()) {
  431.                 return State.dropIt;
  432.             } else if (!inventory.isFull()) {
  433.                 MineCoal();
  434.             }
  435.             } catch (Exception e) {
  436.                 return State.sleep;
  437.             }
  438.         }
  439.         if (varrwestIron == true) {
  440.             try {
  441.             if (inventory.isFull() && !varrwestBank()) {
  442.                 return State.toVarrWestBank;
  443.             } else if (inventory.isFull() && varrwestBank()) {
  444.                 bank();
  445.                 return State.nuller;
  446.             } else if (!inventory.isFull() && !varrwestMine()) {
  447.                 return State.toVarrWestMine;
  448.             } else if (varrwestMine() && !inventory.isFull()) {
  449.                 MineIron();
  450.                 return State.nuller;
  451.             } else if (!varrwestBank() && !varrwestMine() && !inventory.isFull()) {
  452.                 return State.toVarrWestMine;
  453.             } else if (!varrwestBank() && !varrwestMine() && inventory.isFull()) {
  454.                 return State.toVarrWestBank;
  455.             }
  456.             } catch (Exception e) {
  457.             return State.sleep;
  458.             }
  459.         }
  460.         if (varrwestIronPwr == true) {
  461.             try {
  462.             if(inventory.isFull()) {
  463.                 return State.dropIt;
  464.             } else if (!inventory.isFull()) {
  465.                 MineIron();
  466.             }
  467.             } catch (Exception e) {
  468.                 return State.sleep;
  469.             }
  470.         }
  471.         if (fallyMinngGuild == true) {
  472.             RSObject ladder = objects.getNearest(fallyMineGuildUpLadder);
  473.             RSObject ladderDown = objects.getNearest(fallyMineGuildDownLadder);
  474.             RSObject bankBooth = objects.getNearest(thebankid);
  475.             RSObject randomObj = objects.getNearest(7829);
  476.         try {
  477.             if (inventory.isFull() && fallyEastMine() && !ladder.isOnScreen()) {
  478.                 antiban2();
  479.                 return State.toMineGuildLadder;
  480.             } else if (inventory.isFull() && fallyEastMine() && ladder.isOnScreen()) {
  481.                 ladder.doAction("Climb-up");
  482.                 sleep(random(3000, 7000));
  483.                 return State.nuller;
  484.             } else if (fallyEastMine() && !inventory.isFull() && calc.distanceTo(randomObj) < 7) {
  485.                 return State.guildFrontMiddle;
  486.             } else if (fallyEastMine() && !inventory.isFull() && calc.distanceTo(randomObj) > 7) {
  487.                 MineCoal();
  488.             } else if (inventory.isFull() && fallyMineArea() && !bankBooth.isOnScreen()) {
  489.                 return State.fallyMineBankB;
  490.             } else if (fallyMineArea() && inventory.isFull() && bankBooth.isOnScreen()) {
  491.                 bank();
  492.                 return State.nuller;
  493.             } else if (fallyMineArea() && !inventory.isFull() && !ladderDown.isOnScreen()) {
  494.                 antiban2();
  495.                 return State.fallyBankMineB;
  496.             } else if (fallyMineArea() && !inventory.isFull() && ladderDown.isOnScreen()) {
  497.                 ladderDown.doAction("Climb-down");
  498.                 sleep(random(1000, 2000));
  499.                 return State.nuller;
  500.             }
  501.             } catch (Exception e) {
  502.             return State.sleep;
  503.             }
  504.         }
  505.         if (fallyMinngGuildPwr == true) {
  506.             try {
  507.             if(inventory.isFull()) {
  508.                 return State.dropIt;
  509.             } else if (!inventory.isFull()) {
  510.                 MineCoal();
  511.             }
  512.             } catch (Exception e) {
  513.                 return State.sleep;
  514.             }
  515.         }
  516.         return State.nuller;
  517.     }
  518.  
  519.     public int sleepForAnim(int timeout) {
  520.         long start = System.currentTimeMillis();
  521.         RSPlayer myPlayer = getMyPlayer();
  522.         int anim = -1;
  523.  
  524.         while (System.currentTimeMillis() - start < timeout) {
  525.             if ((anim = myPlayer.getAnimation()) != -1) {
  526.                 break;
  527.             }
  528.             sleep(random(5, 15));
  529.         }
  530.         return anim;
  531.     }
  532.    
  533.     private void drawTile(Graphics render, RSTile tile, Color color, boolean drawCardinalDirections) {
  534.     Point southwest = calc.tileToScreen(tile, 0, 0, 0);
  535.     Point southeast = calc.tileToScreen(new RSTile(tile.getX() + 1, tile.getY()), 0, 0, 0);
  536.     Point northwest = calc.tileToScreen(new RSTile(tile.getX(), tile.getY() + 1), 0, 0, 0);
  537.     Point northeast = calc.tileToScreen(new RSTile(tile.getX() + 1, tile.getY() + 1), 0, 0, 0);
  538.    
  539.     if (calc.pointOnScreen(southwest) && calc.pointOnScreen(southeast) && calc.pointOnScreen(northwest) && calc.pointOnScreen(northeast)) {
  540.         render.setColor(Color.BLACK);
  541.         render.drawPolygon(new int[] { (int) northwest.getX(), (int) northeast.getX(), (int) southeast.getX(), (int) southwest.getX() }, new int[] { (int) northwest.getY(), (int) northeast.getY(), (int) southeast.getY(), (int) southwest.getY() }, 4);
  542.         render.setColor(color);
  543.         render.fillPolygon(new int[] { (int) northwest.getX(), (int) northeast.getX(), (int) southeast.getX(), (int) southwest.getX() }, new int[] { (int) northwest.getY(), (int) northeast.getY(), (int) southeast.getY(), (int) southwest.getY() }, 4);
  544.        
  545.         if (drawCardinalDirections) {
  546.             render.setColor(Color.WHITE);
  547.  
  548.             }
  549.         }
  550.     }
  551.  
  552.     public void mouseDragged(MouseEvent e) {
  553.         mPlayer = e.getPoint();
  554.     }
  555.  
  556.     public void mouseMoved(MouseEvent e) {
  557.         mPlayer = e.getPoint();
  558.  
  559.     }
  560.    
  561.     public void onRepaint(final Graphics g) {
  562.             final Color Black = new Color(0, 0, 0);
  563.             final Color Border = new Color(0, 153, 153);
  564.             final Color LightFill = new Color(0, 153, 153, 99);
  565.            
  566.             //=== Timer ===
  567.             long millis = System.currentTimeMillis() - startTime;
  568.             int expHour = (int) (3600000.0 / millis * gainedExp);
  569.             int oreHour = (int) (3600000.0 / millis * hourlyOre);
  570.             long hours = millis / (1000 * 60 * 60);
  571.             millis -= hours * (1000 * 60 * 60);
  572.             long minutes = millis / (1000 * 60);
  573.             millis -= minutes * (1000 * 60);
  574.             long seconds = millis / 1000;
  575.            
  576.             gainedExp = skills.getCurrentExp(Skills.MINING) - startExp;
  577.             final int percent = skills.getPercentToNextLevel(Skills.MINING);
  578.             int lvlGain = skills.getCurrentLevel(Skills.MINING) - startlvl;
  579.             Point m = mouse.getLocation();
  580.            
  581.             final int x = 24;
  582.             int y = 47;
  583.             int y2 = 47 + 16 + 16 + 16 + 16 + 5 + 16 + 16 + 5;
  584.             //Exp Bar Area
  585.             if (mPlayer.x >= 20 && mPlayer.x < 20 + 168 && mPlayer.y >= y2 && mPlayer.y < y2 + 13) {
  586.                 barHover = true;
  587.             } else {
  588.                 barHover = false;
  589.             }
  590.             //=== Locations ===
  591.             if (lumSwampMine()){
  592.                 location = "Lumby Swamp Mine";
  593.             } else if (draynorBank()){
  594.                 location = "Draynor Bank";
  595.             } else if (varrwestMine()){
  596.                 location = "Varrock West Mine";
  597.             } else if (varrwestBank()){
  598.                 location = "Varrock West Bank";
  599.             } else if (fallyEastBank()){
  600.                 location = "Falador East Bank";
  601.             } else if (fallyEastMine()){
  602.                 location = "Mining Guild";
  603.             } else if (fallyMineArea()){
  604.                 location = "Fally Mine Area";
  605.             } else {
  606.                 location = "Unknown";
  607.             }
  608.            
  609.         if (game.isLoggedIn()) {
  610.             drawTile(g, players.getMyPlayer().getLocation(), LightFill, true);
  611.             //Bot Mouse
  612.             g.setColor(Black);
  613.             g.drawLine(0, m.y, 1024, m.y);
  614.             g.drawLine(m.x, 0, m.x, 1024);
  615.             //Player Mouse
  616.             g.setColor(Color.RED);
  617.             g.drawLine(mPlayer.x - 8, mPlayer.y, mPlayer.x + 8, mPlayer.y);
  618.             g.drawLine(mPlayer.x, mPlayer.y - 8, mPlayer.x, mPlayer.y + 8);
  619.         g.setColor(Border);
  620.         g.drawRect(16, 31, 174, 143);
  621.         g.setColor(LightFill);
  622.         g.fillRect(17, 32, 173, 142);
  623.         g.setFont(new Font("SansSerif", 0, 12));
  624.         g.setColor(Black);
  625.         g.drawString("Ores Mined: " + oresMined, x, y);
  626.         y += 16;
  627.         g.drawString("Gems Mined: " + gemsMined, x, y);
  628.         y += 16;
  629.         g.drawString("Levels Gained: " + lvlGain, x, y);
  630.         y += 16;
  631.         g.drawString("Exp Gained: " + gainedExp, x, y);
  632.         y += 16;
  633.         g.drawLine(25, 100, 182, 100);
  634.         y += 5;
  635.         g.drawString("Remaning Exp: " + skills.getExpToNextLevel(Skills.MINING), x, y);
  636.         y += 16;
  637.         g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, x, y);
  638.         y += 16;
  639.         g.drawString("Location: " + location, x, y);
  640.         y += 5;
  641.         g.drawRect(x - 5, y, 169, 14);
  642.         // Exp Bar
  643.             g.setColor(Color.RED);
  644.             /* x, y, width, height, rounded, rounded */
  645.             g.fillRoundRect(x - 4, y + 1, 168, 13, 0, 0);
  646.             g.setColor(Color.GREEN);
  647.             g.fillRoundRect(x - 4, y + 1, (int) (percent * 168 / 100.0), 13, 0, 0);
  648.        
  649.         //Hovered
  650.         if (barHover == true) {
  651.         g.setColor(Border);
  652.         g.drawRect(mPlayer.x, mPlayer.y - 35, 141, 34);
  653.         g.setColor(new Color(0, 153, 153, 255));
  654.         g.fillRect(mPlayer.x + 1, mPlayer.y - 34, 140, 33);
  655.         g.setColor(Black);
  656.         g.drawString("Exp/Hr: " + expHour, mPlayer.x + 5, mPlayer.y - 20);
  657.         g.drawString("Ores/Hr: " + oreHour, mPlayer.x + 5, mPlayer.y - 5);
  658.         }
  659.         }
  660.     }
  661.    
  662.     public void serverMessageRecieved(final ServerMessageEvent arg0) {
  663.         final String serverString = arg0.getMessage();
  664.             if (serverString.contains("You manage to mine some")){
  665.             oresMined++;
  666.             }
  667.             if (serverString.contains("found")) {
  668.             gemsMined++;
  669.             }
  670.             if (serverString.contains("clay")) {
  671.             hourlyOre = hourlyOre + 1;
  672.             }
  673.             if (serverString.contains("copper")) {
  674.             hourlyOre = hourlyOre + 1;
  675.             }
  676.             if (serverString.contains("tin")) {
  677.             hourlyOre = hourlyOre + 1;
  678.             }
  679.             if (serverString.contains("iron")) {
  680.             hourlyOre = hourlyOre + 1;
  681.             }
  682.             if (serverString.contains("silver")) {
  683.             hourlyOre = hourlyOre + 1;
  684.             }
  685.             if (serverString.contains("coal")) {
  686.             hourlyOre = hourlyOre + 1;
  687.             }
  688.             if (serverString.contains("gold")) {
  689.             hourlyOre = hourlyOre + 1;
  690.             }
  691.             if (serverString.contains("mith")) {
  692.             hourlyOre = hourlyOre + 1;
  693.             }
  694.             if (serverString.contains("adamantite")) {
  695.             hourlyOre = hourlyOre + 1;
  696.             }
  697.             if (serverString.contains("rune")) {
  698.             hourlyOre = hourlyOre + 1;
  699.             }
  700.     }
  701.  
  702.     public void onFinish() {
  703.         log("Goodbye");
  704.     }
  705.    
  706.     public class minerGUI extends JFrame {
  707.     public minerGUI() {
  708.         initComponents();
  709.     }
  710.  
  711.     private void initComponents() {
  712.         // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
  713.         // Generated using JFormDesigner Evaluation license - joe dirt
  714.         comboBox1 = new JComboBox();
  715.         label1 = new JLabel();
  716.         button1 = new JButton();
  717.         checkBox1 = new JCheckBox();
  718.  
  719.         //======== this ========
  720.         setTitle("Miner Settings");
  721.         setResizable(false);
  722.         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  723.         Container contentPane = getContentPane();
  724.         contentPane.setLayout(null);
  725.  
  726.         //---- comboBox1 ----
  727.         comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  728.             "Choose Location",
  729.             "Lumbridge Swamp [Coal]",
  730.             "Varrock West [Iron]",
  731.             "Falador Mining Guild [Coal]"
  732.         }));
  733.         contentPane.add(comboBox1);
  734.         comboBox1.setBounds(5, 5, 250, comboBox1.getPreferredSize().height);
  735.  
  736.         //---- label1 ----
  737.         label1.setText("Created by Harrison(Stew)");
  738.         contentPane.add(label1);
  739.         label1.setBounds(new Rectangle(new Point(20, 65), label1.getPreferredSize()));
  740.  
  741.         //---- button1 ----
  742.         button1.setText("Start");
  743.         button1.addMouseListener(new MouseAdapter() {
  744.             @Override
  745.             public void mouseClicked(MouseEvent e) {
  746.                 button1MouseClicked(e);
  747.             }
  748.         });
  749.         contentPane.add(button1);
  750.         button1.setBounds(new Rectangle(new Point(190, 45), button1.getPreferredSize()));
  751.        
  752.         //---- checkBox1 ----
  753.         checkBox1.setText("Powermine? (Check if yes)");
  754.         contentPane.add(checkBox1);
  755.         checkBox1.setBounds(new Rectangle(new Point(5, 35), checkBox1.getPreferredSize()));
  756.  
  757.         { // compute preferred size
  758.             Dimension preferredSize = new Dimension();
  759.             for(int i = 0; i < contentPane.getComponentCount(); i++) {
  760.                 Rectangle bounds = contentPane.getComponent(i).getBounds();
  761.                 preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  762.                 preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  763.             }
  764.             Insets insets = contentPane.getInsets();
  765.             preferredSize.width += insets.right;
  766.             preferredSize.height += insets.bottom;
  767.             contentPane.setMinimumSize(preferredSize);
  768.             contentPane.setPreferredSize(preferredSize);
  769.         }
  770.         pack();
  771.         setLocationRelativeTo(getOwner());
  772.         // JFormDesigner - End of component initialization  //GEN-END:initComponents
  773.     }
  774.  
  775.    
  776.     private void button1MouseClicked(MouseEvent e) {
  777.         if(comboBox1.getSelectedItem().toString().contains("Lumbridge Swamp [Coal]") && !checkBox1.isSelected()) {
  778.             lumSwampCoal = true;
  779.         } else if (comboBox1.getSelectedItem().toString().contains("Lumbridge Swamp [Coal]") && checkBox1.isSelected()) {
  780.             lumSwampCoalPwr = true;
  781.         }
  782.         if(comboBox1.getSelectedItem().toString().contains("Varrock West [Iron]") && !checkBox1.isSelected()) {
  783.             varrwestIron = true;
  784.         } else if (comboBox1.getSelectedItem().toString().contains("Varrock West [Iron]") && checkBox1.isSelected()) {
  785.             varrwestIronPwr = true;
  786.         }
  787.         if (comboBox1.getSelectedItem().toString().contains("Falador Mining Guild [Coal]") && !checkBox1.isSelected()) {
  788.             fallyMinngGuild = true;
  789.         } else if (comboBox1.getSelectedItem().toString().contains("Falador Mining Guild [Coal]") && checkBox1.isSelected()) {
  790.             fallyMinngGuildPwr = true;
  791.         }
  792.         gui.setVisible(false);
  793.         }
  794.     // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
  795.     // Generated using JFormDesigner Evaluation license - joe dirt
  796.     private JComboBox comboBox1;
  797.     private JLabel label1;
  798.     private JButton button1;
  799.     private JCheckBox checkBox1;
  800.     // JFormDesigner - End of variables declaration  //GEN-END:variables
  801. }
  802.  
  803. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement