Guest User

>C< House Planks v0.1

a guest
Jul 26th, 2018
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.85 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Dimension;
  3. import java.awt.EventQueue;
  4. import java.awt.Font;
  5. import java.awt.Graphics2D;
  6. import java.awt.Toolkit;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.io.BufferedReader;
  10. import java.io.InputStreamReader;
  11. import java.net.URL;
  12. import java.net.URLConnection;
  13.  
  14. import javax.swing.DefaultComboBoxModel;
  15. import javax.swing.JButton;
  16. import javax.swing.JCheckBox;
  17. import javax.swing.JComboBox;
  18. import javax.swing.JFrame;
  19. import javax.swing.JLabel;
  20. import javax.swing.JSeparator;
  21. import javax.swing.JTextField;
  22.  
  23. import org.osbot.rs07.api.Bank;
  24. import org.osbot.rs07.api.Dialogues;
  25. import org.osbot.rs07.api.GrandExchange;
  26. import org.osbot.rs07.api.GrandExchange.Box;
  27. import org.osbot.rs07.api.GrandExchange.Status;
  28. import org.osbot.rs07.api.map.Area;
  29. import org.osbot.rs07.api.model.Entity;
  30. import org.osbot.rs07.api.ui.RS2Widget;
  31. import org.osbot.rs07.api.ui.Tab;
  32. import org.osbot.rs07.canvas.paint.Painter;
  33. import org.osbot.rs07.script.Script;
  34. import org.osbot.rs07.script.ScriptManifest;
  35. import org.osbot.rs07.utility.ConditionalSleep;
  36.  
  37. @ScriptManifest(author = "Castro_", info = "Creates planks in your PoH.", logo = "", name = ">C< House Planks", version = 0)
  38. public class Main extends Script implements Painter{
  39.  
  40.     private long startTime;
  41.  
  42.     public String status = "";
  43.  
  44.     public boolean gui_COMPLETE = false;
  45.  
  46.     public long log_counter = 26;
  47.     public boolean in_house = false;
  48.  
  49.     public String planks_to_make = "";
  50.     public int plank_id = 0;
  51.     public int log_id = 0;
  52.    
  53.     public int planks_made = 0;
  54.  
  55.     // ge
  56.  
  57.     public boolean should_restock = false;
  58.  
  59.     public boolean should_Ge = false;
  60.  
  61.     public int buy_logs_price = 0;
  62.     public int buy_logs_amount = 0;
  63.  
  64.     public int sell_planks_price = 0;
  65.  
  66.     Area GRAND_EXCHANGE_AREA = new Area(3161, 3485, 3169, 3492);
  67.     Area LUMBRIDGE_PVP_BANK_AREA = new Area(3220, 3214, 3225, 3222);
  68.     Area VARROCK_TELEPORT_AREA = new Area(3207, 3420, 3219, 3428);
  69.  
  70.     private static int getPrice(final int id) {
  71.         try {
  72.             URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id);
  73.             URLConnection con = url.openConnection();
  74.             con.setUseCaches(true);
  75.             BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
  76.             String[] data = br.readLine().replace("{", "").replace("}", "").split(",");
  77.             return Integer.parseInt(data[0].split(":")[1]);
  78.         } catch (Exception e) {
  79.  
  80.         }
  81.         return -1;
  82.     }
  83.    
  84.     public final String formatTime(final long ms) {
  85.         long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
  86.         s %= 60;
  87.         m %= 60;
  88.         h %= 24;
  89.  
  90.         return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
  91.                 : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s);
  92.     }
  93.  
  94.     public void onStart() {
  95.  
  96.         status = "Waiting for GUI";
  97.         log(status);
  98.  
  99.         GUI gui = new GUI();
  100.  
  101.         Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  102.         int screenW = screensize.width / 2;
  103.         int screenH = screensize.height / 2;
  104.  
  105.         gui.frmc.setVisible(true);
  106.         gui.frmc.setLocation(screenW / 2, screenH / 2);
  107.  
  108.         while (!this.gui_COMPLETE) {
  109.             try {
  110.                 sleep(300L);
  111.             } catch (InterruptedException e) {
  112.                 e.printStackTrace();
  113.             }
  114.         }
  115.         gui.frmc.setVisible(false);
  116.  
  117.         status = "GUI completed";
  118.         log(status);
  119.        
  120.         startTime = System.currentTimeMillis();
  121.        
  122.     }
  123.  
  124.     @Override
  125.     public int onLoop() throws InterruptedException {
  126.  
  127.         if (getInventory().getAmount("Coins") > 50000 && getInventory().getAmount("Teleport to house") > 1
  128.                 && getInventory().getAmount("Teleport to Lumbridge") > 1) {
  129.  
  130.             if (LUMBRIDGE_PVP_BANK_AREA.contains(myPlayer().getPosition()) && !getInventory().isFull()
  131.                     && log_counter >= 25) {
  132.  
  133.                 status = "Withdrawing "+planks_to_make+" logs";
  134.                
  135.                 withdraw_logs();
  136.  
  137.             } else {
  138.  
  139.                 if (getInventory().contains(planks_to_make + " logs") && in_house == false) {
  140.  
  141.                     status = "Teleporting to House";
  142.                    
  143.                     teleport_to_house();
  144.  
  145.                 } else {
  146.  
  147.                     if (in_house == true && getInventory().contains(planks_to_make + " logs")) {
  148.  
  149.                         status = "Creating planks";
  150.                        
  151.                         create_planks();
  152.  
  153.                     } else {
  154.  
  155.                         if (getWorlds().getCurrentWorld() == 325 && should_Ge == true) {
  156.  
  157.                             status = "Hopping to non-PvP world";
  158.                            
  159.                             hop_to_non_pvp();
  160.  
  161.                         } else {
  162.  
  163.                             if (should_Ge == true && should_restock == true) {
  164.  
  165.                                 if (should_Ge == true && LUMBRIDGE_PVP_BANK_AREA.contains(myPlayer().getPosition())
  166.                                         && getWorlds().getCurrentWorld() != 325) {
  167.  
  168.                                     status = "Teleporting to Varrock";
  169.                                    
  170.                                     teleport_to_varrock();
  171.  
  172.                                 } else {
  173.  
  174.                                     if (VARROCK_TELEPORT_AREA.contains(myPlayer().getPosition())) {
  175.  
  176.                                         status = "Walking to Grand Exchange";
  177.                                        
  178.                                         to_grand_exchange();
  179.  
  180.                                     } else {
  181.  
  182.                                         if (GRAND_EXCHANGE_AREA.contains(myPlayer().getPosition())
  183.                                                 && getInventory().contains(planks_to_make + " plank")
  184.                                                 && should_Ge == true) {
  185.  
  186.                                             status = "Selling "+planks_to_make+" planks";
  187.                                            
  188.                                             sell_planks();
  189.  
  190.                                         } else {
  191.  
  192.                                             if (GRAND_EXCHANGE_AREA.contains(myPlayer().getPosition())
  193.                                                     && !getInventory().contains(planks_to_make + " plank")
  194.                                                     && should_Ge == true) {
  195.  
  196.                                                 status = "Buying "+buy_logs_amount+" "+planks_to_make +" logs";
  197.                                                
  198.                                                 buy_logs();
  199.  
  200.                                             } else {
  201.  
  202.                                                 if (getWorlds().getCurrentWorld() != 325 && should_Ge == false) {
  203.  
  204.                                                     status = "Hopping to PvP world";
  205.                                                     hop_to_pvp();
  206.  
  207.                                                 } else {
  208.  
  209.                                                     if (GRAND_EXCHANGE_AREA.contains(myPlayer().getPosition())
  210.                                                             && !getInventory().isFull() && log_counter >= 25) {
  211.  
  212.                                                         status = "Withdrawing "+planks_to_make+" logs";
  213.                                                        
  214.                                                         withdraw_logs_grand_exchange();
  215.  
  216.                                                     } else {
  217.  
  218.                                                         if (in_house == true
  219.                                                                 && !getInventory().contains(planks_to_make + " logs")) {
  220.  
  221.                                                             status = "Teleporting to Lumbridge";
  222.                                                            
  223.                                                             teleport_to_lumbrdge();
  224.  
  225.                                                         }
  226.  
  227.                                                     }
  228.  
  229.                                                 }
  230.                                             }
  231.                                         }
  232.  
  233.                                     }
  234.  
  235.                                 }
  236.                                
  237.                             } else {
  238.  
  239.                                 if (should_Ge == true && should_restock == false) {
  240.  
  241.                                     status = "Out of "+planks_to_make+" logs; stopping script.";
  242.                                    
  243.                                     log("Out of logs; restock mode off.");
  244.                                     stop();
  245.                                 }
  246.                             }
  247.                         }
  248.                     }
  249.                 }
  250.             }
  251.         }else {
  252.            
  253.             if (getInventory().getAmount("Coins") < 50000 || getInventory().getAmount("Teleport to house") < 1
  254.                     || getInventory().getAmount("Teleport to Lumbridge") < 1) {
  255.  
  256.                 status = "Out of supplies; stopping script.";
  257.  
  258.                 log("Out of supplies; stopping script.");
  259.                 stop();
  260.                
  261.             }
  262.         }
  263.  
  264.         return random(20, 40);
  265.     }
  266.  
  267.     public void teleport_to_lumbrdge() {
  268.  
  269.         getInventory().interact("Break", "Lumbridge teleport");
  270.  
  271.         in_house = false;
  272.  
  273.         planks_made = planks_made+25;
  274.        
  275.         new ConditionalSleep(random(5000, 7000)) {
  276.             @Override
  277.             public boolean condition() {
  278.                 return LUMBRIDGE_PVP_BANK_AREA.contains(myPlayer().getPosition());
  279.             }
  280.  
  281.         }.sleep();
  282.  
  283.     }
  284.  
  285.     public void create_planks() {
  286.  
  287.         getTabs().open(Tab.SETTINGS);
  288.  
  289.         if (getTabs().getOpen().equals(Tab.SETTINGS)) {
  290.  
  291.             RS2Widget house_options = getWidgets().get(261, 81);
  292.             RS2Widget call_servant = getWidgets().get(370, 19, 0);
  293.  
  294.             if (house_options != null) {
  295.  
  296.                 house_options.interact("View House Options");
  297.  
  298.                 new ConditionalSleep(random(5000, 7000)) {
  299.                     @Override
  300.                     public boolean condition() {
  301.                         return call_servant != null;
  302.                     }
  303.  
  304.                 }.sleep();
  305.  
  306.                 if (call_servant != null) {
  307.  
  308.                     Entity demon_butler = getNpcs().closest("Demon butler");
  309.                     call_servant.interact("Call Servant");
  310.                     new ConditionalSleep(random(10000, 12000)) {
  311.                         @Override
  312.                         public boolean condition() {
  313.                             return getDialogues().inDialogue() == true;
  314.                         }
  315.  
  316.                     }.sleep();
  317.  
  318.                     if (getDialogues().inDialogue() == false) {
  319.  
  320.                         getWalking().walk(demon_butler);
  321.                         demon_butler.interact("Talk-to");
  322.  
  323.                     } else {
  324.  
  325.                         if (getDialogues().toString().contains(
  326.                                 "Master, if thou desirest my continued service thou must render unto me the 10,000 coins that are due to me!")) {
  327.  
  328.                             try {
  329.                                 getDialogues().completeDialogue("Click here to continue", "Okay, here's 10,000 coins.",
  330.                                         "Click here to continue");
  331.                             } catch (InterruptedException e) {
  332.                                 e.printStackTrace();
  333.                             }
  334.  
  335.                         } else {
  336.  
  337.                             try {
  338.  
  339.                                 getDialogues().completeDialogue("Okay, here's 10,000 coins.", "Take to sawmill:",
  340.                                         "Click here to continue", "Yes", "Click here to continue");
  341.  
  342.                             } catch (InterruptedException e) {
  343.                                 e.printStackTrace();
  344.                             }
  345.                         }
  346.                     }
  347.                 }
  348.             }
  349.  
  350.         }
  351.  
  352.     }
  353.  
  354.     public void teleport_to_house() {
  355.  
  356.         Entity house_portal = getObjects().closest("Portal");
  357.  
  358.         if (LUMBRIDGE_PVP_BANK_AREA.contains(myPlayer().getPosition())
  359.                 || GRAND_EXCHANGE_AREA.contains(myPlayer().getPosition())) {
  360.  
  361.             getInventory().interact("Break", "Teleport to house");
  362.  
  363.             new ConditionalSleep(random(5000, 7000)) {
  364.                 @Override
  365.                 public boolean condition() {
  366.                     return house_portal != null && house_portal.isOnScreen();
  367.                 }
  368.  
  369.             }.sleep();
  370.         }
  371.  
  372.         if (house_portal != null && house_portal.isOnScreen()) {
  373.  
  374.             in_house = true;
  375.  
  376.         }
  377.  
  378.     }
  379.  
  380.     public void hop_to_pvp() {
  381.  
  382.         if (getWorlds().getCurrentWorld() != 325 && should_Ge == false) {
  383.  
  384.             getWorlds().hop(325);
  385.  
  386.             new ConditionalSleep(random(5000, 7000)) {
  387.                 @Override
  388.                 public boolean condition() {
  389.                     return getDialogues().inDialogue();
  390.                 }
  391.  
  392.             }.sleep();
  393.  
  394.             if (getDialogues().inDialogue()) {
  395.  
  396.                 try {
  397.                     getDialogues().completeDialogue("Switch to the PvP world.");
  398.                 } catch (InterruptedException e) {
  399.                     e.printStackTrace();
  400.                 }
  401.  
  402.             }
  403.  
  404.         }
  405.     }
  406.  
  407.     public void hop_to_non_pvp() {
  408.  
  409.         if (getWorlds().getCurrentWorld() == 325 && should_Ge == true) {
  410.  
  411.             getWorlds().hopToP2PWorld();
  412.  
  413.         }
  414.     }
  415.  
  416.     public void teleport_to_varrock() {
  417.  
  418.         if (should_Ge == true && LUMBRIDGE_PVP_BANK_AREA.contains(myPlayer().getPosition())
  419.                 && getWorlds().getCurrentWorld() != 325) {
  420.  
  421.             status = "Teleporting to Varrock";
  422.  
  423.             getInventory().interact("Break", "Varrock teleport");
  424.  
  425.             new ConditionalSleep(random(5000, 7000)) {
  426.                 @Override
  427.                 public boolean condition() {
  428.                     return VARROCK_TELEPORT_AREA.contains(myPlayer().getPosition());
  429.                 }
  430.  
  431.             }.sleep();
  432.  
  433.         }
  434.  
  435.     }
  436.  
  437.     public void to_grand_exchange() {
  438.  
  439.         if (VARROCK_TELEPORT_AREA.contains(myPlayer().getPosition())) {
  440.  
  441.             status = "Walking to Grand Exchange";
  442.  
  443.             getWalking().webWalk(GRAND_EXCHANGE_AREA);
  444.  
  445.         }
  446.  
  447.     }
  448.  
  449.     public void withdraw_logs() {
  450.  
  451.         status = "Withdrawing logs";
  452.  
  453.         if (getBank().isOpen() == false) {
  454.  
  455.             try {
  456.                 getBank().open();
  457.             } catch (InterruptedException e) {
  458.                 e.printStackTrace();
  459.             }
  460.  
  461.             if (getBank().isOpen() && getBank().contains(planks_to_make + " logs")) {
  462.  
  463.                 log_counter = getBank().getAmount(planks_to_make + " logs");
  464.  
  465.                 if (log_counter >= 25) {
  466.  
  467.                     getBank().withdraw(planks_to_make + " logs", 25);
  468.  
  469.                     getBank().close();
  470.  
  471.                 } else {
  472.  
  473.                     if (log_counter < 25) {
  474.  
  475.                         getBank().withdraw("Varrock teleport", 1);
  476.  
  477.                         if (getBank().getWithdrawMode().equals(Bank.BankMode.WITHDRAW_NOTE) == true) {
  478.  
  479.                             getBank().withdrawAll(planks_to_make + " plank");
  480.                             getBank().enableMode(Bank.BankMode.WITHDRAW_ITEM);
  481.  
  482.                         } else {
  483.  
  484.                             if (getBank().getWithdrawMode().equals(Bank.BankMode.WITHDRAW_NOTE) == false) {
  485.  
  486.                                 getBank().enableMode(Bank.BankMode.WITHDRAW_NOTE);
  487.                                 getBank().withdrawAll(planks_to_make + " plank");
  488.                                 getBank().enableMode(Bank.BankMode.WITHDRAW_ITEM);
  489.  
  490.                             }
  491.                         }
  492.  
  493.                         getBank().close();
  494.  
  495.                         try {
  496.                             sleep(random(750, 1250));
  497.                         } catch (InterruptedException e) {
  498.                             e.printStackTrace();
  499.                         }
  500.  
  501.                         should_Ge = true;
  502.                     }
  503.  
  504.                 }
  505.  
  506.             }
  507.         }
  508.  
  509.     }
  510.  
  511.     public void withdraw_logs_grand_exchange() {
  512.  
  513.         status = "Withdrawing logs";
  514.  
  515.         if (getBank().isOpen() == false) {
  516.  
  517.             try {
  518.                 getBank().open();
  519.             } catch (InterruptedException e) {
  520.                 e.printStackTrace();
  521.             }
  522.  
  523.             if (getBank().isOpen() && getBank().contains(planks_to_make + " logs")) {
  524.  
  525.                 log_counter = getBank().getAmount(planks_to_make + " logs");
  526.  
  527.                 if (log_counter >= 25) {
  528.  
  529.                     getBank().withdraw(planks_to_make + " logs", 25);
  530.  
  531.                     getBank().close();
  532.  
  533.                 } else {
  534.  
  535.                     if (log_counter < 25) {
  536.  
  537.                         getBank().withdraw("Varrock teleport", 1);
  538.  
  539.                         if (getBank().getWithdrawMode().equals(Bank.BankMode.WITHDRAW_NOTE) == true) {
  540.  
  541.                             getBank().withdrawAll(planks_to_make + " plank");
  542.                             getBank().enableMode(Bank.BankMode.WITHDRAW_ITEM);
  543.  
  544.                         } else {
  545.  
  546.                             if (getBank().getWithdrawMode().equals(Bank.BankMode.WITHDRAW_NOTE) == false) {
  547.  
  548.                                 getBank().enableMode(Bank.BankMode.WITHDRAW_NOTE);
  549.                                 getBank().withdrawAll(planks_to_make + " plank");
  550.                                 getBank().enableMode(Bank.BankMode.WITHDRAW_ITEM);
  551.  
  552.                             }
  553.                         }
  554.  
  555.                         getBank().close();
  556.                         should_Ge = true;
  557.                     }
  558.  
  559.                 }
  560.  
  561.             }
  562.         }
  563.  
  564.     }
  565.  
  566.     public void sell_planks() {
  567.  
  568.         Entity GE_BOOTH = getObjects().closest(GRAND_EXCHANGE_AREA, "Grand Exchange booth");
  569.  
  570.         if (getGrandExchange().isOpen() == false) {
  571.  
  572.             if (GE_BOOTH.interact("Exchange")) {
  573.  
  574.                 new ConditionalSleep(random(5000, 7000)) {
  575.                     @Override
  576.                     public boolean condition() {
  577.                         return getGrandExchange().isOpen() == true;
  578.                     }
  579.  
  580.                 }.sleep();
  581.  
  582.             }
  583.  
  584.             if (getGrandExchange().isOpen() == true) {
  585.  
  586.                 getGrandExchange().sellItem(plank_id, sell_planks_price,
  587.                         Integer.valueOf((int) getInventory().getAmount(planks_to_make + " plank")));
  588.  
  589.                 new ConditionalSleep(random(30000, 45000)) {
  590.  
  591.                     @Override
  592.                     public boolean condition() {
  593.                         return grandExchange.getStatus(Box.BOX_1) == Status.FINISHED_SALE;
  594.                     }
  595.  
  596.                 }.sleep();
  597.  
  598.             }
  599.  
  600.             if (grandExchange.getStatus(Box.BOX_1) == Status.FINISHED_SALE) {
  601.  
  602.                 getGrandExchange().collect();
  603.                 log(">C< House Planker: Planks sold");
  604.  
  605.                 getGrandExchange().close();
  606.  
  607.             } else {
  608.  
  609.                 if (grandExchange.getStatus(Box.BOX_1) == Status.PENDING_SALE) {
  610.  
  611.                     log(">C< House Planker: Planks taking too long to sell... stopping script");
  612.                     stop();
  613.                 }
  614.  
  615.             }
  616.         }
  617.     }
  618.  
  619.     public void buy_logs() {
  620.  
  621.         Entity GE_BOOTH = getObjects().closest(GRAND_EXCHANGE_AREA, "Grand Exchange booth");
  622.  
  623.         if (getGrandExchange().isOpen() == false) {
  624.  
  625.             if (GE_BOOTH.interact("Exchange")) {
  626.  
  627.                 new ConditionalSleep(random(5000, 7000)) {
  628.                     @Override
  629.                     public boolean condition() {
  630.                         return getGrandExchange().isOpen() == true;
  631.                     }
  632.  
  633.                 }.sleep();
  634.  
  635.             }
  636.  
  637.             if (getGrandExchange().isOpen() == true) {
  638.  
  639.                 getGrandExchange().buyItem(log_id, planks_to_make + " logs", buy_logs_price, buy_logs_amount);
  640.  
  641.                 new ConditionalSleep(random(30000, 45000)) {
  642.  
  643.                     @Override
  644.                     public boolean condition() {
  645.                         return grandExchange.getStatus(Box.BOX_1) == Status.FINISHED_BUY;
  646.                     }
  647.  
  648.                 }.sleep();
  649.  
  650.             }
  651.  
  652.             if (grandExchange.getStatus(Box.BOX_1) == Status.FINISHED_BUY) {
  653.  
  654.                 getGrandExchange().collect(true);
  655.                 log(">C< House Planker: Logs bought");
  656.                 log_counter = buy_logs_amount;
  657.                 should_Ge = false;
  658.  
  659.             } else {
  660.  
  661.                 if (grandExchange.getStatus(Box.BOX_1) == Status.PENDING_BUY) {
  662.  
  663.                     log(">C< House Planker: Logs taking too long to buy... stopping script");
  664.                     stop();
  665.  
  666.                 }
  667.             }
  668.         }
  669.  
  670.     }
  671.    
  672.     @Override
  673.     public void onPaint(final Graphics2D g) {
  674.  
  675.         final long runTime = System.currentTimeMillis() - startTime;
  676.  
  677.         g.setColor(Color.WHITE);
  678.         Font font = new Font("Verdana", Font.PLAIN, 17);
  679.         g.setFont(font);
  680.         g.drawString(">C< House Planker - v0.1", 29, 204);
  681.         Font font2 = new Font("Verdana", Font.PLAIN, 12);
  682.         g.setFont(font2);
  683.         g.drawString("Time running: " + formatTime(runTime), 29, 224);
  684.         g.drawString("Status: " + status, 29, 244);
  685.         g.drawString("Planks made: "+planks_made, 29, 264);
  686.     }
  687.  
  688.     public class GUI {
  689.  
  690.         private JFrame frmc;
  691.         private JTextField textField;
  692.         private JTextField textField_1;
  693.         private JTextField textField_2;
  694.         private JTextField textField_3;
  695.  
  696.         public GUI() {
  697.             initialize();
  698.         }
  699.  
  700.         /**
  701.          * Initialize the contents of the frame.
  702.          */
  703.         private void initialize() {
  704.             frmc = new JFrame();
  705.             frmc.setResizable(false);
  706.             frmc.setTitle(">C< House Plank Maker");
  707.             frmc.setBounds(100, 100, 314, 277);
  708.             frmc.getContentPane().setLayout(null);
  709.  
  710.             JLabel lblPlankSettings = new JLabel("Plank settings:");
  711.             lblPlankSettings.setForeground(Color.GRAY);
  712.             lblPlankSettings.setBounds(10, 11, 81, 14);
  713.             frmc.getContentPane().add(lblPlankSettings);
  714.  
  715.             JComboBox comboBox = new JComboBox();
  716.             comboBox.setModel(new DefaultComboBoxModel(new String[] { "Oak", "Teak", "Mahogany" }));
  717.             comboBox.setBounds(92, 36, 206, 20);
  718.             frmc.getContentPane().add(comboBox);
  719.  
  720.             JLabel lblPlanksToMake = new JLabel("Planks to make:");
  721.             lblPlanksToMake.setBounds(10, 39, 81, 14);
  722.             frmc.getContentPane().add(lblPlanksToMake);
  723.  
  724.             JSeparator separator = new JSeparator();
  725.             separator.setBounds(0, 67, 311, 2);
  726.             frmc.getContentPane().add(separator);
  727.  
  728.             JLabel lblGrandExchangeSettings = new JLabel("Grand Exchange settings:");
  729.             lblGrandExchangeSettings.setForeground(Color.GRAY);
  730.             lblGrandExchangeSettings.setBounds(10, 79, 169, 14);
  731.             frmc.getContentPane().add(lblGrandExchangeSettings);
  732.  
  733.             JCheckBox chckbxRestockLogs = new JCheckBox("Restock?");
  734.             chckbxRestockLogs.setBounds(140, 72, 91, 29);
  735.             frmc.getContentPane().add(chckbxRestockLogs);
  736.  
  737.             textField = new JTextField();
  738.             textField.setBounds(195, 123, 103, 20);
  739.             textField.setText("0");
  740.             frmc.getContentPane().add(textField);
  741.             textField.setColumns(10);
  742.  
  743.             textField_1 = new JTextField();
  744.             textField_1.setColumns(10);
  745.             textField_1.setBounds(54, 123, 81, 20);
  746.             textField_1.setText("0");
  747.             frmc.getContentPane().add(textField_1);
  748.  
  749.             JLabel lblAmount = new JLabel("Amount:");
  750.             lblAmount.setBounds(10, 126, 46, 14);
  751.             frmc.getContentPane().add(lblAmount);
  752.  
  753.             JLabel lblBuyPrice = new JLabel("Buy price:");
  754.             lblBuyPrice.setBounds(144, 126, 55, 14);
  755.             frmc.getContentPane().add(lblBuyPrice);
  756.  
  757.             JSeparator separator_1 = new JSeparator();
  758.             separator_1.setBounds(0, 201, 311, 2);
  759.             frmc.getContentPane().add(separator_1);
  760.  
  761.             JButton btnStart = new JButton("Start");
  762.             btnStart.addActionListener(new ActionListener() {
  763.                 public void actionPerformed(ActionEvent arg0) {
  764.  
  765.                     planks_to_make = comboBox.getSelectedItem().toString();
  766.  
  767.                     buy_logs_price = Integer.parseInt(textField.getText());
  768.                     buy_logs_amount = Integer.parseInt(textField_1.getText());
  769.  
  770.                     sell_planks_price = Integer.parseInt(textField_3.getText());
  771.  
  772.                     if(planks_to_make == "Oak") {
  773.                        
  774.                         plank_id = 1521;
  775.                         log_id = 8779;
  776.                        
  777.                     }else {
  778.                        
  779.                         if(planks_to_make == "Teak") {
  780.                            
  781.                             plank_id = 6333;
  782.                             log_id = 8781;
  783.                            
  784.                         }else {
  785.                            
  786.                             if(planks_to_make == "Mahogany") {
  787.                                
  788.                                 plank_id = 6332;
  789.                                 log_id = 8783;
  790.                             }
  791.                            
  792.                         }
  793.                     }
  794.                    
  795.                    
  796.                     if (chckbxRestockLogs.isSelected()) {
  797.  
  798.                         should_restock = true;
  799.  
  800.                     } else {
  801.  
  802.                         buy_logs_price = 0;
  803.                         buy_logs_amount = 0;
  804.                         sell_planks_price = 0;
  805.                         should_restock = false;
  806.  
  807.                     }
  808.                    
  809.                     log("Making: "+planks_to_make+" planks");
  810.                     log("Plank id: "+plank_id);
  811.                     log("Log id: "+log_id);
  812.                     log("Restocking: "+should_restock);
  813.                     log("Buying logs for: "+buy_logs_price);
  814.                     log("Buying "+buy_logs_amount+" logs");
  815.                     log("Selling planks for: "+sell_planks_price+"gp");
  816.  
  817.                     gui_COMPLETE = true;
  818.                 }
  819.             });
  820.             btnStart.setBounds(10, 214, 288, 23);
  821.             frmc.getContentPane().add(btnStart);
  822.  
  823.             JLabel lblLogs = new JLabel("Logs:");
  824.             lblLogs.setForeground(Color.GRAY);
  825.             lblLogs.setBounds(10, 104, 46, 20);
  826.             frmc.getContentPane().add(lblLogs);
  827.  
  828.             JLabel lblPlanks = new JLabel("Planks:");
  829.             lblPlanks.setForeground(Color.GRAY);
  830.             lblPlanks.setBounds(10, 151, 46, 20);
  831.             frmc.getContentPane().add(lblPlanks);
  832.  
  833.             JLabel label_1 = new JLabel("Amount:");
  834.             label_1.setBounds(10, 173, 46, 14);
  835.             frmc.getContentPane().add(label_1);
  836.  
  837.             textField_2 = new JTextField();
  838.             textField_2.setColumns(10);
  839.             textField_2.setBounds(54, 170, 81, 20);
  840.             textField_2.setText("All");
  841.             textField_2.setEditable(false);
  842.             frmc.getContentPane().add(textField_2);
  843.  
  844.             JLabel lblSellPrice = new JLabel("Sell price:");
  845.             lblSellPrice.setBounds(144, 173, 55, 14);
  846.             frmc.getContentPane().add(lblSellPrice);
  847.  
  848.             textField_3 = new JTextField();
  849.             textField_3.setColumns(10);
  850.             textField_3.setBounds(195, 170, 103, 20);
  851.             textField_3.setText("0");
  852.             frmc.getContentPane().add(textField_3);
  853.         }
  854.     }
Advertisement
Add Comment
Please, Sign In to add comment