- import java.awt.*;
- import java.awt.Component;
- import java.awt.Graphics;
- import javax.swing.JOptionPane;
- 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.interactive.Players;
- import org.powerbot.game.api.methods.node.SceneEntities;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.util.Filter;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.game.api.wrappers.node.SceneObject;
- import org.powerbot.game.bot.event.listener.PaintListener;
- import java.util.Timer;
- @Manifest(authors = { "Syndicate" }, name = "SynMiner", description = "Power Mines Any Rock!", version = 1.0)
- public class SynMiner extends ActiveScript implements PaintListener{
- private int rock; // ints are stored values that are numbers only
- private int ore;
- private boolean start = false; // booleans are always a way to determin true or false
- @Override
- protected void setup() {
- AskRock ar = new AskRock();
- submit(ar);
- Mine m = new Mine();
- Strategy mStrategy = new Strategy(m, m);
- provide(mStrategy);
- Drop d = new Drop();
- Strategy dStrategy = new Strategy(d, d);
- provide(dStrategy);
- } // everything inside above is what gets started up when the script starts
- //(this stuff only runs once when the script is started then not again)
- private class AskRock implements Task,Condition {
- @Override
- public void run() {
- try {
- Component frame = null;
- rock = Integer.parseInt(JOptionPane.showInputDialog(frame, // opens a window to ask
- "Enter Your Rock ID Here!" + // for a number thats the ID of the rock
- " Iron Ore Is: 11956 / Varrock",
- "SynMiner V1.0 By: Syndicate",
- JOptionPane.INFORMATION_MESSAGE));
- } catch (Exception e) {
- stop();
- }
- AskOre ao = new AskOre();
- submit(ao);
- }
- @Override
- public boolean validate() {
- return true;
- }
- }
- private class AskOre implements Task,Condition {
- @Override
- public void run() {
- try {
- Component frame = null;
- ore = Integer.parseInt(JOptionPane.showInputDialog(frame, // opens a window to ask
- "Enter Your Ore ID Here!" + // for a number thats the ID of the ore
- " Iron Ore Is: 440",
- "SynMiner V1.0 By: Syndicate",
- JOptionPane.INFORMATION_MESSAGE));
- } catch (Exception e) {
- stop();
- }
- start = true;
- }
- @Override
- public boolean validate() {
- return false;
- }
- }
- private class Mine implements Task,Condition {
- @Override
- public void run() {
- SceneObject Rock = SceneEntities.getNearest(new Filter<SceneObject>() {
- @Override
- public boolean accept(SceneObject ROCK) {
- //
- return start && ROCK.getId() == rock;
- }
- });
- if (Rock.isOnScreen() && !Inventory.isFull()) {
- Rock.interact("Mine");
- Time.sleep(1000,1800);
- if (Players.getLocal().getAnimation() != -1) {
- Time.sleep(500,800);
- }
- }
- }
- @Override
- public boolean validate() {
- return start;
- }
- }
- private class Drop implements Task,Condition {
- @Override
- public void run() {
- for (Item i : Inventory.getItems(new Filter<Item>()
- {public boolean accept(Item a) {return (a.getId() == ore);}})) {
- i.getWidgetChild().interact("Drop");
- }
- }
- @Override
- public boolean validate() {
- return start && Inventory.getCount() == 28;
- }
- }
- {
- }
- public void onRepaint1(Graphics arg0) {
- }
- private final Color color1 = new Color(18, 122, 55, 188);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(0, 239, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 14);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRoundRect(547, 264, 190, 218, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(547, 264, 190, 218, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("SynMiner v1", 581, 284);
- g.drawString("Time Running:", 548, 326);
- g.drawString("Xp Per Hour:", 550, 367);
- g.drawString("Xp Gained:", 551, 407);
- g.drawString("Made By Syndicate", 578, 476);
- }
- }