Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JDialog;
- import xobot.client.callback.listeners.PaintListener;
- import xobot.script.ActiveScript;
- import xobot.script.Manifest;
- import xobot.script.methods.GameObjects;
- import xobot.script.methods.Players;
- import xobot.script.methods.tabs.Inventory;
- import xobot.script.methods.tabs.Skills;
- import xobot.script.util.Filter;
- import xobot.script.util.Time;
- import xobot.script.util.Timer;
- import xobot.script.wrappers.interactive.GameObject;
- import xobot.script.wrappers.interactive.Item;
- @Manifest(authors = { "Alex" }, name = "AlexMiner")
- public class aMiner extends ActiveScript implements PaintListener{
- public Timer t = null;
- int mined = 0;
- int id1 = 0;
- int id2 = 0;
- int ore;
- int startxp = 0;
- int[] pickaxe = {1267, 1273, 1275, 15259};
- String status = "Loading...";
- public boolean onStart() {
- t = new Timer(System.currentTimeMillis());
- JDialog frame = new JDialog();
- frame.setPreferredSize(new Dimension(250,90));
- frame.setLocationRelativeTo(null);
- frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- FlowLayout layout = new FlowLayout();
- layout.setHgap(5);
- layout.setVgap(5);
- frame.setLayout(layout);
- JComboBox<String> combo = new JComboBox<String>();
- combo.setPreferredSize(new Dimension(150,30));
- combo.setFocusable(false);
- combo.addItem("Tin");
- combo.addItem("Copper");
- combo.addItem("Iron");
- combo.addItem("Coal");
- combo.addItem("Mithril");
- combo.addItem("Adamant");
- JButton button = new JButton("Start");
- button.setFocusable(false);
- button.setPreferredSize(new Dimension(60,32));
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- String oretype = (String)combo.getSelectedItem();
- switch(oretype) {
- case "Tin":
- id1 = 21293;
- id2 = 21294;
- break;
- case "Copper":
- id1 = 21284;
- id2 = 21285;
- break;
- case "Iron":
- id1 = 21281;
- id2 = 21282;
- break;
- case "Coal":
- id1 = 21288;
- id2 = 21287;
- break;
- case "Mithril":
- id1 = 21280;
- id2 = 21278;
- break;
- case "Adamant":
- id1 = 21277;
- id2 = 21276;
- break;
- }
- frame.dispose();
- }
- });
- frame.add(combo);
- frame.add(button);
- frame.setTitle("AlexMiner");
- frame.pack();
- frame.setVisible(true);
- while(frame.isVisible()) {
- Time.sleep(500);
- }
- startxp = Skills.getCurrentExp(Skills.MINING);
- return id1 != 0 && id2 != 0;
- }
- @Override
- public int loop() {
- if(Inventory.isFull()) {
- status = "Dropping..";
- return dropAllExcept(pickaxe);
- }else {
- if(Players.getMyPlayer().getAnimation() == 6746 || Players.getMyPlayer().getAnimation() == 12188) {
- status = "Mining..";
- return 1000;
- }
- GameObject oo = GameObjects.getNearest(new Filter<GameObject>() {
- @Override
- public boolean accept(GameObject o) {
- if(o.getId() == id1 || o.getId() == id2) {
- return o.uid != ore;
- }
- return false;
- }
- });
- if(oo != null && oo.isReachable()) {
- status = "Mining..";
- ore = oo.uid;
- oo.interact("mine");
- return 2000;
- }else {
- return 100;
- }
- }
- }
- private final Color color1 = new Color(102, 102, 102, 218);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 0, 0);
- private final Color color4 = new Color(0, 0, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 22);
- private final Font font2 = new Font("Arial", 0, 16);
- public void repaint(Graphics g1) {
- int ph = (int) ((mined) * 3600000D / (t.getElapsed()));
- int xp = Skills.getCurrentExp(Skills.MINING) - startxp;
- int xph = (int) ((xp) * 3600000D / (t.getElapsed()));
- Graphics2D g = (Graphics2D)g1;
- g.setColor(color1);
- g.fillRect(2, 340, 515, 138);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(2, 340, 515, 138);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("Alex Power Miner", 173, 367);
- g.setFont(font2);
- g.setColor(color4);
- g.drawString("Mined ores: " + mined, 14, 396);
- g.drawString("Mined ores(hr): " + ph, 14, 425);
- g.drawString("XP: " + xp, 237, 393);
- g.drawString("XP(h): " + xph, 237, 422);
- g.drawString(t.toElapsedString(), 380, 365);
- g.drawString("Status: " + status, 17, 457);
- }
- public int dropAllExcept(int[] items) {
- boolean found = false;
- for(Item i : Inventory.getItems()) {
- if(i != null) {
- for(int item : items) {
- if(item == i.getID()) {
- found = true;
- break;
- }
- }
- if(!found) {
- i.interact("drop");
- mined+=1;
- Time.sleep(50);
- }
- found = false;
- }
- }
- return 500;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement