- import java.util.Map;
- import java.awt.Font;
- import java.awt.Color;
- import java.awt.RenderingHints;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.io.*;
- import java.net.*;
- import javax.swing.JOptionPane;
- import javax.swing.JFileChooser;
- import org.rsbot.script.Constants;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.event.listeners.PaintListener;
- @ScriptManifest(authors = {"pk purewcer,Reported"}, category = "Mining", name = "RimmingtonMiner", version = 1.11, description = ("<html><body style='font-family: Calibri; background-color: black; color:white; padding: 0px; text-align:'>"
- + "<center><h2>RimmingtonMiner V1.11</h2></center>"
- + "<p>"
- + "Thanks for chosing RimmingtonMiner"
- + "<p>The script comes whit...</p>"
- + "<li>Antiban</li>"
- + "<li>Nice and good paint</li>"
- + "<li>Fast droping</li>"
- + "<li>And more!</li>"
- + "<p></p>"
- + "<select name='whatToMine'><option>Gold</option><option>Copper</option></select>"
- + "<p></p>"
- + "Start at Rimmington mine near iron rocks!"
- + "<b> Dont forget your pickaxe!</b>"))
- public class RimmingtonMiner extends Script implements PaintListener,ServerMessageListener {
- RSTile mineTile = new RSTile (2968, 3240);
- RSTile walkToMine[] = { new RSTile (2968, 3240) };
- public int[] dontDrop = { 995, 1269, 1273, 1275, 1265, 1271, 1267, 1617 };
- public int[] ironID = {9719, 9717, 9718 };
- public int[] goldID = {9722, 9720};
- public int[] copperID = {9710, 9709, 9708};
- public int AnimationID = (625);
- public int startexp;
- int oresMined = 0;
- public long startTime = System.currentTimeMillis();
- private String status = "";
- public boolean onStart (Map<String, String>args) {
- URLConnection url = null;
- BufferedReader in = null;
- BufferedWriter out = null;
- //Ask the user if they'd like to check for an update...
- if(JOptionPane.showConfirmDialog(null, "Would you like to check for updates? Please Note this requires an internet connection and the script will write files to your harddrive!") == 0){ //If they would, continue
- try{
- //Open the version text file
- url = new URL("http://www.rimmingtonminer.webs.com/scripts/RimmingtonMinerVERSION.txt").openConnection();
- //Create an input stream for it
- in = new BufferedReader(new InputStreamReader(url.getInputStream()));
- //Check if the current version is outdated
- if(Double.parseDouble(in.readLine()) > getVersion()) {
- //If it is, check if the user would like to update.
- if(JOptionPane.showConfirmDialog(null, "Update found. Do you want to update?") == 0){
- //If so, allow the user to choose the file to be updated.
- JOptionPane.showMessageDialog(null, "Please choose 'RimmingtonMiner.java' in your scripts folder and hit 'Open'");
- JFileChooser fc = new JFileChooser();
- //Make sure "Open" was clicked.
- if(fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
- //If so, set up the URL for the .java file and set up the IO.
- url = new URL("http://www.rimmingtonminer.webs.com/scripts/RimmingtonMiner.java").openConnection();
- in = new BufferedReader(new InputStreamReader(url.getInputStream()));
- out = new BufferedWriter(new FileWriter(fc.getSelectedFile().getPath()));
- String inp;
- /* Until we reach the end of the file, write the next line in the file
- * and add a new line. Then flush the buffer to ensure we lose
- * no data in the process.
- */
- while((inp = in.readLine()) != null){
- out.write(inp);
- out.newLine();
- out.flush();
- }
- //Notify the user that the script has been updated, and a recompile and reload is needed.
- log("Script successfully downloaded. Please recompile and reload your scripts!");
- return false;
- } else log("Update canceled");
- } else log("Update canceled");
- } else
- JOptionPane.showMessageDialog(null, "You have the latest version. :)"); //User has the latest version. Tell them!
- if(in != null)
- in.close();
- if(out != null)
- out.close();
- } catch (IOException e){
- log("Problem getting version :/");
- return false; //Return false if there was a problem
- }
- }
- log ("Thanks for chosing rimmingtonminer." +
- "Please start at Rimmington mine");
- startTime = System.currentTimeMillis();
- getMouseSpeed();
- if (args.get("whatToMine").equals("Gold"))
- {
- goldID = (9722, 9720);
- }
- if (args.get("whatToMine").equals("Copper"))
- {
- copperID = (9710, 9709, 9708);
- }
- if (args.get("whatToMine").equals("Iron"))
- {
- ironID = (9719, 9717, 9718);
- }
- return true;
- }
- public void onFinish() {
- log ("thanks for using me scipt" +
- "hope you like it =)");
- }
- public boolean dropAllExeptPickaxesAndMoney(){
- status = "Dropping ores.";
- dropAllExcept (dontDrop);
- return true;
- }
- public boolean atMine(){
- return distanceTo(mineTile) < 10;
- }
- public boolean mineIron() {
- try {
- final RSObject Rock = getNearestObjectByID(ironID);
- if (Rock == null) {
- status = "Waiting.";
- return false;
- }
- if (isAni()) {
- return false;
- } else {
- if (!isAni() && Rock != null) {
- atObject(Rock, "Mine");
- status = "Mining Iron.";
- wait(random(950, 1100));
- return true;
- }
- }
- } catch (Exception ignored) {
- }
- return false;
- }
- public boolean mineGold() {
- try {
- final RSObject Rock = getNearestObjectByID(goldID);
- if (Rock == null) {
- status = "Waiting";
- return false;
- }
- if (isAni()) {
- return false;
- } else {
- if (!isAni() && Rock != null) {
- atObject(Rock, "Mine");
- status = "Mining Gold.";
- wait(random(950, 1100));
- return true;
- }
- }
- } catch (Exception ignored) {
- }
- return false;
- }
- public boolean isAni() {
- if (getMyPlayer().getAnimation() == AnimationID
- || getMyPlayer().getAnimation() == 626
- || getMyPlayer().getAnimation() == 624
- || getMyPlayer().getAnimation() == 627) {
- return true;
- }
- return false;
- }
- public double getVersion() { return 1.11; } //is the current version of the script
- public boolean AntiBan(){
- status = "Antiban";
- int randomNumber = random(1, 25);
- if (randomNumber <= 25) {
- if (randomNumber == 1) {
- setCameraRotation(random(1,360));
- }
- if (randomNumber == 2) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- wait(random(300, 500));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 3) {
- wait(random(100, 500));
- moveMouse(522, 188, 220, 360);
- wait(random(100, 500));
- }
- if (randomNumber == 4) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- setCameraRotation(random(1,360));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 6) {
- wait(random(500, 1500));
- }
- if (randomNumber == 7) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 8) {
- wait(random(100, 200));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- wait(random(200, 500));
- if (randomNumber == 9) {
- wait(random(100, 200));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- if (randomNumber == 10) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 11) {
- setCameraRotation(random(1,360));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- if (randomNumber == 12) {
- openTab(TAB_STATS);
- wait(random(50, 100));
- moveMouse(522, 188, 220, 360);
- wait(random(500, 1400));
- }
- if (randomNumber == 13) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- setCameraRotation(random(1,360));
- }
- if (randomNumber == 14) {
- openTab(TAB_STATS);
- wait(random(50, 100));
- moveMouse(522, 188, 220, 360);
- wait(random(500, 1400));
- }
- if (randomNumber == 15) {
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- wait(random(500, 1000));
- moveMouse(random(50, 700), random(50, 450), 2, 2);
- }
- }
- }
- }
- return true;}
- //Credits to Garrett
- @Override
- public int loop() {
- if (isInventoryFull()) { // checks if invertory if full
- dropAllExeptPickaxesAndMoney();
- } else {
- if (!isInventoryFull()) { //checks if needs to mine
- atMine();
- mineIron();
- AntiBan();
- }
- }
- return 0;
- }
- protected int getMouseSpeed() {
- return random(4, 7);
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- String msg = e.getMessage();
- if (msg.contains("You manage to mine")) {
- oresMined++;
- }
- }
- //This variable is used for Antialiasing. DO NOT DELETE!
- private final RenderingHints rh = new RenderingHints(
- RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- public void onRepaint(Graphics g) {
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- if (isLoggedIn()) {
- int xpGained = 0;
- if ( startexp == 0) {
- startexp = skills.getCurrentSkillExp(STAT_MINING);
- }
- xpGained = skills.getCurrentSkillExp(STAT_MINING) - startexp;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- long minutes2 = minutes + (hours * 60);
- float xpsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
- xpsec = ((float) xpGained)
- / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
- }
- float xpmin = xpsec * 60;
- float xpHour = xpmin * 60;
- g.setColor(new Color(0, 153, 204, 193));
- g.fillRect(375, 201, 139, 135);
- g.setColor(new Color(0, 153, 204, 193));
- g.fillRect(375, 201, 0, 0);
- g.setColor(new Color(255, 255, 255));
- g.drawRect(375, 200, 140, 135);
- g.setColor(new Color(255, 255, 255));
- g.drawRect(375, 201, 140, 134);
- g.setColor(new Color(255, 255, 255));
- g.drawRect(376, 201, 138, 134);
- g.setFont(new Font("Narkisim", 0, 19));
- g.setColor(new Color(0, 0, 204));
- g.drawString("R.M.P.", 427, 219);
- g.setFont(new Font("Narkisim", 0, 14));
- g.setColor(new Color(255, 255, 255));
- g.drawLine(513, 225, 377, 225);
- g.setColor(Color.white);
- g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds + "." , 381, 240);
- g.drawString("Ores Mined: " + oresMined, 381, 255);
- g.drawString("Current Level: " + skills.getCurrentSkillLevel(STAT_MINING), 381, 270);
- g.drawString("XP Gained: " + xpGained, 381, 285);
- g.drawString("XP Hour: " + xpHour, 381, 300);
- final int percent = skills.getPercentToNextLevel(Constants.STAT_MINING); //change the MINING to the stat u want
- g.setColor(Color.red);
- g.fillRoundRect(3, 315, 100, 10, 15, 15); //these must be on same cordinates
- g.setColor(Color.green);
- g.fillRoundRect(3, 315, percent, 10, 15, 15); //these must be on same cordinates
- g.setFont(new Font("Narkisim", 0, 10));
- g.setColor(Color.black);
- g.drawString("%" + percent, 38, 325); //this must be on the center of the bar
- g.drawRoundRect(3, 315, 100, 10, 15, 15); //these must be on same cordinates
- g.drawRoundRect(3, 315, percent, 10, 15, 15); //these must be on same cordinates
- g.setFont(new Font("Narkisim", 0, 15));
- g.drawString("Status : " + status , 381, 330);
- }
- } // paint credits go 100% to 'Reported' he maded the paint!
- }