megaalgos

MegaFiller 2.3

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