megaalgos

MegaFiller 2.5

Apr 13th, 2012
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.86 KB | None | 0 0
  1. //Version 2.5
  2. /**
  3. * Added cool mouse.
  4. * Made the paint easier to read
  5. * Fixed a banking problem
  6. */
  7. //Version 2.4
  8. /**
  9. * Added automatic updater
  10. */
  11. //Version 2.3
  12. /**
  13. * Faster banking
  14. * More efficient antiban
  15. * More reliable paint
  16. */
  17. //Version 2.2
  18. /**
  19. * Fixed resting error, stopping the script
  20. */
  21. //Version 2.1
  22. /**
  23. * Fixed the null pointer exception error, stopping the script
  24. */
  25. //Version 2.0!!
  26. /**
  27. * Added GUI and antiban
  28. * Fixed error where it didnt walk back to fountain
  29. * Added more options and changed the name
  30. */
  31.  
  32. import java.awt.*;
  33. import java.awt.event.ActionEvent;
  34. import java.awt.event.ActionListener;
  35. import java.awt.event.KeyEvent;
  36. import java.awt.image.BufferedImage;
  37. import java.io.BufferedInputStream;
  38. import java.io.BufferedOutputStream;
  39. import java.io.BufferedReader;
  40. import java.io.File;
  41. import java.io.FileOutputStream;
  42. import java.io.IOException;
  43. import java.io.InputStreamReader;
  44. import java.net.MalformedURLException;
  45. import java.net.URL;
  46. import java.text.DecimalFormat;
  47.  
  48. import javax.imageio.ImageIO;
  49. import javax.swing.*;
  50.  
  51. import com.rarebot.script.Script;
  52. import com.rarebot.client.m;
  53. import com.rarebot.event.events.MessageEvent;
  54. import com.rarebot.event.listeners.*;
  55. import com.rarebot.script.ScriptManifest;
  56. import com.rarebot.script.methods.Game.Tab;
  57. import com.rarebot.script.wrappers.*;
  58.  
  59. // Script Info
  60. @ScriptManifest(authors = { "MegaAlgos" }, version = 2.5, keywords = ("Vial, Money Making, Filler"), description = "Fills vials at Grand Exchange", name = "MegaFiller")
  61. public class MegaFiller extends Script implements PaintListener,
  62. MessageListener {
  63.  
  64. // Script Info for paint and proggies...
  65. public double getVersion() {
  66. return (2.5);
  67. }
  68.  
  69. public String getName() {
  70. return ("MegaFiller");
  71. }
  72.  
  73. public String getAuthor() {
  74. return ("MegaAlgos");
  75. }
  76.  
  77. // Script Variables
  78. RSNPC banker;
  79. RSObject fountain;
  80. int gePrice = 0, moneyMade, profitHour, vials, counter, fullPrice,
  81. emptyPrice;
  82. int emptyObjectID, filledObjectID;
  83. String status, eName, fName;
  84. String[] list = { "Vials", "Jugs", "Buckets", "Bowls" };
  85. private static final String GE_URL = "http://services.runescape.com/m=itemdb_rs/g=runescape/viewitem.ws?obj=";
  86. long startTime, checkForFilling;
  87. double work = 0;
  88. boolean fillingVials = false, start = false, fOnScreen = false,
  89. startUP = false;
  90. int vP;
  91. int jP;
  92. int buP;
  93. int boP;
  94. Image arrow = null;
  95.  
  96. // What it does on the start of the script
  97. public boolean onStart() {
  98. mouse.setSpeed(7);
  99. startTime = System.currentTimeMillis();
  100. log("MegaFiller! Aimed to make you money,"
  101. + " filling one thing at a time... or 28 ;)");
  102. java.awt.EventQueue.invokeLater(new Runnable() {
  103. @Override
  104. public void run() {
  105. new MegaGUI().setVisible(true);
  106. }
  107. });
  108.  
  109. if (getOVersion() != getVersion()) {
  110. java.awt.EventQueue.invokeLater(new Runnable() {
  111. @Override
  112. public void run() {
  113. new VersionGUI().setVisible(true);
  114. }
  115. });
  116. }
  117.  
  118. while (!start) {
  119. sleep(1000);
  120. }
  121.  
  122. try {
  123. arrow = ImageIO.read(new URL("http://megascripts.comyr.com/Arrow.png").openStream());
  124. } catch (IOException e) {
  125. // TODO Auto-generated catch block
  126. e.printStackTrace();
  127. }
  128.  
  129.  
  130. fullPrice = getPrice(filledObjectID);
  131. emptyPrice = getPrice(emptyObjectID);
  132. log("Filled " + whereandwhat.getSelectedItem().toString() + " price: "
  133. + fullPrice);
  134. return true;
  135. }
  136.  
  137. // Sees the messages in game
  138. @Override
  139. public void messageReceived(MessageEvent arg0) {
  140. if (arg0.getMessage().contains("You fill")) {
  141. fillingVials = true;
  142. }
  143.  
  144. }
  145.  
  146. // Script's graphics
  147. public void onRepaint(Graphics g) {
  148. long runTime = System.currentTimeMillis() - startTime;
  149. long TotalSecs = runTime / 1000;
  150. long TotalMins = TotalSecs / 60;
  151. long TotalHours = TotalMins / 60;
  152. int seconds = (int) TotalSecs % 60;
  153. int minutes = (int) TotalMins % 60;
  154. int hours = (int) TotalHours % 60;
  155.  
  156. StringBuilder b = new StringBuilder();
  157.  
  158. if (hours < 10)
  159. b.append('0');
  160. b.append(hours);
  161. b.append(':');
  162. if (minutes < 10)
  163. b.append('0');
  164. b.append(minutes);
  165. b.append(':');
  166. if (seconds < 10)
  167. b.append('0');
  168. b.append(seconds);
  169.  
  170. if (start) {
  171. work = vials / (minutes + hours * 60 + seconds / 60f) * 60f;
  172.  
  173. moneyMade = (vials * fullPrice) + (vials * emptyPrice);
  174.  
  175. profitHour = (int) (moneyMade
  176. / (minutes + hours * 60 + seconds / 60f) * 60f);
  177.  
  178. if (minutes == 30 && seconds == 1 || minutes == 0 && seconds == 30
  179. && game.isLoggedIn()) {
  180. String fS = File.separator;
  181. String path = null;
  182. File directory;
  183. try {
  184. path = new File(".").getCanonicalPath();
  185. } catch (IOException e) {
  186. // TODO Auto-generated catch block
  187. e.printStackTrace();
  188. }
  189. directory = new File(path + fS + getName() + " " + getVersion());
  190. if (!directory.exists()) {
  191. directory.mkdirs();
  192. log("Made the directory for proggies");
  193. }
  194. BufferedImage img = new BufferedImage(155, 140,
  195. BufferedImage.TYPE_INT_RGB);
  196. File file = new File(directory + fS + "MegaVial " + counter
  197. + ".gif");
  198. g = img.getGraphics();
  199. g.setColor(new Color(76, 67, 69));
  200. g.fill3DRect(0, 0, 155, 140, true);
  201.  
  202. int w = 0;
  203. int z = 0;
  204. g.setColor(new Color(80, 207, 58));
  205. g.drawString(getName() + " " + getVersion(), w, z += 20);
  206. g.drawString("Ran for: " + b.toString(), w, z += 25);
  207. g.drawString("Filled: " + vials + " " + eName + "s", w, z += 20);
  208. g.drawString("Filling: " + roundToTenth(work) + " per hour.",
  209. w, z += 20);
  210. g.drawString("Made: " + addCommas(moneyMade, true) + " profit", w, z += 20);
  211. g.drawString("Making: " + addCommas(profitHour, true) + " an hour", w, z += 20);
  212. try {
  213. ImageIO.write(img, "gif", file);
  214. } catch (IOException e) {
  215. // TODO Auto-generated catch block
  216. e.printStackTrace();
  217. }
  218. log("Sent a proggy image to the MegaVial folder in program files folder...");
  219. counter++;
  220. sleep(2000);
  221. }
  222. }
  223.  
  224. if (game.isLoggedIn()) {
  225. if (arrow != null) {
  226. g.drawImage(arrow, mouse.getLocation().x - 9, mouse.getLocation().y - 2, null);
  227. }
  228. g.setColor(new Color(76, 67, 69, 185));
  229. g.fill3DRect(360, 180, 158, 165, true);
  230. int x = 365;
  231. int y = 185;
  232. g.setColor(new Color(80, 207, 58));
  233. g.drawString(getName() + " " + getVersion(), x, y += 20);
  234. g.drawString("Ran for: " + b.toString(), x, y += 25);
  235. g.drawString("Filled: " + vials + " vials", x, y += 20);
  236. g.drawString("Filling: " + roundToTenth(work) + " per hour.", x,
  237. y += 20);
  238. g.drawString("Made: " + addCommas(moneyMade, true) + " proffit", x, y += 20);
  239. g.drawString("Making: " + addCommas(profitHour, true) + " an hour", x, y += 20);
  240. g.drawString("Status: " + status, x, y += 20);
  241. }
  242. }
  243.  
  244. // Main method to run.. the methods.
  245. @Override
  246. public int loop() {
  247. // Checks if we are logged in!
  248. if (!game.isLoggedIn()) {
  249. return 1000;
  250. }
  251. // Moves camera up if down
  252. if (camera.getPitch() < 50) {
  253. camera.setPitch(true);
  254. }
  255. if (getMyPlayer().getAnimation() == 5713
  256. || getMyPlayer().getAnimation() == 11786
  257. && walking.getEnergy() == 100) {
  258. mouse.move(calc.tileToScreen(getMyPlayer().getLocation()));
  259. mouse.click(true);
  260. }
  261. // Checks if energy is low
  262. if (walking.getEnergy() < 10 && getMyPlayer().isIdle()) {
  263. walking.rest();
  264. }
  265. // Checks if the run is off and the energy is above 75
  266. if (!walking.isRunEnabled() && walking.getEnergy() > 75) {
  267. // If run is off we should turn it on
  268. walking.setRun(true);
  269. }
  270.  
  271. // Make the fillingVials boolean false
  272. if (inventory.getItems(filledObjectID).length == 28) {
  273. fillingVials = false;
  274. }
  275.  
  276. // Checks if player is filling vials
  277. if (getMyPlayer().getAnimation() == 823 || fillingVials) {
  278. if (Filling()) {
  279. fillingVials = false;
  280. return 0;
  281. }
  282. while (inventory.getCount(filledObjectID) < 20) {
  283. antiBan();
  284. if (Filling()) {
  285. fillingVials = false;
  286. return 0;
  287. }
  288. }
  289. return 1;
  290. }
  291. // Checks if inventory is full
  292. if (inventory.isFull()) {
  293. switch (stateFull()) {
  294. case 1:
  295. // Checks if we are walking
  296. if (getMyPlayer().isMoving()) {
  297. return random(100, 300);
  298. }
  299. walkToFountain();
  300. return 223;
  301. case 2:
  302. fillVials();
  303. return 243;
  304. case 3:
  305. // Checks if we are walking
  306. if (getMyPlayer().isMoving()) {
  307. return random(100, 300);
  308. }
  309. walkToBank();
  310. return 233;
  311. case 4:
  312. depositVials();
  313. return 253;
  314. case 0:
  315. return 1;
  316. }
  317. } else { // IF NOT FULL
  318. RSTile bankerTile = new RSTile(3181, 3480);
  319. // banker = npcs.getNearest("Banker"); // bank
  320. if (calc.distanceTo(bankerTile) < 3) { // If close to bank
  321. if (bank.open()) {
  322. if (bank.withdraw(eName, 0)) {
  323. while (!inventory.isFull()) {
  324. sleep(100);
  325. }
  326. return random(33, 100);
  327. }
  328. } else {
  329. if (clickTile(bankerTile, "Bank Banker")) {
  330. sleep(random(33, 210));
  331. }
  332. }
  333. // if (banker.interact("Bank Banker")) {
  334. // return random(33, 210);
  335. // }
  336. return 50;
  337. }
  338. if (getMyPlayer().isMoving()) {
  339. return 50;
  340. } else {
  341. if (walkToBank()) {
  342. // Walking back to bank!
  343. return 500;
  344. } else {
  345. // Something is wrong.
  346. return 100;
  347. }
  348. }
  349. }
  350. return random(300, 500);
  351. }
  352.  
  353. // Other Methods!
  354.  
  355. // The state we are in when inventory is full.
  356. public int stateFull() {
  357. fountain = objects.getNearest("Fountain");
  358. RSTile f = new RSTile(3165, 3490);
  359. if (calc.tileOnScreen(f)) {
  360. fOnScreen = true;
  361. } else {
  362. fOnScreen = false;
  363. }
  364.  
  365. if (inventory.containsAll(emptyObjectID) && !fOnScreen) {
  366. status = "Walking to fountain";
  367. return 1;
  368. }
  369. if (inventory.containsAll(emptyObjectID) && fOnScreen) {
  370. status = "Filling " + eName;
  371. return 2;
  372. }
  373. // banker = npcs.getNearest(2718);
  374. // if(banker == null) {
  375. // walkToBank();
  376. // return 0;
  377. // }
  378. RSTile bankerTile = new RSTile(3181, 3480);
  379. if (inventory.containsAll(filledObjectID)
  380. && !calc.tileOnScreen(bankerTile)) {
  381. status = "Walking to bank";
  382. return 3;
  383. }
  384. if (inventory.containsAll(filledObjectID)
  385. && calc.tileOnScreen(bankerTile)) {
  386. status = "Depositing";
  387. return 4;
  388. }
  389.  
  390. return 0;
  391. }
  392.  
  393. // Walks to bank
  394. public boolean walkToBank() {
  395. RSTile bankTile = new RSTile(3179, 3481);
  396. mouse.click(calc.tileToMinimap(bankTile), 5, 5, true);
  397. sleep(1000);
  398. return true;
  399. }
  400.  
  401. // Walks to fountain
  402. public boolean walkToFountain() {
  403. RSTile fTile = new RSTile(3167, 3488);
  404. if (calc.tileOnMap(fTile)) {
  405. mouse.click(calc.tileToMinimap(fTile), 5, 5, true);
  406. } else {
  407. mouse.click(calc.tileToMinimap(walking.getClosestTileOnMap(fTile)),
  408. true);
  409. }
  410. sleep(1000);
  411. return true;
  412. }
  413.  
  414. // Fills vials
  415. public boolean fillVials() {
  416. fountain = objects.getNearest("Fountain"); // ID 47150
  417. if (inventory.selectItem(emptyObjectID)) {
  418. if (fountain.isOnScreen()) {
  419. fountain.doClick();
  420. sleep(2500);
  421. return true;
  422. }
  423. return true;
  424. }
  425. return false;
  426. }
  427.  
  428. public boolean Filling() {
  429. int iCount = inventory.getCount(filledObjectID);
  430. sleep(2000);
  431. if (inventory.getCount(filledObjectID) == iCount) {
  432. return true;
  433. }
  434. return false;
  435. }
  436.  
  437. // Deposits vials
  438. public boolean depositVials() {
  439. // banker = npcs.getNearest("Banker"); // bank
  440. // if (banker.interact("Bank Banker")) {
  441. // sleep(random(350, 500));
  442. // }
  443. int c = 0;
  444. RSTile bankerTile = new RSTile(3181, 3480);
  445. if (clickTile(bankerTile, "Bank Banker")) {
  446. while (!bank.isOpen()) {
  447. sleep(500);
  448. c++;
  449. if (c > 3) {
  450. c = 0;
  451. break;
  452. }
  453. }
  454. }
  455. if (bank.isOpen()) {
  456. bank.depositAll();
  457. vials = vials + 28;
  458. while (inventory.isFull()) {
  459. sleep(250);
  460. c++;
  461. if (c > 4) {
  462. c = 0;
  463. break;
  464. }
  465. }
  466. } else {
  467. return false;
  468. }
  469. return true;
  470. }
  471.  
  472. public boolean clickTile(RSTile c, String action) {
  473. try {
  474. while (getMyPlayer().isMoving()) {
  475. sleep(750);
  476. }
  477. Point screenLoc = calc.tileToScreen(c);
  478. mouse.move(screenLoc);
  479. if (!mouse.getLocation().equals(screenLoc))
  480. return false;
  481.  
  482. mouse.click(screenLoc, false);
  483. return menu.doAction(action);
  484.  
  485. } catch (NullPointerException e) {
  486. }
  487. return true;
  488. }
  489.  
  490. // Clicks tile accurately
  491. public boolean clickTile2(RSTile c, String action) {
  492. try {
  493. Point screenLoc = null;
  494. screenLoc = calc.tileToScreen(c);
  495. if (c == null || !calc.pointOnScreen(screenLoc)) {
  496. System.out.println("Not on screen " + action);
  497. return false;
  498. }
  499.  
  500. mouse.move(screenLoc);
  501. screenLoc = calc.tileToScreen(c);
  502.  
  503. String[] items = menu.getItems();
  504. if (items.length <= 1)
  505. return false;
  506. if (items[0].toLowerCase().contains(action.toLowerCase())) {
  507. mouse.click(screenLoc, true);
  508. return true;
  509. } else {
  510. mouse.click(screenLoc, false);
  511. return menu.doAction(action);
  512. }
  513.  
  514. } catch (NullPointerException e) {
  515. }
  516. return true;
  517. }
  518.  
  519. // Rounds a double to the nearest tenth
  520. public double roundToTenth(double d) {
  521. DecimalFormat twoDForm = new DecimalFormat("#.#");
  522. twoDForm = new DecimalFormat("#.#");
  523. return Double.valueOf(twoDForm.format(d));
  524. }
  525.  
  526. // Adds commas to the number returns a string
  527. public String addCommas(int d, boolean money) {
  528. DecimalFormat twoDForm = new DecimalFormat("###,###");
  529. if(money) {
  530. twoDForm = new DecimalFormat("$###,###");
  531. return twoDForm.format(d);
  532. }
  533. return twoDForm.format(d);
  534. }
  535.  
  536. // Checks for the recent version
  537. public double getOVersion() {
  538. try {
  539. URL url = new URL("http://megascripts.comyr.com/MegaFIller");
  540. BufferedReader br = new BufferedReader(new InputStreamReader(
  541. new BufferedInputStream(url.openConnection()
  542. .getInputStream())));
  543. double ver = Double.parseDouble(br.readLine().trim());
  544. br.close();
  545. return ver;
  546. } catch (IOException e) {
  547. throw new RuntimeException(e);
  548. }
  549. }
  550.  
  551. // ANTI-BAN STUFF
  552. public int antiBan() {
  553. Point m;
  554. int x = random(0, 750);
  555. int y = random(0, 500);
  556. int xx = random(710, 554);
  557. int yy = random(444, 230);
  558. int screenx = random(1, 510);
  559. int screeny = random(1, 450);
  560.  
  561. int gamble = random(0, 22);
  562.  
  563. final long start = System.currentTimeMillis();
  564. final RSPlayer myPlayer = getMyPlayer();
  565.  
  566. int anim = -1;
  567. while (System.currentTimeMillis() - start > 2000) {
  568. if ((anim = myPlayer.getAnimation()) != -1) {
  569. break;
  570. }
  571. sleep(15);
  572. }
  573.  
  574. switch (gamble) {
  575. case 1:
  576.  
  577. sleep(random(1000, 2500));
  578.  
  579. break;
  580. case 2:
  581. mouse.move(x, y);
  582.  
  583. while (System.currentTimeMillis() - start > 2000) {
  584.  
  585. if ((anim = myPlayer.getAnimation()) != -1) {
  586. break;
  587. }
  588. sleep(random(15, 55));
  589. }
  590.  
  591. sleep(random(1000, 2500));
  592. break;
  593. case 3:
  594. game.openTab(Tab.INVENTORY);
  595. sleep(random(1000, 2500));
  596. break;
  597. case 4:
  598. if (getMyPlayer().isMoving()) {
  599. sleep(random(1000, 2500));
  600. break;
  601. }
  602. case 5:
  603. mouse.move(x, y);
  604. int checkTime = 0;
  605. long lastCheck = 0;
  606. sleep(random(1000, 2500));
  607. if (System.currentTimeMillis() - lastCheck >= checkTime) {
  608. lastCheck = System.currentTimeMillis();
  609. checkTime = random(60000, 180000);
  610. break;
  611. }
  612. case 6:
  613. if (game.getTab() != Tab.STATS) {
  614. game.openTab(Tab.STATS);
  615. mouse.move(xx, yy);
  616. sleep(random(2000, 3500));
  617. game.openTab(Tab.INVENTORY);
  618. break;
  619. }
  620. case 7:
  621. sleep(random(750, 1500));
  622. break;
  623. case 8:
  624. mouse.move(screenx, screeny);
  625. sleep(random(750, 1500));
  626. break;
  627. case 9:
  628. mouse.move(screenx, screeny);
  629. sleep(random(750, 1500));
  630. break;
  631. case 10:
  632. game.openTab(game.getRandomTab());
  633. sleep(random(750, 1500));
  634. break;
  635.  
  636. case 11:
  637. mouse.move(x, y);
  638. sleep(random(750, 1500));
  639. break;
  640. case 13:
  641. mouse.move(x, y);
  642. sleep(random(750, 1500));
  643. break;
  644. case 12:
  645. mouse.move(x, y);
  646. sleep(random(750, 1500));
  647. break;
  648. case 14:
  649. m = mouse.getLocation();
  650. sleep(random(300, 500));
  651. mouse.move(m, 20, 20);
  652. sleep(random(100, 200));
  653. break;
  654. case 15:
  655. m = mouse.getLocation();
  656. sleep(random(300, 500));
  657. mouse.move(m, 20, 20);
  658. sleep(random(100, 200));
  659. break;
  660. case 16:
  661. m = mouse.getLocation();
  662. sleep(random(300, 500));
  663. mouse.move(m, 20, 20);
  664. sleep(random(100, 200));
  665. break;
  666. case 17:
  667. m = mouse.getLocation();
  668. sleep(random(300, 500));
  669. mouse.move(m, 20, 20);
  670. sleep(random(100, 200));
  671. break;
  672. case 19:
  673. mouse.move(x, y);
  674. sleep(random(750, 1500));
  675. break;
  676. case 20:
  677. mouse.move(x, y);
  678. sleep(random(750, 1500));
  679. break;
  680. case 21:
  681. mouse.move(x, y);
  682. sleep(random(750, 1500));
  683. break;
  684.  
  685. }
  686.  
  687. return 100;
  688. }
  689.  
  690. // Grand exchange price lookup
  691. private int getPrice(int itemID) {
  692. try {
  693. URL url = new URL(GE_URL + String.valueOf(itemID));
  694. BufferedReader x = new BufferedReader(new InputStreamReader(
  695. url.openStream()));
  696. String inputLine;
  697. while ((inputLine = x.readLine()) != null) {
  698. if (inputLine
  699. .contains("<th scope=\"row\">Current guide price:</th>")) {
  700. return (int) parsePrice(x.readLine());
  701. }
  702. }
  703. x.close();
  704. } catch (MalformedURLException e) {
  705. e.printStackTrace();
  706. } catch (IOException e) {
  707. e.printStackTrace();
  708. }
  709. return -1;
  710. }
  711.  
  712. private double parsePrice(String str) {
  713. if (str != null && !str.isEmpty()) {
  714. str = stripFormatting(str);
  715. str = str.substring(str.indexOf(58) + 1, str.length());
  716. str = str.replace(",", "");
  717. str = str.trim();
  718. if (!str.endsWith("%")) {
  719. if (!str.endsWith("k") && !str.endsWith("m")
  720. && !str.endsWith("b")) {
  721. return Double.parseDouble(str);
  722. }
  723. return Double.parseDouble(str.substring(0, str.length() - 1))
  724. * (str.endsWith("b") ? 1000000000
  725. : str.endsWith("m") ? 1000000 : 1000);
  726. }
  727. final int k = str.startsWith("+") ? 1 : -1;
  728. str = str.substring(0);
  729. return Double.parseDouble(str.substring(0, str.length() - 1)) * k;
  730. }
  731. return -1D;
  732. }
  733.  
  734. private String stripFormatting(final String str) {
  735. if (str != null && !str.isEmpty()) {
  736. return str.replaceAll("(^[^<]+>|<[^>]+>|<[^>]+$)", "");
  737. }
  738. return "";
  739. }
  740.  
  741. // End Grand exchange price lookup
  742.  
  743. JButton startButton;
  744. JButton mPButton;
  745. JComboBox whereandwhat;
  746. JLabel text;
  747. JLabel profit;
  748. JPanel jp1;
  749.  
  750. public class MegaGUI extends JFrame implements ActionListener {
  751.  
  752. public MegaGUI() {
  753. setTitle("MegaFiller");
  754.  
  755. startButton = new JButton("Start");
  756. mPButton = new JButton("CHECK");
  757. text = new JLabel("What to fill?");
  758. profit = new JLabel("Most profitable right now: ");
  759. whereandwhat = new JComboBox(list);
  760.  
  761. setLayout(null);
  762. setResizable(false);
  763. setSize(390, 255);
  764. setLocationRelativeTo(null);
  765.  
  766. mPButton.setBounds(245, 20, 83, 28);
  767. mPButton.addActionListener(this);
  768. text.setBounds(20, 20, 182, 21);
  769. profit.setBounds(100, 20, 182, 21);
  770. startButton.setBounds(135, 148, 83, 28);
  771. startButton.addActionListener(this);
  772. whereandwhat.setBounds(65, 71, 200, 22);
  773.  
  774. add(text);
  775. add(profit);
  776. add(whereandwhat);
  777. add(startButton);
  778. add(mPButton);
  779.  
  780. setVisible(true);
  781. }
  782.  
  783. public String mostProfit() {
  784. int vP = getPrice(227) - getPrice(229);
  785. int jP = getPrice(1937 - getPrice(1935));
  786. int buP = getPrice(1929) - getPrice(1925);
  787. int boP = getPrice(1921) - getPrice(1923);
  788.  
  789. if (vP > jP && vP > buP && vP > boP) {
  790. return "Vials";
  791. }
  792.  
  793. if (jP > vP && jP > buP && jP > boP) {
  794. return "Jugs";
  795. }
  796.  
  797. if (buP > vP && buP > jP && buP > boP) {
  798. return "Buckets";
  799. }
  800.  
  801. if (boP > vP && boP > buP && boP > jP) {
  802. return "Bowls";
  803. }
  804.  
  805. return "IDK";
  806. }
  807.  
  808. @Override
  809. public void actionPerformed(ActionEvent e) {
  810. if (e.getActionCommand().contains("Start")) {
  811. if (whereandwhat.getSelectedItem().toString().equals("Vials")) {
  812. filledObjectID = 227;
  813. emptyObjectID = 229;
  814. eName = "Vial";
  815. fName = "Vial of Water";
  816. log("Filling Vials");
  817. } else if (whereandwhat.getSelectedItem().toString()
  818. .equals("Jugs")) {
  819. filledObjectID = 1937;
  820. emptyObjectID = 1935;
  821. eName = "Jug";
  822. fName = "Jug of Water";
  823. log("Filling jugs");
  824. } else if (whereandwhat.getSelectedItem().toString()
  825. .equals("Buckets")) {
  826. filledObjectID = 1929;
  827. emptyObjectID = 1925;
  828. eName = "Bucket";
  829. fName = "Bucket of Water";
  830. log("Filling Buckets");
  831. } else if (whereandwhat.getSelectedItem().toString()
  832. .equals("Bowls")) {
  833. filledObjectID = 1921;
  834. emptyObjectID = 1923;
  835. eName = "Bowl";
  836. fName = "Bowl of Water";
  837. log("Filling Bowls");
  838. }
  839. dispose();
  840. setVisible(false);
  841. start = true;
  842. }
  843. if (e.getActionCommand().contains("CHECK")) {
  844. log("Loading prices and finding profits, "
  845. + "make take a minute");
  846. profit.setText("Most profitable right now: " + mostProfit());
  847. remove(mPButton);
  848. repaint();
  849. }
  850. }
  851.  
  852. }
  853.  
  854. JButton oB;
  855. JButton gN;
  856. JLabel oL;
  857.  
  858. public class VersionGUI extends JFrame implements ActionListener {
  859.  
  860. public VersionGUI() {
  861. setTitle("OUTDATED");
  862.  
  863. oB = new JButton("Okay");
  864. oL = new JLabel("OUTDATED");
  865. gN = new JButton("Get new version");
  866.  
  867. setLayout(null);
  868. setResizable(false);
  869. setSize(150, 185);
  870. setLocationRelativeTo(null);
  871.  
  872. oB.setBounds(20, 35, 65, 25);
  873. gN.setBounds(20, 85, 115, 25);
  874. oB.addActionListener(this);
  875. gN.addActionListener(this);
  876. oL.setBounds(20, 5, 182, 21);
  877.  
  878. add(oL);
  879. add(gN);
  880. add(oB);
  881.  
  882. setVisible(true);
  883. }
  884.  
  885. public void getNewVersion() {
  886. File directory = getCacheDirectory();
  887. File newDirectory =
  888. new File(new File(new File(directory.getParent()).getParent()).getParent()
  889. + File.separator + "Scripts" + File.separator +
  890. "Sources" + File.separator + "MegaFiller.java");
  891.  
  892. BufferedInputStream in;
  893. try {
  894. in = new BufferedInputStream(
  895. new URL("http://megascripts.comyr.com/MegaFiller.java").openStream());
  896. FileOutputStream fos = new FileOutputStream(newDirectory);
  897. BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
  898. byte[] data = new byte[1024];
  899. int x=0;
  900. while((x=in.read(data,0,1024))>=0) {
  901. bout.write(data,0,x);
  902. }
  903. bout.close();
  904. in.close();
  905. } catch (MalformedURLException e) {
  906. // TODO Auto-generated catch block
  907. e.printStackTrace();
  908. } catch (IOException e) {
  909. // TODO Auto-generated catch block
  910. e.printStackTrace();
  911. }
  912. }
  913.  
  914. @Override
  915. public void actionPerformed(ActionEvent e) {
  916. if (e.getActionCommand().contains("Okay")) {
  917. dispose();
  918. setVisible(false);
  919. }
  920. if (e.getActionCommand().contains("Get new version")) {
  921. getNewVersion();
  922. sleep(1000);
  923. oL.setText("Recompile the script");
  924. repaint();
  925. stopScript();
  926. }
  927. }
  928. }
  929. }
Advertisement
Add Comment
Please, Sign In to add comment