Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.text.DecimalFormat;
- import java.awt.event.*;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.net.URLConnection;
- import javax.swing.*;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.Walking;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.SceneEntities;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.tab.Skills;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.wrappers.Area;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.node.SceneObject;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.MessageEvent;
- import org.powerbot.game.bot.event.listener.MessageListener;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(name = "GuildMiner", description = "Mines Mithril at the Mining Guild", version = 1.0, authors = {"Thondar"})
- public class GuildMiner extends ActiveScript implements PaintListener, MessageListener {
- private int MithrilP(int id) throws IOException {
- URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + MithrilOre);
- URLConnection con = url.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(
- con.getInputStream()));
- String line = "";
- String inputLine;
- while ((inputLine = in.readLine()) != null) {
- line += inputLine;
- }
- in.close();
- if (!line.contains("mark_price"))
- return -1;
- line = line.substring(line.indexOf("mark_price\":\"")
- + "mark_price\":\"".length());
- line = line.substring(0, line.indexOf("\""));
- return Integer.parseInt(line.replaceAll(",", ""));
- }
- int RandomGift = 14664;
- int startLVL;
- int MithrilVein[] = {5786, 5785, 5784};
- int MithrilOre = 447;
- int Ladder = 2113;
- int MithrilPrice;
- int MithrilCount;
- int Profit;
- int ProfitHour;
- int Banker = 6200;
- int Saphire = 1623;
- int Ruby = 1619;
- int Emerald = 1621;
- int Diamond = 1617;
- long startXP;
- long startTime;
- long runTime, xpTime;
- long hr, min, sec, xphr, xpmin, xpsec;
- long xpGain;
- private static WidgetChild FalaTele;
- String time;
- String status;
- String xptime;
- GUI g;
- private boolean guiWait = true;
- Tile MineTile = new Tile(3047, 9739, 0);
- Tile StilesTile = new Tile(2857, 3146, 0);
- DecimalFormat format = new DecimalFormat("#.##");
- boolean start = false;
- boolean Note = true;
- Area BankArea = new Area(new Tile(3009, 3355, 0), new Tile(3018, 3358, 0));
- Area GuildArea = new Area(new Tile(3041, 9732, 0), new Tile(3055, 9749, 0));
- Area WalkArea = new Area(new Tile(3015, 9732, 0), new Tile(3040, 9749, 0));
- Area ClimbArea = new Area(new Tile(3014, 3335, 0), new Tile(3025, 3345, 0));
- Tile[] TilesToBank = new Tile[] { new Tile(2966, 3394, 0),
- new Tile(2967, 3381, 0), new Tile(2975, 3378, 0),
- new Tile(2986, 3373, 0), new Tile(2995, 3366, 0),
- new Tile(3005, 3362, 0), new Tile(3013, 3357, 0)
- };
- Tile[] TilesToOre = new Tile[] { new Tile(3024, 9739, 0),
- new Tile(3034, 9738, 0), new Tile(3042, 9737, 0),
- };
- Tile[] TilesToGuild = new Tile[] { new Tile(3018, 3361, 0),
- new Tile(3023, 3350, 0), new Tile(3030, 3343, 0),
- new Tile(3022, 3338, 0)
- };
- @Override
- protected void setup() {
- log.info("GuildMiner 1.0");
- log.info("Made by Thondar");
- start = true;
- status = ("Starting Up");
- Walking.setRun(true);
- try {
- MithrilPrice = MithrilP(MithrilOre);
- } catch (IOException e) {
- e.printStackTrace();
- }
- g = new GUI();
- g.setVisible(true);
- final WaitGui guiTask = new WaitGui();
- provide(new Strategy(guiTask, guiTask));
- provide(new Strategy(new WaitGui(), new WaitGui()));
- startTime = System.currentTimeMillis();
- startXP = Skills.getExperience(Skills.MINING);
- startLVL = Skills.getLevel(Skills.MINING);
- Mine mine = new Mine();
- Strategy mineStrategy = new Strategy(mine, mine);
- provide(mineStrategy);
- MineWait minewait = new MineWait();
- Strategy minewaitStrategy = new Strategy(minewait, minewait);
- provide(minewaitStrategy);
- GuildWalk guildwalk = new GuildWalk();
- Strategy guildwalkStrategy = new Strategy(guildwalk, guildwalk);
- provide(guildwalkStrategy);
- BankWalk bankwalk = new BankWalk();
- Strategy bankwalkStrategy = new Strategy(bankwalk, bankwalk);
- provide(bankwalkStrategy);
- MineWalk minewalk = new MineWalk();
- Strategy minewalkStrategy = new Strategy(minewalk, minewalk);
- provide(minewalkStrategy);
- Climb climb = new Climb();
- Strategy climbStrategy = new Strategy(climb, climb);
- provide(climbStrategy);
- FalaTele falatele = new FalaTele();
- Strategy falateleStrategy = new Strategy(falatele, falatele);
- provide(falateleStrategy);
- Bank bank = new Bank();
- Strategy bankStrategy = new Strategy(bank, bank);
- provide(bankStrategy);
- BankOpen bankopen = new BankOpen();
- Strategy bankopenStrategy = new Strategy(bankopen, bankopen);
- provide(bankopenStrategy);
- AntiBan ab = new AntiBan();
- Strategy abStrategy = new Strategy(ab, ab);
- provide(abStrategy);
- Tabs.INVENTORY.open(false);
- }
- private class WaitGui implements Task, Condition {
- @Override
- public void run() {
- while (guiWait) {
- Time.sleep(500);
- }
- }
- public boolean validate() {
- return guiWait;
- }
- }
- private class Mine implements Task, Condition {
- @Override
- public void run() {
- Mine();
- Time.sleep(Random.nextInt(1200, 1600));
- }
- @Override
- public boolean validate() {
- return !Inventory.isFull() && GuildArea.contains(Players.getLocal()) && SceneEntities.getNearest(MithrilVein).isOnScreen();
- }
- }
- private class MineWait implements Task, Condition {
- @Override
- public void run() {
- Walking.walk(MineTile);
- status = ("Waiting");
- Camera.setPitch(Random.nextInt(19, 68));
- Camera.setAngle(Random.nextInt(204, 224));
- Time.sleep(Random.nextInt(600, 1100));
- }
- @Override
- public boolean validate() {
- return !Inventory.isFull() && (Players.getLocal().getAnimation() == -1) && GuildArea.contains(Players.getLocal()) && !SceneEntities.getNearest(MithrilVein).isOnScreen();
- }
- }
- private class GuildWalk implements Task, Condition {
- @Override
- public void run() {
- status = ("Walking");
- Walking.newTilePath(TilesToOre).traverse();
- Time.sleep(Random.nextInt(300, 500));
- }
- @Override
- public boolean validate() {
- return !Inventory.isFull() && (Players.getLocal().getAnimation() == -1) && WalkArea.contains(Players.getLocal());
- }
- }
- private class BankWalk implements Task, Condition {
- @Override
- public void run() {
- Walking.setRun(true);
- status = ("Walking");
- Walking.newTilePath(TilesToBank).traverse();
- Time.sleep(Random.nextInt(300, 500));
- }
- @Override
- public boolean validate() {
- return Inventory.isFull() && !BankArea.contains(Players.getLocal()) && !GuildArea.contains(Players.getLocal());
- }
- }
- private class MineWalk implements Task, Condition {
- @Override
- public void run() {
- status = ("Walking");
- Walking.newTilePath(TilesToGuild).traverse();
- Time.sleep(Random.nextInt(300, 500));
- }
- @Override
- public boolean validate() {
- return !Inventory.isFull() && !WalkArea.contains(Players.getLocal()) && !GuildArea.contains(Players.getLocal());
- }
- }
- private class FalaTele implements Task, Condition {
- @Override
- public void run() {
- FalaTele();
- }
- @Override
- public boolean validate() {
- return Inventory.isFull() && (Players.getLocal().getAnimation() == -1) && GuildArea.contains(Players.getLocal());
- }
- }
- private class Climb implements Task, Condition {
- @Override
- public void run() {
- SceneEntities.getNearest(Ladder).interact("Climb-down");
- Time.sleep(Random.nextInt(600, 900));
- }
- @Override
- public boolean validate() {
- return !Inventory.isFull() && (Players.getLocal().getAnimation() == -1) && ClimbArea.contains(Players.getLocal());
- }
- }
- private class BankOpen implements Task, Condition {
- @Override
- public void run() {
- status = ("Banking");
- NPCs.getNearest(Banker).interact("Bank");
- Time.sleep(500);
- }
- @Override
- public boolean validate() {
- return Inventory.isFull() && NPCs.getNearest(Banker).isOnScreen() && (Players.getLocal().getAnimation() == -1);
- }
- }
- private class Bank implements Task, Condition {
- @Override
- public void run() {
- status = ("Banking");
- org.powerbot.game.api.methods.widget.Bank.deposit(MithrilOre, 28);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.deposit(Saphire, 28);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.deposit(Ruby, 28);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.deposit(Emerald, 28);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.deposit(Diamond, 28);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.close();
- }
- @Override
- public boolean validate() {
- return Inventory.isFull() && org.powerbot.game.api.methods.widget.Bank.isOpen();
- }
- }
- private class AntiBan implements Task, Condition {
- @Override
- public void run() {
- switch(Random.nextInt(1, 100)){
- case 3:
- Camera.setAngle(Random.nextInt(1, 150));
- Camera.setPitch(Random.nextInt(20, 50));
- case 33:
- Camera.setAngle(Random.nextInt(1, 310));
- Camera.setPitch(Random.nextInt(20, 50));
- case 75:
- Camera.setAngle(Random.nextInt(1, 210));
- Camera.setPitch(Random.nextInt(20, 50));
- default:
- }
- Time.sleep(Random.nextInt(500, 1000));
- }
- @Override
- public boolean validate() {
- return start;
- }
- }
- public void Mine() {
- log.info("Mining");
- status = ("Mining");
- Tabs.INVENTORY.open(false);
- SceneObject i = SceneEntities.getNearest(MithrilVein);
- if (i != null) {
- Camera.turnTo(i.getLocation());
- SceneEntities.getNearest(MithrilVein).interact("Mine");
- }
- }
- public void FalaTele() {
- Tabs.MAGIC.open(false);
- Time.sleep(500);
- FalaTele = Widgets.get(192, 24);
- FalaTele.click(true);
- Time.sleep(500);
- Mouse.move(275, 200);
- Mouse.click(true);
- status = ("Teleporting");
- Time.sleep(500);
- }
- @Override
- public void messageReceived(MessageEvent e) {
- String txt = e.getMessage().toLowerCase();
- if(txt.contains("you manage to mine some mithril")) {
- MithrilCount++;}
- }
- private AlphaComposite makeComposite(float alpha) {
- int type = AlphaComposite.SRC_OVER;
- return(AlphaComposite.getInstance(type, alpha));
- }
- private final Font font1 = new Font("Verdana", 0, 16);
- private final Font font2 = new Font("Verdana", 0, 12);
- private final Font font3 = new Font("Verdana", 0, 13);
- private final Font font4 = new Font("Verdana", 0, 9);
- @Override
- public void onRepaint(Graphics g) {
- Graphics2D g2d = (Graphics2D) g;
- runTime = System.currentTimeMillis() - startTime;
- time = "";
- hr = runTime / (1000 * 60 * 60);
- min = (runTime % (1000 * 60 * 60)) / (1000 * 60);
- sec = ((runTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
- xpGain = (Skills.getExperience(Skills.MINING) - startXP);
- int xpHour = (int) ((xpGain) * 3600000D / (System
- .currentTimeMillis() - startTime));
- int level = Skills.getLevel(Skills.MINING);
- int startXP = Skills.getExperienceRequired(level);
- int nextXP = Skills.getExperienceRequired(level + 1);
- double rangeXP = nextXP-startXP;
- double currentRelativeXP = Skills.getExperience(Skills.MINING) - startXP;
- double currentXPleft = nextXP - Skills.getExperience(Skills.MINING);
- double percentA = currentRelativeXP/rangeXP;
- double percentToLvl = ((percentA) * 100D);
- double percent = (int) ((percentA) * 500D);
- xpTime = (long) ((currentXPleft / xpHour) * 3600000D);
- xptime = "";
- if(MithrilCount == 0) {
- xphr = 0;
- xpmin = 0;
- xpsec = 0;
- }
- if(MithrilCount >= 1) {
- xphr = xpTime / (1000 * 60 * 60);
- xpmin = (xpTime % (1000 * 60 * 60)) / (1000 * 60);
- xpsec = ((xpTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
- }
- int MithrilHour = (int) ((MithrilCount) * 3600000D / (System
- .currentTimeMillis() - startTime));
- Profit = MithrilCount * MithrilPrice;
- ProfitHour = MithrilHour * MithrilPrice;
- Rectangle bg = new Rectangle(10, 10, 160, 320);
- g2d.setComposite(makeComposite(.5f));
- g2d.setColor(Color.LIGHT_GRAY);
- g2d.fill(bg);
- g2d.setComposite(makeComposite(.5f));
- g2d.setColor(Color.BLACK);
- g2d.drawRect(10, 10, 160, 320);
- g2d.setFont(font1);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.BLUE);
- g2d.drawString("GuildMiner", 50, 30);
- g2d.setFont(font3);
- g2d.drawString("By Thondar", 55, 45);
- g2d.setFont(font4);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.BLUE);
- g2d.drawString("Version 1.0", 61, 55);
- g2d.setComposite(makeComposite(.5f));
- g2d.setColor(Color.BLACK);
- g2d.drawLine(20, 60, 160, 60);
- g2d.drawLine(20, 110, 160, 110);
- g2d.drawLine(20, 160, 160, 160);
- g2d.drawLine(20, 210, 160, 210);
- g2d.drawLine(20, 260, 160, 260);
- g2d.drawLine(20, 310, 160, 310);
- g2d.setFont(font2);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Time Run: " + hr + ":" + min + ":" + sec, 30, 80);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Status: " + status, 30, 100);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("XP/H: " + xpHour, 30, 130);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("XP Gained: " + xpGain, 30, 150);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Current Level: " + (Skills.getLevel(Skills.MINING)), 30, 180);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Levels Gained: " + (Skills.getLevel(Skills.MINING) - startLVL), 30, 200);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Mithril Mined: " + MithrilCount, 30, 230);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Mithril Mined/H: " + MithrilHour , 30, 250);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Profit: " + Profit, 30, 280);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Profit/h: " + ProfitHour, 30, 300);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(new Color (0x00, 0x33, 0xff));
- g2d.drawString("Time to lvl: " + xphr + ":" + xpmin + ":" + xpsec, 30, 325);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.BLACK);
- g2d.drawRect(10, 330, 500, 15);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.LIGHT_GRAY);
- g2d.fillRect(11, 331, 499, 13);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.GREEN);
- g2d.fillRect(11, 331,(int) (percent), 13);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.BLUE);
- g2d.drawString (String.format("%.2f", percentToLvl) + "%" , 225, 342);
- }
- class GUI extends JFrame {
- public GUI() {
- initComponents();
- }
- private void StartButtonActionPerformed(ActionEvent e) {
- guiWait = false;
- g.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
- StartButton = new JButton();
- label1 = new JLabel();
- label2 = new JLabel();
- label3 = new JLabel();
- label4 = new JLabel();
- label5 = new JLabel();
- label6 = new JLabel();
- label7 = new JLabel();
- //======== this ========
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- StartButton ----
- StartButton.setText("Start");
- StartButton.setFont(new Font("Calibri", Font.PLAIN, 14));
- StartButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- StartButtonActionPerformed(e);
- }
- });
- contentPane.add(StartButton);
- StartButton.setBounds(5, 195, 230, 75);
- //---- label1 ----
- label1.setText("GuildMiner");
- label1.setFont(new Font("MV Boli", Font.BOLD, 24));
- label1.setHorizontalAlignment(SwingConstants.CENTER);
- contentPane.add(label1);
- label1.setBounds(5, 0, 225, 65);
- //---- label2 ----
- label2.setText("By Thondar");
- label2.setHorizontalAlignment(SwingConstants.CENTER);
- label2.setFont(new Font("MV Boli", Font.PLAIN, 14));
- contentPane.add(label2);
- label2.setBounds(0, 45, 240, label2.getPreferredSize().height);
- //---- label3 ----
- label3.setText("Make sure you have your desired");
- label3.setHorizontalAlignment(SwingConstants.CENTER);
- label3.setFont(new Font("Calibri", Font.PLAIN, 12));
- contentPane.add(label3);
- label3.setBounds(0, 100, 240, 15);
- //---- label4 ----
- label4.setText(" Pickaxe in your inventory before starting");
- label4.setHorizontalAlignment(SwingConstants.CENTER);
- label4.setFont(new Font("Calibri", Font.PLAIN, 12));
- contentPane.add(label4);
- label4.setBounds(0, 115, 240, 15);
- //---- label5 ----
- label5.setText(" If you start the script without a Pickaxe,");
- label5.setHorizontalAlignment(SwingConstants.CENTER);
- label5.setFont(new Font("Calibri", Font.PLAIN, 12));
- contentPane.add(label5);
- label5.setBounds(0, 135, 240, 20);
- //---- label6 ----
- label6.setText("it will use your Bronze Pickaxe");
- label6.setHorizontalAlignment(SwingConstants.CENTER);
- label6.setFont(new Font("Calibri", Font.PLAIN, 12));
- contentPane.add(label6);
- label6.setBounds(0, 155, 240, 15);
- //---- label7 ----
- label7.setText(" from your toolbelt");
- label7.setHorizontalAlignment(SwingConstants.CENTER);
- label7.setFont(new Font("Calibri", Font.PLAIN, 12));
- contentPane.add(label7);
- label7.setBounds(0, 170, 240, label7.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
- private JButton StartButton;
- private JLabel label1;
- private JLabel label2;
- private JLabel label3;
- private JLabel label4;
- private JLabel label5;
- private JLabel label6;
- private JLabel label7;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment