Advertisement
Guest User

xobot aminer

a guest
Sep 1st, 2017
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1.  
  2. import java.awt.BasicStroke;
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5. import java.awt.FlowLayout;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.awt.Graphics2D;
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11.  
  12. import javax.swing.JButton;
  13. import javax.swing.JComboBox;
  14. import javax.swing.JDialog;
  15.  
  16. import xobot.client.callback.listeners.PaintListener;
  17. import xobot.script.ActiveScript;
  18. import xobot.script.Manifest;
  19. import xobot.script.methods.GameObjects;
  20. import xobot.script.methods.Players;
  21. import xobot.script.methods.tabs.Inventory;
  22. import xobot.script.methods.tabs.Skills;
  23. import xobot.script.util.Filter;
  24. import xobot.script.util.Time;
  25. import xobot.script.util.Timer;
  26. import xobot.script.wrappers.interactive.GameObject;
  27. import xobot.script.wrappers.interactive.Item;
  28.  
  29. @Manifest(authors = { "Alex" }, name = "AlexMiner")
  30. public class aMiner extends ActiveScript implements PaintListener{
  31.  
  32.  
  33. public Timer t = null;
  34.  
  35. int mined = 0;
  36. int id1 = 0;
  37. int id2 = 0;
  38. int ore;
  39.  
  40. int startxp = 0;
  41.  
  42. int[] pickaxe = {1267, 1273, 1275, 15259};
  43.  
  44. String status = "Loading...";
  45.  
  46. public boolean onStart() {
  47. t = new Timer(System.currentTimeMillis());
  48. JDialog frame = new JDialog();
  49. frame.setPreferredSize(new Dimension(250,90));
  50. frame.setLocationRelativeTo(null);
  51. frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  52. FlowLayout layout = new FlowLayout();
  53. layout.setHgap(5);
  54. layout.setVgap(5);
  55. frame.setLayout(layout);
  56.  
  57. JComboBox<String> combo = new JComboBox<String>();
  58. combo.setPreferredSize(new Dimension(150,30));
  59. combo.setFocusable(false);
  60. combo.addItem("Tin");
  61. combo.addItem("Copper");
  62. combo.addItem("Iron");
  63. combo.addItem("Coal");
  64. combo.addItem("Mithril");
  65. combo.addItem("Adamant");
  66.  
  67. JButton button = new JButton("Start");
  68. button.setFocusable(false);
  69. button.setPreferredSize(new Dimension(60,32));
  70. button.addActionListener(new ActionListener() {
  71.  
  72. @Override
  73. public void actionPerformed(ActionEvent arg0) {
  74. String oretype = (String)combo.getSelectedItem();
  75. switch(oretype) {
  76. case "Tin":
  77. id1 = 21293;
  78. id2 = 21294;
  79. break;
  80. case "Copper":
  81. id1 = 21284;
  82. id2 = 21285;
  83. break;
  84. case "Iron":
  85. id1 = 21281;
  86. id2 = 21282;
  87. break;
  88. case "Coal":
  89. id1 = 21288;
  90. id2 = 21287;
  91. break;
  92. case "Mithril":
  93. id1 = 21280;
  94. id2 = 21278;
  95. break;
  96. case "Adamant":
  97. id1 = 21277;
  98. id2 = 21276;
  99. break;
  100. }
  101. frame.dispose();
  102. }
  103.  
  104. });
  105.  
  106. frame.add(combo);
  107. frame.add(button);
  108. frame.setTitle("AlexMiner");
  109.  
  110.  
  111. frame.pack();
  112. frame.setVisible(true);
  113. while(frame.isVisible()) {
  114. Time.sleep(500);
  115. }
  116. startxp = Skills.getCurrentExp(Skills.MINING);
  117. return id1 != 0 && id2 != 0;
  118. }
  119.  
  120. @Override
  121. public int loop() {
  122.  
  123. if(Inventory.isFull()) {
  124. status = "Dropping..";
  125. return dropAllExcept(pickaxe);
  126. }else {
  127. if(Players.getMyPlayer().getAnimation() == 6746 || Players.getMyPlayer().getAnimation() == 12188) {
  128. status = "Mining..";
  129. return 1000;
  130. }
  131. GameObject oo = GameObjects.getNearest(new Filter<GameObject>() {
  132.  
  133. @Override
  134. public boolean accept(GameObject o) {
  135.  
  136. if(o.getId() == id1 || o.getId() == id2) {
  137. return o.uid != ore;
  138. }
  139. return false;
  140. }
  141.  
  142. });
  143. if(oo != null && oo.isReachable()) {
  144. status = "Mining..";
  145. ore = oo.uid;
  146. oo.interact("mine");
  147. return 2000;
  148.  
  149. }else {
  150. return 100;
  151. }
  152. }
  153. }
  154.  
  155. private final Color color1 = new Color(102, 102, 102, 218);
  156. private final Color color2 = new Color(0, 0, 0);
  157. private final Color color3 = new Color(255, 0, 0);
  158. private final Color color4 = new Color(0, 0, 255);
  159.  
  160. private final BasicStroke stroke1 = new BasicStroke(1);
  161.  
  162. private final Font font1 = new Font("Arial", 0, 22);
  163. private final Font font2 = new Font("Arial", 0, 16);
  164.  
  165. public void repaint(Graphics g1) {
  166. int ph = (int) ((mined) * 3600000D / (t.getElapsed()));
  167. int xp = Skills.getCurrentExp(Skills.MINING) - startxp;
  168. int xph = (int) ((xp) * 3600000D / (t.getElapsed()));
  169.  
  170. Graphics2D g = (Graphics2D)g1;
  171. g.setColor(color1);
  172. g.fillRect(2, 340, 515, 138);
  173. g.setColor(color2);
  174. g.setStroke(stroke1);
  175. g.drawRect(2, 340, 515, 138);
  176. g.setFont(font1);
  177. g.setColor(color3);
  178. g.drawString("Alex Power Miner", 173, 367);
  179. g.setFont(font2);
  180. g.setColor(color4);
  181. g.drawString("Mined ores: " + mined, 14, 396);
  182. g.drawString("Mined ores(hr): " + ph, 14, 425);
  183. g.drawString("XP: " + xp, 237, 393);
  184. g.drawString("XP(h): " + xph, 237, 422);
  185. g.drawString(t.toElapsedString(), 380, 365);
  186. g.drawString("Status: " + status, 17, 457);
  187. }
  188.  
  189.  
  190. public int dropAllExcept(int[] items) {
  191. boolean found = false;
  192. for(Item i : Inventory.getItems()) {
  193. if(i != null) {
  194. for(int item : items) {
  195. if(item == i.getID()) {
  196. found = true;
  197. break;
  198. }
  199. }
  200. if(!found) {
  201. i.interact("drop");
  202. mined+=1;
  203. Time.sleep(50);
  204. }
  205. found = false;
  206. }
  207. }
  208. return 500;
  209. }
  210.  
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement