Guest User

Untitled

a guest
Nov 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.84 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Container;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Image;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.awt.event.MouseEvent;
  13. import java.awt.event.MouseListener;
  14. import java.io.IOException;
  15. import java.lang.reflect.InvocationTargetException;
  16. import java.net.URL;
  17.  
  18. import javax.imageio.ImageIO;
  19. import javax.swing.DefaultComboBoxModel;
  20. import javax.swing.GroupLayout;
  21. import javax.swing.ImageIcon;
  22. import javax.swing.JButton;
  23. import javax.swing.JComboBox;
  24. import javax.swing.JFrame;
  25. import javax.swing.JLabel;
  26. import javax.swing.LayoutStyle;
  27. import javax.swing.SwingUtilities;
  28. import javax.swing.WindowConstants;
  29.  
  30. import org.rsbuddy.tabs.Equipment;
  31. import org.rsbuddy.tabs.Inventory;
  32. import org.rsbuddy.widgets.Bank;
  33.  
  34. import com.rsbuddy.event.events.MessageEvent;
  35. import com.rsbuddy.event.listeners.MessageListener;
  36. import com.rsbuddy.event.listeners.PaintListener;
  37. import com.rsbuddy.script.ActiveScript;
  38. import com.rsbuddy.script.Manifest;
  39. import com.rsbuddy.script.methods.Calculations;
  40. import com.rsbuddy.script.methods.Camera;
  41. import com.rsbuddy.script.methods.Game;
  42. import com.rsbuddy.script.methods.Mouse;
  43. import com.rsbuddy.script.methods.Objects;
  44. import com.rsbuddy.script.methods.Players;
  45. import com.rsbuddy.script.methods.Skills;
  46. import com.rsbuddy.script.methods.Walking;
  47. import com.rsbuddy.script.task.LoopTask;
  48. import com.rsbuddy.script.util.Random;
  49. import com.rsbuddy.script.util.Timer;
  50. import com.rsbuddy.script.wrappers.Area;
  51. import com.rsbuddy.script.wrappers.GameObject;
  52.  
  53. @Manifest(name = "Insan3's Rimmmington Iron Miner", authors = ("1nsan3" ), version = 1.1, keywords = ( "Mining" ), description = "Mining iron like no before.")
  54. public class PowerMiner extends ActiveScript implements MessageListener, PaintListener, MouseListener{
  55.  
  56. private int[] rockId = {9717, 9718, 9719};
  57. public String status = "Unknown";
  58. private int axeid[] = {1267, 1269, 1271, 1273, 1275, 10499, 14107, 15259}; // axeid
  59. public int bankId = 2015;
  60. public int oreid = 440;
  61. private final Area bankarea = new Area(3088, 3239, 3098, 3247);
  62. private final Area orearea = new Area(2966, 3235, 2972, 3243);
  63. private int oresMined = 0;
  64. private int startExp = 0;
  65. private long startTime;
  66.  
  67. public boolean dropping;
  68. public boolean banking;
  69. public int OreID;
  70. private int BD; // what does this do? :P i forgot
  71. static int dropAmount;
  72.  
  73. /*
  74. * gui variables
  75. */
  76. public rimminergui GUI; //why are these up here lol why not cos they're part of your gui, they should be in your gui class o.o
  77.  
  78. public boolean onStart() {
  79. try {
  80. SwingUtilities.invokeAndWait(new Runnable()
  81. {
  82. public void run()
  83. {
  84. GUI = new rimminergui();
  85. GUI.setVisible(true);
  86. }
  87. });
  88. }catch(Exception e){
  89. log(e);
  90. }
  91. while(GUI.isVisible())
  92. {
  93. sleep(50);
  94. }
  95. startTime = System.currentTimeMillis();
  96. status = "Starting";
  97. getContainer().submit(new LoopTask(){
  98. public int loop(){
  99. antiBan();
  100. return Random.nextInt(20000,40000);
  101. }
  102. });
  103. log("If you find any bugs please message me!");
  104. return true;
  105. }
  106.  
  107. private Image getImage(String url) {
  108. try {
  109. return ImageIO.read(new URL(url));
  110. } catch(IOException e) {
  111. return null;
  112. }
  113. }
  114.  
  115.  
  116.  
  117. @Override
  118. public int loop() {
  119.  
  120. if(Walking.getEnergy() < Random.nextInt(50,60)){
  121. Walking.setRun(true);
  122. }
  123.  
  124. if (Walking.getEnergy() <= Random.nextInt(15, 30)) {
  125. Walking.rest();
  126. }
  127.  
  128. if (GUI.drop) {
  129. if(!Inventory.isFull()){
  130. mine();
  131. }else{
  132. drop();
  133. }
  134. }
  135.  
  136. if (GUI.m1d1) {
  137. if(!Inventory.containsOneOf(oreid)) {
  138. mine();
  139. }else{
  140. m1d1();
  141. }
  142. }
  143.  
  144. if (GUI.bank) { //same idea, but its just neater i suppose so
  145. Bank();
  146. }
  147. return 650;
  148. }
  149.  
  150.  
  151.  
  152.  
  153.  
  154. public void Bank() {
  155. GameObject rock = Objects.getNearest(rockId);
  156. GameObject bank = Objects.getNearest(bankId);
  157.  
  158.  
  159. if (!isMining() && orearea.contains(Players.getLocal().getLocation()) && !Inventory.isFull()) {
  160. mine();
  161. }
  162. if (Inventory.isFull() && !bankarea.contains(Players.getLocal().getLocation())) {
  163. walkbank();
  164. }
  165. if (bankarea.contains(Players.getLocal().getLocation()) && Inventory.isFull()) {
  166. bank();
  167. }
  168. if (!Inventory.isFull() && !orearea.contains(Players.getLocal().getLocation())) {
  169. walkore();
  170. }
  171. }
  172.  
  173.  
  174. public void drop() {
  175. GameObject rock = Objects.getNearest(rockId);
  176.  
  177. if (!Inventory.isFull() && !orearea.contains(Players.getLocal().getLocation())) {
  178. walkore();
  179. }
  180. if (Inventory.isFull()) {
  181. status = "Dropping ores";
  182. Inventory.dropAllExcept(axeid);
  183. }
  184. /*if (!Inventory.isFull() && rock != null && !rock.isOnScreen()) {
  185. Walking.stepTowards(rock.getLocation()) ;
  186. sleep(750, 1100);
  187. }*/
  188. return;
  189. }
  190.  
  191. public void m1d1() {
  192. GameObject rock = Objects.getNearest(rockId);
  193. if (!Inventory.isFull() && !orearea.contains(Players.getLocal().getLocation())) {
  194. walkore();
  195. }
  196. if (Inventory.containsOneOf(oreid)) {
  197. status = "Dropping ores";
  198. Inventory.dropAllExcept(axeid);
  199. }
  200.  
  201. return;
  202. }
  203.  
  204. public void bank() {
  205. GameObject bank = Objects.getNearest(bankId);
  206. if (Inventory.isFull())
  207. if (bank != null && bankarea.contains(Players.getLocal().getLocation())) {
  208. Camera.turnTo(bank);
  209. sleep(500, 600);
  210. status = "Banking";
  211. bank.interact("Use-quickly");
  212. sleep(200, 220);
  213. }
  214. if (Inventory.isFull())
  215. if (Bank.isOpen() && bankarea.contains(Players.getLocal().getLocation())) {
  216. sleep(500, 600);
  217. status = "Banking";
  218. Bank.depositAllExcept(axeid);
  219. sleep(200, 220);
  220. Bank.close();
  221. }
  222. }
  223.  
  224. public void walkbank() {
  225.  
  226. if (Calculations.distanceTo(bankarea.getCentralTile()) <= 1000) {
  227. Walking.findPath(bankarea.getCentralTile().randomize(3, 3)).traverse();
  228. status = "Walking to bank";
  229. sleep(200, 300);
  230. }
  231. }
  232.  
  233. public void walkore() {
  234.  
  235. if (Calculations.distanceTo(orearea.getCentralTile()) <= 1000) {
  236. Walking.findPath(orearea.getCentralTile().randomize(3, 3)).traverse();
  237. status = "Walking to ores";
  238. sleep(200, 300);
  239. }
  240.  
  241. }
  242.  
  243.  
  244. private boolean isMining() {
  245. if (Players.getLocal().getAnimation() != -1
  246. || Players.getLocal().isMoving()) {
  247. return true;
  248.  
  249. }
  250. return false;
  251. }
  252.  
  253. private void mine() {
  254. GameObject rock = Objects.getNearest(rockId);
  255. if (Players.getLocal().isIdle() && rock != null) {
  256. status = "Mining";
  257. rock.interact("Mine");
  258. sleep(600, 900);
  259. antiBan(); }
  260. return;
  261. }
  262.  
  263.  
  264.  
  265. //Antiban
  266.  
  267.  
  268. private void antiBan() {
  269. int ab = Random.nextInt(0, 4);
  270. switch (ab) {
  271. case 1://Rotating camera
  272. Camera.setCompassAngle(Random.nextInt(30, 70));
  273. sleep(400, 1200);
  274. break;
  275. case 2://Hovering over skill checking exp
  276. Game.openTab(1);
  277. Skills.hover(Skills.COMPONENT_MINING);
  278. sleep(2100, 2400);
  279. break;
  280. case 3://Move mouse
  281. Mouse.moveSlightly();
  282. break;
  283. case 4://Move mouse off screen
  284. Mouse.moveOffScreen();
  285. sleep(100, 300);
  286. break;
  287. }
  288. }
  289.  
  290. /*
  291. * Paint stuff
  292. */
  293.  
  294.  
  295. private final Color color1 = new Color(255, 51, 0);
  296. private final Color color2 = new Color(0, 0, 0);
  297. private final Color color3 = new Color(51, 153, 255);
  298.  
  299. private final BasicStroke stroke1 = new BasicStroke(1);
  300.  
  301. private final Font font1 = new Font("Arial", 0, 18);
  302. private final Font font2 = new Font("Tahoma", 0, 18);
  303.  
  304. private Image img1 = new ImageIcon("C:\\Users\\Javier\\Downloads\\Finished-2.png").getImage();
  305.  
  306. public void onRepaint(Graphics g1) {
  307. Graphics2D g = (Graphics2D)g1;
  308. int TTNL = (Skills.getExpToNextLevel(Skills.MINING));
  309. long millis = System.currentTimeMillis() - startTime;
  310. long hours = millis / (1000 * 60 * 60);
  311. millis -= hours * (1000 * 60 * 60);
  312. long minutes = millis / (1000 * 60);
  313. millis -= minutes * (1000 * 60);
  314. long seconds = millis / 1000;
  315. int currentLevel = Skills.getRealLevel(Skills.MINING);
  316. if(kittens){
  317. g.drawImage(img1, 3, 8, null);
  318. g.setColor(color1);
  319. g.fillRoundRect(403, 480, 114, 26, 16, 16);
  320. g.setColor(color2);
  321. g.setStroke(stroke1);
  322. g.drawRoundRect(403, 480, 114, 26, 16, 16);
  323. g.setFont(font1);
  324. g.drawString("Hide Paint", 419, 500);
  325. g.setFont(font2);
  326. g.setColor(color3);
  327. g.drawString(String.format("%02:%02d:%02d",hours, minutes, seconds ), 377, 387);
  328. g.drawString(""+oresMined, 376, 407);
  329. g.drawString(""+TTNL, 377, 423);
  330. g.drawString(""+currentLevel, 377, 440);
  331. g.drawString(status, 377, 459);
  332. }else if(!kittens){
  333. g.setColor(color1);
  334. g.fillRoundRect(403, 480, 114, 26, 16, 16);
  335. g.setColor(color2);
  336. g.setStroke(stroke1);
  337. g.drawRoundRect(403, 480, 114, 26, 16, 16);
  338. g.setFont(font1);
  339. g.drawString("Show Paint", 419, 500);
  340. }//run
  341.  
  342. }
  343.  
  344.  
  345. /*
  346. * Message received
  347. */
  348.  
  349. @Override
  350. public void messageReceived(MessageEvent e) {
  351. String x = e.getMessage().toLowerCase();
  352. if (x.contains("manage to mine")){
  353. oresMined++;
  354. }
  355. }
  356.  
  357.  
  358. Rectangle hideButton = new Rectangle(403, 480, 114, 26);
  359. boolean kittens = true;
  360. @Override
  361. public void mouseClicked(MouseEvent e) {
  362. if(hideButton.contains(e.getPoint())){
  363. if(kittens){
  364. kittens = false;
  365. }else if(!kittens){
  366. kittens = true;
  367. }
  368. }
  369.  
  370. }
  371.  
  372. @Override
  373. public void mouseEntered(MouseEvent arg0) {
  374. // TODO Auto-generated method stub
  375.  
  376. }
  377.  
  378. @Override
  379. public void mouseExited(MouseEvent arg0) { //i think your missing a bracket somewhere
  380. // TODO Auto-generated method stub
  381.  
  382. }
  383.  
  384. @Override
  385. public void mousePressed(MouseEvent e) {
  386. if(hideButton.contains(e.getPoint())){
  387. if(kittens){
  388. kittens = false;
  389. }else if(!kittens){
  390. kittens = true;
  391. }
  392. }
  393.  
  394. }
  395.  
  396. @Override
  397. public void mouseReleased(MouseEvent arg0) {
  398. // TODO Auto-generated method stub
  399.  
  400. }
  401.  
  402. /*
  403. * Gui shit
  404. */
  405. class rimminergui extends JFrame {
  406. public rimminergui() {
  407. initComponents();
  408. }
  409.  
  410. boolean drop = false;
  411. boolean m1d1 = false; //no idea what the says lol
  412. boolean bank = true;
  413. private void button1ActionPerformed(ActionEvent e) {
  414. String BankDrop = bankDrop.getSelectedItem().toString();
  415. if (BankDrop.equals("Drop")) {
  416. BD = 1;
  417. drop = true;
  418. }
  419. if (BankDrop.equals("M1D1")) { //you shouldve used booleans instead :P kinda like this
  420. BD = 2;
  421. m1d1 = true;
  422. }
  423. if (BankDrop.equals("Bank")) {
  424. BD = 3;
  425. bank = true;
  426. }
  427. dispose();
  428. }
  429.  
  430. private void initComponents() {
  431. // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
  432. // Generated using JFormDesigner Evaluation license - Ryan Johnson
  433. button1 = new JButton();
  434. //comboBox1 = new JComboBox();
  435. bankDrop = new JComboBox();
  436. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  437.  
  438. //======== this ========
  439. Container contentPane = getContentPane();
  440.  
  441. //---- button1 ----
  442. button1.setText("Start!");
  443. button1.addActionListener(new ActionListener() {
  444. @Override
  445. public void actionPerformed(ActionEvent e) {
  446. button1ActionPerformed(e);
  447. }
  448. });
  449.  
  450. //---- bankDrop ----
  451. bankDrop.setModel(new DefaultComboBoxModel(new String[] {
  452. "Drop",
  453. "M1D1",
  454. "Bank"
  455. }));
  456.  
  457. GroupLayout contentPaneLayout = new GroupLayout(contentPane);
  458. contentPane.setLayout(contentPaneLayout);
  459. contentPaneLayout.setHorizontalGroup(
  460. contentPaneLayout.createParallelGroup()
  461. .addGroup(contentPaneLayout.createSequentialGroup()
  462. .addGap(174, 174, 174)
  463. .addComponent(bankDrop, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  464. .addContainerGap(170, Short.MAX_VALUE))
  465. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  466. .addGap(85, 85, 85)
  467. .addComponent(button1, GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
  468. .addGap(80, 80, 80))
  469. );
  470. contentPaneLayout.setVerticalGroup(
  471. contentPaneLayout.createParallelGroup()
  472. .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
  473. .addContainerGap(112, Short.MAX_VALUE)
  474. .addComponent(bankDrop, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  475. .addGap(69, 69, 69)
  476. .addComponent(button1, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
  477. .addGap(23, 23, 23))
  478. );
  479. pack();
  480. setLocationRelativeTo(getOwner());
  481. }
  482. }
  483.  
  484. private JButton button1;
  485. private JComboBox bankDrop;
  486. private JLabel label1;
  487. private JLabel label2;
  488.  
  489.  
  490. }
Add Comment
Please, Sign In to add comment