Advertisement
deww1

FuserConstruction.java -Version 1.1

Jul 22nd, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 50.64 KB | None | 0 0
  1. /*
  2.  
  3.  *LICENSE*
  4.  <This is a java script for the PowerBot platform.>
  5.     Copyright (C) 2011  Fuser scripts
  6.  
  7.     This program is free software: you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation, either version 3 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  *LICENSE*
  17.  
  18.  We encourage every script writer of Fuser scripts to make use of the skeleton code.
  19.  Look at this like suggested methods or recommended ways to write scripts. Don't let this hold back your creativity
  20.  in any way.
  21.  
  22.  
  23.   @Contributors
  24.   - Ubuntu4life
  25.   - Dew
  26.   - ExoCode
  27.  */
  28.  
  29. import java.awt.BasicStroke;
  30. import java.awt.Color;
  31. import java.awt.Font;
  32. import java.awt.Graphics;
  33. import java.awt.Graphics2D;
  34. import java.awt.Image;
  35. import java.awt.Point;
  36. import java.awt.Rectangle;
  37. import java.awt.RenderingHints;
  38. import java.awt.event.KeyEvent;
  39. import java.awt.event.MouseEvent;
  40. import java.awt.event.MouseListener;
  41. import java.io.BufferedReader;
  42. import java.io.IOException;
  43. import java.io.InputStreamReader;
  44. import java.io.PrintWriter;
  45. import java.lang.reflect.InvocationTargetException;
  46. import java.net.URL;
  47. import java.text.NumberFormat;
  48. import java.util.LinkedList;
  49. import java.util.Locale;
  50. import java.util.Random;
  51. import java.util.regex.Matcher;
  52. import java.util.regex.Pattern;
  53.  
  54. import javax.imageio.ImageIO;
  55. import javax.swing.SwingUtilities;
  56. import org.rsbot.Configuration;
  57. import org.rsbot.client.RSItem;
  58.  
  59. import org.rsbot.event.events.MessageEvent;
  60. import org.rsbot.event.listeners.MessageListener;
  61. import org.rsbot.event.listeners.PaintListener;
  62. import org.rsbot.script.Script;
  63. import org.rsbot.script.ScriptManifest;
  64. import org.rsbot.script.methods.Methods;
  65. import org.rsbot.script.methods.Skills;
  66. import org.rsbot.script.wrappers.RSComponent;
  67. import org.rsbot.script.wrappers.RSInterface;
  68. import org.rsbot.script.wrappers.RSNPC;
  69. import org.rsbot.script.wrappers.RSObject;
  70. import org.rsbot.script.wrappers.RSTile;
  71. import org.rsbot.script.wrappers.RSWeb;
  72.  
  73. @ScriptManifest(authors = { "Dew" }, name = "FuserConstruction", version = 1.1, description = "The new standart of Construction botting.", website = "http://www.powerbot.org/community/topic/LINK/", requiresVersion = 257)
  74. public class FuserConstruction extends Script implements MessageListener, PaintListener, MouseListener {
  75.  
  76.     @Override
  77.     public void messageReceived(final MessageEvent serverTraffic) {
  78.         final String serverMessage = serverTraffic.getMessage().toLowerCase();
  79.         if (serverMessage.contains("advanced a")) {
  80.             log("Congratulations on level up !");
  81.         }
  82.         if (serverMessage.contains("the next runescape")) {
  83.             log("There will be a system update soon, logged out.");
  84.             stopScript(true);
  85.         }
  86.     }
  87.     public Double ver = FuserConstruction.class.getAnnotation(ScriptManifest.class).version();
  88.     public Double currVer;
  89.     public boolean doUpdate = false;
  90.  
  91.     boolean stepClicked = false;
  92.     public boolean guiIsOpen = true,
  93.             showPaint = true;
  94.     public long experienceGained, currentExperience, startExperience, expHour,
  95.             startLevel, experiencePerHour, startTime = 0;
  96.     public MousePaint mousePaint = new MousePaint();
  97.     public Image cursorUnclicked, cursorClicked, fuserScriptsLogo, userLogo,
  98.             paintBackGround, closeButton, openButton, Avatar;
  99.     public String paintType = "Chatbox Paint", Status = "Starting script";
  100.     public String messageFromDew = "Stay Frosty! :)";
  101.  
  102.     FuserConstructionGui gui = new FuserConstructionGui();
  103.      /**
  104.      * Try to break up the script in as many actions as possible.
  105.      */
  106.     private enum Action {
  107.         SWITCHMODES, PAYBUTLER, FETCH, DECONSTRUCT, CONSTRUCT, WAIT, UNKNOWN
  108.     }
  109.  
  110.     /**
  111.      * Constants here.
  112.      */
  113.     public static interface Constants {
  114.         int gp = 995;
  115.         int saw = 8794;
  116.         int hammer = 2347;
  117.  
  118.         int[] buildMaterialIds = {8778};
  119.         int buildMaterialId = buildMaterialIds[0];
  120.         String[] buildMaterialAmts = {"24"};
  121.         String buildMaterialAmt = buildMaterialAmts[0];
  122.  
  123.         int[] butlerIDs = {4243};
  124.         int butlerID = butlerIDs[0];
  125.  
  126.         int buildDoor = 15316;
  127.  
  128.         int[] constructIds = {15403};
  129.         int constructId = constructIds[0];
  130.  
  131.         int[] deconstructIds = {13566};
  132.         int deconstructId = deconstructIds[0];
  133.  
  134.         boolean inBuildMode = false;
  135.  
  136.         // <editor-fold defaultstate="collapsed" desc="FETCH Vars">
  137.  
  138.  
  139.         int mainfetchinter = 234;
  140.         int mainfetchcom = 2;
  141.         String[] mainfetchstrings = {"etch another"};
  142.         String mainfetchstring = mainfetchstrings[0];
  143.        
  144.         int fetchInterId1 = 241;
  145.         int fetchComIdStep1 = 4;
  146.         String[] fetchComStringStep1Strings = {"am at thy"};
  147.         String fetchComStringStep1 = fetchComStringStep1Strings[0];
  148.        
  149.         int fetchInterId4 = 232;
  150.         int fetchComIdStep4 = 3;
  151.         String[] fetchComStringStep4Strings = {"ak plank"};
  152.         String fetchComStringStep4 = fetchComStringStep4Strings[0];
  153.        
  154.         int fetchInterId5 = 752;
  155.         int fetchComIdStep5 = 4;
  156.         String[] fetchComStringStep5Strings = {"nter amoun"};
  157.         String fetchComStringStep5 = fetchComStringStep5Strings[0];
  158.         // </editor-fold>
  159.        
  160.         // <editor-fold defaultstate="collapsed" desc="CONSTRUCT Vars">
  161.         int[] mainInters = {394};
  162.         int mainInter = mainInters[0];
  163.        
  164.         int[] mainComs = {11};
  165.         int mainCom = mainComs[0];
  166.        
  167.         int[] clickComs = {1};
  168.         int clickCom = clickComs[0];
  169.         // </editor-fold>
  170.  
  171.         // <editor-fold defaultstate="collapsed" desc="DECONSTRUCT Vars">
  172.         int de_inter1 = 228;
  173.         int de_com1 = 2;
  174.         String de_comstring = "es";
  175.         // </editor-fold>
  176.        
  177.         // <editor-fold defaultstate="collapsed" desc="PAYBUTLER Vars">
  178.         int pay_inter1 = 243;
  179.         int pay_com1 = 4;
  180.         String[] pay_strings1 = {"my continued service"};
  181.         String pay_string1 = pay_strings1[0];
  182.  
  183.         int pay_inter2 = 232;
  184.         int pay_com2 = 2;
  185.         String[] pay_strings2 = {"ay servant"};
  186.         String pay_string2 = pay_strings2[0];
  187.         // </editor-fold>
  188.  
  189.  
  190.  
  191.         Color Color1 = new Color(255, 255, 255), Transparent = new Color(255,
  192.                 255, 255, 0);
  193.         Font Font1 = new Font("Calibri", 1, 14), Font2 = new Font("Calibri", 0,
  194.                 14), Font3 = new Font("Calibri", 0, 9);
  195.         Rectangle fuserScriptsLogoRectangle = new Rectangle(4, 276, 207, 69),
  196.                 userLogoRectangle = new Rectangle(9, 347, 124, 28),
  197.                 closeButtonRectangle = new Rectangle(426, 345, 22, 22),
  198.                 openButtonRectangle = new Rectangle(474, 345, 22, 22),
  199.                 avatarRectangle = new Rectangle(448, 345, 65, 65);
  200.     }
  201.  
  202.     @Override
  203.     public boolean onStart() {
  204.         currVer = checkVer();
  205.         startExperience = (long) skills.getCurrentExp(Skills.CONSTRUCTION);
  206.         startLevel = (long) skills.getRealLevel(Skills.CONSTRUCTION);
  207.         startTime = System.currentTimeMillis();
  208.         if(!checkInv(Constants.gp) || !checkInv(Constants.saw) || !checkInv(Constants.hammer)) {
  209.             log("You need GP, saw and hammer in inventory!");
  210.             return false;
  211.         }
  212.         if (!game.isLoggedIn()) {
  213.             log.severe("Start this script logged in please.");
  214.             return false;
  215.         }
  216.         if (!game.isFixed()) {
  217.             log.severe("It's highly recommended to bot with fixed screen mode.");
  218.             return false;
  219.         }
  220.         try {
  221.             SwingUtilities.invokeAndWait(new Runnable() {
  222.                 @Override
  223.                 public void run() {
  224.                     new FuserConstructionGui().setVisible(true);
  225.                 }
  226.             });
  227.         } catch (InterruptedException ignored) {
  228.         } catch (InvocationTargetException ignored) {
  229.         }
  230.         while (guiIsOpen) {
  231.             Methods.sleep(25);
  232.         }
  233.         log(Color.CYAN, "Loading version: "+ver);
  234.         sleep(100, 1000);
  235.         log(Color.GREEN, "Loading Images...");
  236.         Avatar = getImage("http://i.imgur.com/hHeXN.png");
  237.         userLogo = getImage("http://i.imgur.com/EE1kp.png");
  238.  
  239.         cursorUnclicked = getImage("http://i.imgur.com/AfJYm.png");
  240.         cursorClicked = getImage("http://i.imgur.com/ZPycs.png");
  241.         fuserScriptsLogo = getImage("http://i.imgur.com/yzKFM.png");
  242.         paintBackGround = getImage("http://i.imgur.com/9vt7j.png");
  243.         closeButton = getImage("http://i.imgur.com/RqFu8.png");
  244.         openButton = getImage("http://i.imgur.com/OPMSU.png");
  245.         log(Color.PINK, "Load Complete!");
  246.  
  247.         if (doUpdate) {
  248.             checkForUpdates();
  249.         } else {
  250.             if(currVer > ver) {
  251.             displayVer();
  252.             log(Color.MAGENTA, "Restart script, and go to my thread, or update script via GUI! :)");
  253.         }
  254.  
  255.         }
  256.  
  257.         return true;
  258.     }
  259.  
  260.      /**
  261.      * Try to place as much logic as possible here instead of in the loop.
  262.      *
  263.      * @return Action
  264.      */
  265.     public Action getAction() {
  266.         try {
  267.             RSNPC butler = npcs.getNearest(Constants.butlerID);
  268.             if (game.getClientState() != 11 || butler == null || !butler.isOnScreen()
  269.                     || getMyPlayer().getAnimation() == 3676 || getMyPlayer().getAnimation() == 3685) {
  270.                 return Action.WAIT;
  271.             } else {
  272.                 if (this.checkInterface(Constants.pay_inter1) && checkComponent(Constants.pay_inter1, Constants.pay_com1) && this.checkComText(Constants.pay_inter1, Constants.pay_com1, Constants.pay_string1)
  273.                  || this.checkInterface(Constants.pay_inter2) && checkComponent(Constants.pay_inter2, Constants.pay_com2) && this.checkComText(Constants.pay_inter2, Constants.pay_com2, Constants.pay_string2)    ) {
  274.                     return Action.PAYBUTLER;
  275.                 }
  276.                 RSObject inBuildDoor = objects.getNearest(Constants.buildDoor);
  277.                 if (inBuildDoor == null) {
  278.                     return Action.SWITCHMODES;
  279.                 } else {
  280.                     if (!inventory.contains(Constants.buildMaterialId) || inventory.getCount(Constants.buildMaterialId) < 8 || checkInterface(241) && checkComText(241, 4, "hank you")) {
  281.                         return Action.FETCH;
  282.                     } else {
  283.                         RSObject construct = objects.getNearest(Constants.constructId);
  284.                         RSObject deconstruct = objects.getNearest(Constants.deconstructId);
  285.                         if (construct == null && deconstruct != null || checkInterface(241) && checkComText(241, 4, "hank you")) {
  286.                             return Action.DECONSTRUCT;
  287.                         } else {
  288.                             return Action.CONSTRUCT;
  289.                         }
  290.                     }
  291.                 }
  292.             }
  293.         } catch (final Exception e) {
  294.             log("help?");
  295.             return Action.UNKNOWN;
  296.         }
  297.     }
  298.  
  299.     public int loop() {
  300.         setStatus();
  301.         try {
  302.             if (interfaces.get(242) != null && interfaces.get(242).getComponent(4).containsText("cannot")) {
  303.                 log(Color.CYAN, "[SUCCESS]Out of Material: We have depleted all of our resources!");
  304.                 stopScript();
  305.             }
  306.             mouse.setSpeed(Methods.random(4, 7));
  307.             switch (getAction()) {
  308.                
  309.                 case FETCH:
  310.                     // <editor-fold defaultstate="collapsed" desc="FETCH Action">
  311.                     final RSNPC butler = npcs.getNearest(Constants.butlerID);
  312.                     if (butler.isOnScreen()) {
  313.                         if (!checkInterface(Constants.mainfetchinter)
  314.                             && !checkInterface(Constants.fetchInterId1) && !checkInterface(Constants.fetchInterId4)
  315.                                 || checkInterface(241) && checkComText(241, 4, "hank you") ||
  316.                                 !checkInterface(Constants.mainfetchinter)
  317.                                 && !checkInterface(Constants.fetchInterId1)  && !checkInterface(Constants.fetchInterId4)
  318.                                 && checkInterface(Constants.fetchInterId5) && checkComponent(Constants.fetchInterId5, Constants.fetchComIdStep5)
  319.                                 && checkComText(Constants.fetchInterId5, Constants.fetchComIdStep5, Constants.fetchComStringStep5) && stepClicked
  320.                                 ) {
  321.                             this.clickNPC(butler, "Fetch-from-bank");
  322.                             sleep(500, 1000);
  323.                         }
  324.                         if (inventory.contains(Constants.buildMaterialId) && inventory.getCount(Constants.buildMaterialId) > 7) {
  325.                             break;
  326.                         }
  327.                         if (checkInterface(Constants.mainfetchinter)) {
  328.                             if (checkComponent(Constants.mainfetchinter, Constants.mainfetchcom)) {
  329.                                 if (checkComText(Constants.mainfetchinter, Constants.mainfetchcom, Constants.mainfetchstring)) {
  330.                                     this.interDoAction(Constants.mainfetchinter, Constants.mainfetchcom);
  331.                                     stepClicked = false;
  332.                                     sleep(random(500, 1000), random(1000, 1500));
  333.                                 }
  334.                             }
  335.                         } else if (checkInterface(Constants.fetchInterId4) || checkInterface(Constants.fetchInterId5)) {
  336.                             if (checkInterface(Constants.fetchInterId4)) {
  337.                                 if (checkComponent(Constants.fetchInterId4, Constants.fetchComIdStep4)) {
  338.                                     if (checkComText(Constants.fetchInterId4, Constants.fetchComIdStep4, Constants.fetchComStringStep4)) {
  339.                                         this.interDoAction(Constants.fetchInterId4, Constants.fetchComIdStep4);
  340.                                         stepClicked = true;
  341.                                         sleep(random(500, 1000), random(1000, 1500));
  342.                                         while (stepClicked) {
  343.                                             keyboard.sendText("24", true);
  344.                                             sleep(1000, 2000);
  345.                                             stepClicked = false;
  346.                                         }
  347.                                     }
  348.                                 }
  349.                             } else if (checkInterface(Constants.fetchInterId5) && stepClicked) {
  350.                                 if (checkComponent(Constants.fetchInterId5, Constants.fetchComIdStep5)) {
  351.                                     if (checkComText(Constants.fetchInterId5, Constants.fetchComIdStep5, Constants.fetchComStringStep5)) {
  352.                                         keyboard.sendTextInstant("24", true);
  353.                                         sleep(random(500, 1000), random(1000, 1500));
  354.                                     }
  355.                                 }
  356.                             }
  357.                         }
  358.                     }
  359.                     // </editor-fold>
  360.                     break;
  361.  
  362.                 case CONSTRUCT:
  363.                     // <editor-fold defaultstate="collapsed" desc="CONSTRUCT Action">
  364.                     RSObject construct = objects.getNearest(Constants.constructId);
  365.                     if (!checkInterface(Constants.mainInter)) {
  366.                         construct.interact("Build");
  367.                         //sleep(random(500, 1000), random(1000, 1500));
  368.                         //this.clickObject(construct, "Build");
  369.                     } else {
  370.                         RSInterface main = interfaces.get(Constants.mainInter);
  371.                         RSComponent com = main.getComponent(Constants.mainCom).getComponent(Constants.clickCom);
  372.                         if (main != null && main.isValid()) {
  373.                             if (com != null && com.isValid()) {
  374.                                 com.interact("build");
  375.                                 sleep(random(500, 1000), random(1000, 1500));
  376.                             }
  377.                         }
  378.                     }
  379.                     // </editor-fold>
  380.                     break;
  381.  
  382.                 case DECONSTRUCT:
  383.                     // <editor-fold defaultstate="collapsed" desc="DECONSTRUCT Action">
  384.                     RSObject deconstruct = objects.getNearest(Constants.deconstructId);
  385.                     if (!checkInterface(Constants.de_inter1)) {
  386.                         deconstruct.interact("Remove");
  387.                         //sleep(random(500, 1000), random(1000, 1500));
  388.                         //this.clickObject(construct, "Build");
  389.                     } else {
  390.                         if (checkInterface(Constants.de_inter1)) {
  391.                             if (checkComponent(Constants.de_inter1, Constants.de_com1)) {
  392.                                 this.interDoAction(Constants.de_inter1, Constants.de_com1);
  393.                                 sleep(random(500, 1000), random(1000, 1500));
  394.                             }
  395.                         }
  396.                     }
  397.                     // </editor-fold>
  398.                     break;
  399.  
  400.                 case PAYBUTLER:
  401.                     // <editor-fold defaultstate="collapsed" desc="PAYBUTLER Action">
  402.                     if (checkInterface(Constants.pay_inter1)) {
  403.                         if (checkComponent(Constants.pay_inter1, Constants.pay_com1)) {
  404.                             if (checkComText(Constants.pay_inter1, Constants.pay_com1, Constants.pay_string1)) {
  405.                                 this.interDoAction(Constants.pay_inter1, 7);
  406.                             }
  407.                         }
  408.                     } else if (checkInterface(Constants.pay_inter2)) {
  409.                         if (checkComponent(Constants.pay_inter2, Constants.pay_com2)) {
  410.                             if (checkComText(Constants.pay_inter2, Constants.pay_com2, Constants.pay_string2)) {
  411.                                 this.interDoAction(Constants.pay_inter2, Constants.pay_com2);
  412.                             }
  413.                         }
  414.                     }
  415.                     // </editor-fold>
  416.                     break;
  417.  
  418.                 case WAIT:
  419.                     break;
  420.             }
  421.         } catch (final Exception e) {
  422.             log("HELP");
  423.             log(""+e.getLocalizedMessage());
  424.             stopScript();
  425.             return 25;
  426.         }
  427.         return random(1000, 1400);
  428.     }
  429.  
  430.     @Override
  431.     public void onFinish() {
  432.  
  433.     }
  434.  
  435.     public void setStatus() {
  436.         switch(getAction()) {
  437.             case SWITCHMODES:
  438.                 Status = "Switching to Build Mode.";
  439.                 break;
  440.             case PAYBUTLER:
  441.                 Status = "Paying our Butler.";
  442.                 break;
  443.             case FETCH:
  444.                 Status = "Fetching materials.";
  445.                 break;
  446.             case DECONSTRUCT:
  447.                 Status = "Deconstructing Object.";
  448.                 break;
  449.             case CONSTRUCT:
  450.                 Status = "Constructing Object.";
  451.                 break;
  452.             case WAIT:
  453.                 Status = "Waiting...";
  454.                 break;
  455.             case UNKNOWN:
  456.                 Status = "There is a problem.. -_-";
  457.                 break;
  458.         }
  459.     }
  460.  
  461.     // <editor-fold defaultstate="collapsed" desc="METHODS">
  462.     /**
  463.      * Performs the specified action on a given RSNPC. Version 1.00
  464.      *
  465.      * @param RSNPC
  466.      *            The RSNPC to perform an action on.
  467.      * @param Action
  468.      *            the menu item to search and click.
  469.      * @return returns true if clicked.
  470.      *
  471.      * @Author Ubuntu4life
  472.      */
  473.     private boolean clickNPC(final RSNPC RSNPC, final String Action) {
  474.         try {
  475.             Point p;
  476.             for (int i = 0; i < 25; i++) {
  477.                 while (!menu.contains(Action)) {
  478.                     if (players.getMyPlayer().isMoving()) {
  479.                         p = RSNPC.getModel().getCentralPoint();
  480.                     } else {
  481.                         p = RSNPC.getModel().getPoint();
  482.                     }
  483.                     if (!RSNPC.isOnScreen() || bank.isOpen()) {
  484.                         return false;
  485.                     }
  486.                     moveMouse(getDelay(p), p);
  487.                 }
  488.                 if (menu.contains(Action)) {
  489.                     mouse.setSpeed(Methods.random(5, 8));
  490.                     mouse.click(false);
  491.                     for (int x = 0; x < 4; x++) {
  492.                         if (menu.doAction(Action)) {
  493.                             return true;
  494.                         }
  495.                     }
  496.                 }
  497.                 if (menu.isOpen() && !menu.contains(Action)) {
  498.                     do {
  499.                         mouse.moveRandomly(Methods.random(180, 310));
  500.                     } while (menu.isOpen());
  501.                     i = 0;
  502.                 }
  503.             }
  504.         } catch (final Exception e) {
  505.             log("help?1");
  506.         }
  507.         return false;
  508.     }
  509.  
  510.     /**
  511.      * Performs the specified action on a given RSObject. Version 1.00
  512.      *
  513.      * @param RSObject
  514.      *            The RSObject to perform an action on.
  515.      * @param Action
  516.      *            the menu item to search and click.
  517.      * @return returns true if clicked.
  518.      *
  519.      * @Author Ubuntu4life
  520.      */
  521.     private boolean clickObject(final RSObject object, final String action) {
  522.         try {
  523.             Point p;
  524.             for (int i = 0; i < 25; i++) {
  525.                 while (!menu.contains(action)) {
  526.                     if (players.getMyPlayer().isMoving()) {
  527.                         p = object.getModel().getCentralPoint();
  528.                     } else {
  529.                         p = object.getModel().getPoint();
  530.                     }
  531.                     if (!object.isOnScreen() || bank.isOpen()) {
  532.                         return false;
  533.                     }
  534.                     moveMouse(getDelay(p), p);
  535.                 }
  536.                 final String[] menuItems = menu.getItems();
  537.                 if (menuItems.length > 0
  538.                         && menuItems[0].toLowerCase().startsWith(
  539.                         action.toLowerCase())) {
  540.                     mouse.click(true);
  541.                     return true;
  542.                 } else if (menu.contains(action)) {
  543.                     mouse.setSpeed(Methods.random(5, 8));
  544.                     mouse.click(false);
  545.                     for (int x = 0; x < 4; x++) {
  546.                         if (menu.doAction(action)) {
  547.                             return true;
  548.                         }
  549.                     }
  550.                 }
  551.                 if (!menu.contains(action) && menu.isOpen()) {
  552.                     do {
  553.                         mouse.moveRandomly(Methods.random(180, 310));
  554.                     } while (menu.isOpen());
  555.                     i = 0;
  556.                 }
  557.             }
  558.         } catch (final Exception e) {
  559.             log("Help?3");
  560.         }
  561.         return false;
  562.     }
  563.  
  564.     private double getDelay(final Point p) {
  565.         final double Distance = calc.distanceBetween(mouse.getLocation(), p);
  566.         if (Distance > 150) {
  567.             return 60;
  568.         } else {
  569.             if (Distance >= 40) {
  570.                 return Distance / 4;
  571.             } else {
  572.                 return 10;
  573.             }
  574.         }
  575.     }
  576.  
  577.     private void moveMouse(final double time, final Point p) {
  578.         final double endTime = System.currentTimeMillis() + time;
  579.         while (System.currentTimeMillis() < endTime) {
  580.             mouse.move(p, 0, 0);
  581.         }
  582.     }
  583.  
  584.     /**
  585.      *
  586.      * @param interID interface's ID
  587.      * @return <tt>true</tt> if interface is not null and is valid
  588.      */
  589.     public boolean checkInterface(int interID) {
  590.         RSInterface inter = interfaces.get(interID);
  591.         return inter != null && inter.isValid();
  592.     }
  593.  
  594.     /**
  595.      *
  596.      * @param interID interface's ID
  597.      * @param comID component's ID
  598.      * @return <tt>true</tt> if component is not null and is valid
  599.      */
  600.     public boolean checkComponent(int interID, int comID) {
  601.         RSInterface main = interfaces.get(interID);
  602.         RSComponent com = main.getComponent(comID);
  603.         return com != null && com.isValid();
  604.     }
  605.  
  606.     public boolean checkComponent(int interID, int comID1, int comID2) {
  607.         RSInterface main = interfaces.get(interID);
  608.         RSComponent com1 = main.getComponent(comID1);
  609.         RSComponent com2 = com1.getComponent(comID2);
  610.         return com1 != null && com1.isValid() && com2 != null && com2.isValid();
  611.     }
  612.  
  613.     /**
  614.      *
  615.      * @param interID interface's ID
  616.      * @param comID component's ID
  617.      * @param text string of text
  618.      * @return <tt>true</tt> if the component contains text
  619.      */
  620.     public boolean checkComText(int interID, int comID, String text) {
  621.         RSInterface main = interfaces.get(interID);
  622.         RSComponent com = main.getComponent(comID);
  623.         return com != null && com.isValid() && com.containsText(text);
  624.     }
  625.  
  626.     /**
  627.      * clicks ComID
  628.      * @param interID interface id
  629.      * @param comID component id
  630.      */
  631.     public void interDoAction(int interID, int comID) {
  632.         RSInterface main = interfaces.get(interID);
  633.         RSComponent com = main.getComponent(comID);
  634.         if (main != null && main.isValid()) {
  635.             if (com != null && com.isValid()) {
  636.                 com.doClick();
  637.             }
  638.         }
  639.     }
  640.  
  641.     /**
  642.      *
  643.      * @param Item item to check
  644.      * @return <tt>true</tt> if item is not null
  645.      */
  646.     public boolean checkInv(int Item) {
  647.         return inventory.contains(Item);
  648.     }
  649.     // </editor-fold>
  650.  
  651.  
  652.     // <editor-fold defaultstate="collapsed" desc="Paint">
  653.     private final RenderingHints renderHints = new RenderingHints(
  654.             RenderingHints.KEY_TEXT_ANTIALIASING,
  655.             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  656.  
  657.     public void mainPaint(Graphics g) {
  658.         Graphics2D g2 = (Graphics2D) g;
  659.  
  660. //        // (CHANGE) Change the skill.
  661.         if ((skills.getCurrentExp(Skills.CONSTRUCTION) - startExperience) > 0
  662.                 && startExperience > 0) {
  663.             experienceGained = skills.getCurrentExp(Skills.CONSTRUCTION)
  664.                     - startExperience;
  665.             expHour = (int) ((experienceGained) * 3600000D /
  666.                 (System.currentTimeMillis() - startTime));
  667.         }
  668. //            long secondsTNL = (skills.getExpToNextLevel(Skills.CONSTRUCTION)) / (expHour / 3600);
  669. //            long hoursTNL = secondsTNL / (60 * 60); secondsTNL -= hoursTNL * (60 * 60);
  670. //            long minutesTNL = secondsTNL / 60;
  671. //            secondsTNL -= minutesTNL * 60;
  672.  
  673.  
  674.  
  675.  
  676.  
  677.             long lvlsGained = startLevel - skills.getRealLevel(Skills.CONSTRUCTION);
  678.             long millis = System.currentTimeMillis() - startTime;
  679.             long hours = millis / (1000 * 60 * 60);
  680.             millis -= hours * 1000 * 60 * 60;
  681.             long minutes = millis / (1000 * 60);
  682.             millis -= minutes * 1000 * 60;
  683.             long seconds = millis / 1000;
  684.  
  685.             long lardsMade = experienceGained/480;
  686.             int lardtolevel = skills.getExpToNextLevel(skills.CONSTRUCTION)/480;
  687.             if (showPaint) {
  688.  
  689.                 g2.drawImage(fuserScriptsLogo, 4, 276, null);
  690.                 g2.drawImage(paintBackGround, -1, 328, null);
  691.                 g2.drawImage(userLogo, 9, 347, null);
  692.                 g2.drawImage(closeButton, 426, 345, null);
  693.                 g2.drawImage(Avatar, 448, 345, null);
  694.  
  695.                 g2.setColor(Constants.Transparent);
  696.                 g2.draw(Constants.fuserScriptsLogoRectangle);
  697.                 g2.draw(Constants.closeButtonRectangle);
  698.                 g2.draw(Constants.userLogoRectangle);
  699.  
  700.                 g.setFont(Constants.Font1);
  701.                 g.setColor(Constants.Color1);
  702.                 g.drawString("Current Script Version:", 198, 361);
  703.                 g.setFont(Constants.Font2);
  704.                 g.drawString(""+ver, 337, 361);
  705.                 g.setFont(Constants.Font1);
  706.                 g.drawString("Run Time:", 12, 392);
  707.                 g.setFont(Constants.Font2);
  708.                 g.drawString(hours+":"+minutes+":"+seconds, 77, 392);
  709.                 g.setFont(Constants.Font1);
  710.                 g.drawString("Xp Gained:", 10, 416);
  711.                 g.setFont(Constants.Font2);
  712.                 g.drawString(""+experienceGained, 82, 416);
  713.                 g.setFont(Constants.Font1);
  714.                 g.drawString("Xp Gained/hr:", 10, 446);
  715.                 g.setFont(Constants.Font2);
  716.                 g.drawString(""+expHour, 101, 446);
  717.                 g.setFont(Constants.Font1);
  718.                 g.drawString("Levels Gained:", 11, 470);
  719.                 g.setFont(Constants.Font2);
  720.                 g.drawString(""+lvlsGained, 102, 470);
  721.                 g.setFont(Constants.Font1);
  722.                 g.drawString("Script Status:", 204, 449);
  723.                 g.setFont(Constants.Font2);
  724.                 g.drawString(Status, 287, 449);
  725.                 g.setFont(Constants.Font1);
  726.                 g.drawString("Larders to Level:", 199, 390);
  727.                 g.setFont(Constants.Font2);
  728.                 g.drawString(""+lardtolevel, 300, 390);
  729.                 g.setFont(Constants.Font1);
  730.                 g.drawString("Larders Made:", 201, 414);
  731.                 g.setFont(Constants.Font2);
  732.                 g.drawString(""+lardsMade, 291, 414);
  733.                 g.setFont(Constants.Font1);
  734.                 g.drawString("Message from Dew:", 201, 475);
  735.                 g.setFont(Constants.Font2);
  736.                 g.drawString(messageFromDew, 323, 475);
  737.  
  738.  
  739.             } else {
  740.                 g2.setColor(Constants.Transparent);
  741.                 g2.draw(Constants.openButtonRectangle);
  742.                 g2.drawImage(openButton, 474, 345, null);
  743.             }
  744.  
  745.     }
  746.     @Override
  747.     public void onRepaint(Graphics g) {
  748.         Graphics2D g2 = (Graphics2D) g;
  749.         g2.setRenderingHints(renderHints);
  750.         mainPaint(g2);
  751.         mousePaint.Draw(g2);
  752.     }
  753.  
  754.     private Image getImage(final String url) {
  755.         try {
  756.             log("Image Loaded: "+url);
  757.             return ImageIO.read(new URL(url));
  758.  
  759.         } catch (final IOException e) {
  760.             log("Image NOT Loaded: "+url);
  761.             return null;
  762.         }
  763.     }
  764.     // </editor-fold>
  765.  
  766.     // <editor-fold defaultstate="collapsed" desc="mouseClicked">
  767.     @Override
  768.     public void mouseClicked(MouseEvent mouseEvent) {
  769.         Point mousePoint = mouseEvent.getPoint();
  770.         if (Constants.fuserScriptsLogoRectangle.contains(mousePoint)
  771.                 && showPaint) {
  772.             sendToURL("http://fuserscripts.cz.cc/community/");
  773.         } else if (Constants.userLogoRectangle.contains(mousePoint)
  774.                 && showPaint) {
  775.             log("Currently, the Thread is not active! Please wait until I update this.");
  776.             // sendToURL("http://fuserscripts.cz.cc/community/index.php?/topic/76-fuserpaint-skeleton/");
  777.         } else if (Constants.avatarRectangle.contains(mousePoint) && showPaint) {
  778.             sendToURL("http://fuserscripts.cz.cc/community/index.php?/user/19-dew/");
  779.         } else if (Constants.closeButtonRectangle.contains(mousePoint)
  780.                 && showPaint) {
  781.             showPaint = false;
  782.         } else if (Constants.openButtonRectangle.contains(mousePoint)
  783.                 && !showPaint) {
  784.             showPaint = true;
  785.         }
  786.     }
  787.  
  788.     public void sendToURL(String url) {
  789.         try {
  790.             java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
  791.         } catch (Exception exception) {
  792.             log("[ERROR]SendToURL: " + exception.getLocalizedMessage());
  793.         }
  794.     }
  795.  
  796.     @Override
  797.     public void mouseEntered(MouseEvent e) {
  798.     }
  799.  
  800.     @Override
  801.     public void mouseExited(MouseEvent e) {
  802.     }
  803.  
  804.     @Override
  805.     public void mousePressed(MouseEvent e) {
  806.     }
  807.  
  808.     @Override
  809.     public void mouseReleased(MouseEvent e) {
  810.     }
  811.     // </editor-fold>
  812.  
  813.     /**
  814.      * Official mouse paint. Version 1.00
  815.      *
  816.      * @author ExoCode
  817.      *
  818.      */
  819.     // <editor-fold defaultstate="collapsed" desc="MousePaint">
  820.     public class MousePaint {
  821.  
  822.         public int waveSize = 0;
  823.  
  824.         @SuppressWarnings({"serial"})
  825.         public class mousePathPoint extends Point {
  826.  
  827.             private long finishTime;
  828.             private double lastingTime;
  829.  
  830.             public mousePathPoint(int x, int y, int lastingTime) {
  831.                 super(x, y);
  832.                 this.lastingTime = lastingTime;
  833.                 finishTime = System.currentTimeMillis() + lastingTime;
  834.             }
  835.  
  836.             public boolean isUp() {
  837.                 return System.currentTimeMillis() > finishTime;
  838.             }
  839.         }
  840.  
  841.         public double getRot(int ticks) {
  842.             return (System.currentTimeMillis() % (360 * ticks)) / ticks;
  843.         }
  844.         public LinkedList<mousePathPoint> mousePath = new LinkedList<mousePathPoint>();
  845.  
  846.         public void drawTrail(Graphics g) {
  847.             Graphics2D g2 = (Graphics2D) g;
  848.             g2.setStroke(new BasicStroke(1));
  849.             while (!mousePath.isEmpty() && mousePath.peek().isUp()) {
  850.                 mousePath.remove();
  851.             }
  852.             Point clientCursor = mouse.getLocation();
  853.             mousePathPoint mpp = new mousePathPoint(clientCursor.x,
  854.                     clientCursor.y, 250);
  855.             if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp)) {
  856.                 mousePath.add(mpp);
  857.             }
  858.             mousePathPoint lastPoint = null;
  859.             for (mousePathPoint a : mousePath) {
  860.                 if (lastPoint != null) {
  861.                     long mpt = System.currentTimeMillis()
  862.                             - mouse.getPressTime();
  863.                     if (mouse.getPressTime() == -1 || mpt >= 250) {
  864.                         g2.setColor(Color.GREEN);
  865.                     }
  866.                     if (mpt < 250) {
  867.                         g2.setColor(Color.RED);
  868.                     }
  869.                     g2.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
  870.                 }
  871.                 lastPoint = a;
  872.             }
  873.         }
  874.  
  875.         public void drawMouse(Graphics g) {
  876.             Graphics2D g2 = (Graphics2D) g;
  877.             g2.setRenderingHints(new RenderingHints(
  878.                     RenderingHints.KEY_ANTIALIASING,
  879.                     RenderingHints.VALUE_ANTIALIAS_ON));
  880.             g2.setStroke(new BasicStroke(3));
  881.             g2.setColor(Color.BLACK);
  882.             g2.drawOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13,
  883.                     25, 25);
  884.             g2.setStroke(new BasicStroke(1));
  885.             g2.setColor(new Color(0, 0, 0, 114));
  886.             g2.fillOval(mouse.getLocation().x - 13, mouse.getLocation().y - 13,
  887.                     25, 25);
  888.             Point MouseLocation = mouse.getLocation();
  889.             long mpt = System.currentTimeMillis() - mouse.getPressTime();
  890.             g2.rotate(Math.toRadians(getRot(5)), mouse.getLocation().x,
  891.                     mouse.getLocation().y);
  892.             if (mouse.getPressTime() == -1 || mpt >= 250) {
  893.                 g2.setColor(Color.GREEN);
  894.                 g2.drawLine(MouseLocation.x - 5, MouseLocation.y,
  895.                         MouseLocation.x + 5, MouseLocation.y);
  896.                 g2.drawLine(MouseLocation.x, MouseLocation.y - 5,
  897.                         MouseLocation.x, MouseLocation.y + 5);
  898.             }
  899.             if (mpt < 250) {
  900.                 g2.setColor(Color.RED);
  901.                 g2.drawLine(MouseLocation.x - 5, MouseLocation.y,
  902.                         MouseLocation.x + 5, MouseLocation.y);
  903.                 g2.drawLine(MouseLocation.x, MouseLocation.y - 5,
  904.                         MouseLocation.x, MouseLocation.y + 5);
  905.             }
  906.         }
  907.  
  908.         public void drawWave(Graphics g, Color color) {
  909.             Graphics2D g2 = (Graphics2D) g;
  910.             Point MouseLoc = mouse.getPressLocation();
  911.             long mpt = System.currentTimeMillis() - mouse.getPressTime();
  912.             g2.setRenderingHints(new RenderingHints(
  913.                     RenderingHints.KEY_ANTIALIASING,
  914.                     RenderingHints.VALUE_ANTIALIAS_ON));
  915.             g2.setColor(color);
  916.             if (mpt < 1000) {
  917.                 waveSize = (int) (mpt / 7.5);
  918.             } else {
  919.                 waveSize = 0;
  920.             }
  921.             g2.setStroke(new BasicStroke(3));
  922.             g2.drawOval(MouseLoc.x - (waveSize / 2), MouseLoc.y
  923.                     - (waveSize / 2), waveSize, waveSize);
  924.             g2.drawOval(MouseLoc.x - ((waveSize / 2) / 2), MouseLoc.y
  925.                     - ((waveSize / 2) / 2), waveSize / 2, waveSize / 2);
  926.         }
  927.  
  928.         public void Draw(Graphics g) {
  929.             Graphics2D g2 = (Graphics2D) g;
  930.             g2.setRenderingHints(new RenderingHints(
  931.                     RenderingHints.KEY_ANTIALIASING,
  932.                     RenderingHints.VALUE_ANTIALIAS_ON));
  933.             drawWave(g2, Color.BLACK);
  934.             drawTrail(g2);
  935.             drawMouse(g2);
  936.         }
  937.     }
  938.     // </editor-fold>
  939.  
  940.     //<editor-fold defaultstate="collapsed" desc="Updater">
  941.     private static final String UPDATER_FILE_NAME = "FuserConstruction.java";
  942.     private static final String UPDATER_URL = "http://scripters.powerbot.org/542806/scriptdir/fuserconstruction/FuserConstruction.java";
  943.     private static final String UPDATER_CHECK_URL = "http://scripters.powerbot.org/542806/scriptdir/fuserconstruction/fuserconstructionver.txt";
  944.     private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)");
  945.  
  946.  
  947.     private boolean checkForUpdates() {
  948.         try {
  949.             /* Get the current version from the Script Manifest annotation defined at the top of your script's class */
  950.             double currentVer = ironPickUp.class.getAnnotation(ScriptManifest.class).version();
  951.             double newVer = -1;
  952.             URL url = new URL(UPDATER_URL);
  953.             /* Open a stream to the newest script file hosted on your server */
  954.             BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
  955.             String line, lines = "";
  956.             Matcher m;
  957.             /* Look for the "version = x.x" string in the newer file to figure out the newest version number */
  958.             while ((line = in.readLine()) != null) {
  959.                 lines += line + "\n";
  960.                 if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
  961.                     newVer = Double.parseDouble(m.group(1));
  962.                     break;
  963.                 }
  964.             }
  965.             /* Check if the updater was unable to read the newest version number */
  966.             if (newVer < 0) {
  967.                 in.close();
  968.                 log("Unable to find the new version number. Update failed");
  969.                 return false;
  970.             }
  971.             /* Compare the current version to the newest. */
  972.             if (currentVer == newVer) {
  973.                 in.close();
  974.                 log("You already have the latest version of the script.");
  975.                 return true;
  976.             }
  977.             /* The current version is less than the newest version, so we need to download it */
  978.             log("Update found! Downloading version " + newVer);
  979.             /* Figure out where to save the file */
  980.             String scriptFilePath = Configuration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME;
  981.             PrintWriter out = new PrintWriter(scriptFilePath);
  982.             /* Print the cached lines from the version checking */
  983.             out.print(lines);
  984.             /* Print the rest of the file */
  985.             while ((line = in.readLine()) != null) {
  986.                 out.println(line);
  987.             }
  988.             /* Close the streams */
  989.             out.close();
  990.             in.close();
  991.             log(Color.RED,"Successfully saved " + UPDATER_FILE_NAME + " to " + Configuration.Paths.getScriptsSourcesDirectory());
  992.             log(Color.MAGENTA, "File saved, now all you have to do is go to your RSBot directory, and compile\n the script!");
  993.             log(Color.orange, "Update successful!");
  994.             stopScript();
  995.  
  996.             //log(Color.green, "The new version will appear near the bottom of the script selector.");
  997.             //log(Color.red, "Stop and restart the script to run the newer version.");
  998.             return true;
  999.         } catch (IOException e) {
  1000.             log(e.toString());
  1001.             log("Update failed.");
  1002.         }
  1003.         return false;
  1004.     }
  1005.  
  1006.     private void displayVer() {
  1007.         log("An update is currently Available!");
  1008.         log("Update from "+ver+" to the new version: "+currVer);
  1009.     }
  1010.  
  1011.     public double checkVer() {
  1012.         try {
  1013.             BufferedReader r = new BufferedReader(new InputStreamReader(new URL(UPDATER_CHECK_URL).openStream()));
  1014.             double d = Double.parseDouble(r.readLine());
  1015.             r.close();
  1016.             return d;
  1017.         } catch(Exception e) {
  1018.             log("Error checking for latest version.");
  1019.         }
  1020.         return ver;
  1021.     }
  1022.  
  1023.     //</editor-fold>
  1024.  
  1025.     // <editor-fold defaultstate="collapsed" desc="GUI">
  1026.     public class FuserConstructionGui extends javax.swing.JFrame {
  1027.  
  1028.         private static final long serialVersionUID = 1L;
  1029.  
  1030.         /** Creates new form FuserConstructionGui */
  1031.         public FuserConstructionGui() {
  1032.             initComponents();
  1033.         }
  1034.  
  1035.         @SuppressWarnings("unchecked")
  1036.         // <editor-fold defaultstate="collapsed" desc="Generated Code">
  1037.     private void initComponents() {
  1038.  
  1039.         startscript = new javax.swing.JButton();
  1040.         jLabel2 = new javax.swing.JLabel();
  1041.         jScrollPane1 = new javax.swing.JScrollPane();
  1042.         jTextArea1 = new javax.swing.JTextArea();
  1043.         jLabel1 = new javax.swing.JLabel();
  1044.         donate = new javax.swing.JButton();
  1045.         viewscripts = new javax.swing.JButton();
  1046.         viewthread = new javax.swing.JButton();
  1047.         jProgressBar1 = new javax.swing.JProgressBar();
  1048.         jLabel3 = new javax.swing.JLabel();
  1049.         jLabel4 = new javax.swing.JLabel();
  1050.         checkUpdates = new javax.swing.JCheckBox();
  1051.  
  1052.         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  1053.         setTitle("FuserConstruction Settings");
  1054.         setAlwaysOnTop(true);
  1055.         setName("FuserConstruction Settings"); // NOI18N
  1056.         setResizable(false);
  1057.  
  1058.         startscript.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
  1059.         startscript.setText("Start Button");
  1060.         startscript.addActionListener(new java.awt.event.ActionListener() {
  1061.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1062.                 startscriptActionPerformed(evt);
  1063.             }
  1064.         });
  1065.  
  1066.         jLabel2.setIcon(new javax.swing.JLabel() {
  1067.             public javax.swing.Icon getIcon() {
  1068.                 try {
  1069.                     return new javax.swing.ImageIcon(
  1070.                         new java.net.URL("http://i.imgur.com/lKVgI.png")
  1071.                     );
  1072.                 } catch (java.net.MalformedURLException e) {
  1073.                 }
  1074.                 return null;
  1075.             }
  1076.         }.getIcon());
  1077.  
  1078.         jTextArea1.setColumns(20);
  1079.         jTextArea1.setEditable(false);
  1080.         jTextArea1.setLineWrap(true);
  1081.         jTextArea1.setRows(5);
  1082.         jTextArea1.setText("Features:\nONLY supports Demon Butler\nStart with money, saw, and hammer in inventory, or script will not start!\nStart with the butler following, and make sure you start with the larder on the screen.\n\nThis script, is by far not finished - keep up do date with the completetion progress bar as seen above. - This indicates \"ABOUT\" how much this script is complete, and ready to become flawless, and when this occurs, I will start adding stuff, and the progress bar will change!\nCheck for updates if you get message in the log box! This means that there has been a public update to the script!\nThank you for reading! :)"); // NOI18N
  1083.         jTextArea1.setWrapStyleWord(true);
  1084.         jScrollPane1.setViewportView(jTextArea1);
  1085.  
  1086.         jLabel1.setText("Script Written by: Dew");
  1087.  
  1088.         donate.setText("Donate to Dew");
  1089.         donate.addActionListener(new java.awt.event.ActionListener() {
  1090.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1091.                 donateActionPerformed(evt);
  1092.             }
  1093.         });
  1094.  
  1095.         viewscripts.setText("View FuserScripts");
  1096.         viewscripts.addActionListener(new java.awt.event.ActionListener() {
  1097.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1098.                 viewscriptsActionPerformed(evt);
  1099.             }
  1100.         });
  1101.  
  1102.         viewthread.setText("View my Thread");
  1103.         viewthread.addActionListener(new java.awt.event.ActionListener() {
  1104.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  1105.                 viewthreadActionPerformed(evt);
  1106.             }
  1107.         });
  1108.  
  1109.         jProgressBar1.setForeground(new java.awt.Color(0, 204, 0));
  1110.         jProgressBar1.setValue(50);
  1111.  
  1112.         jLabel3.setText("Completetion Progress:");
  1113.  
  1114.         jLabel4.setIcon(new javax.swing.JLabel() {
  1115.             public javax.swing.Icon getIcon() {
  1116.                 try {
  1117.                     return new javax.swing.ImageIcon(
  1118.                         new java.net.URL("http://i.imgur.com/hHeXN.png")
  1119.                     );
  1120.                 } catch (java.net.MalformedURLException e) {
  1121.                 }
  1122.                 return null;
  1123.             }
  1124.         }.getIcon());
  1125.  
  1126.         checkUpdates.setText("Check for Updates");
  1127.  
  1128.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  1129.         getContentPane().setLayout(layout);
  1130.         layout.setHorizontalGroup(
  1131.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1132.             .addGroup(layout.createSequentialGroup()
  1133.                 .addGap(10, 10, 10)
  1134.                 .addComponent(jLabel2)
  1135.                 .addComponent(checkUpdates, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
  1136.                 .addGap(88, 88, 88)
  1137.                 .addComponent(jLabel4))
  1138.             .addGroup(layout.createSequentialGroup()
  1139.                 .addGap(10, 10, 10)
  1140.                 .addComponent(jLabel1)
  1141.                 .addGap(97, 97, 97)
  1142.                 .addComponent(jLabel3)
  1143.                 .addGap(26, 26, 26)
  1144.                 .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
  1145.             .addGroup(layout.createSequentialGroup()
  1146.                 .addGap(10, 10, 10)
  1147.                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 504, javax.swing.GroupLayout.PREFERRED_SIZE))
  1148.             .addGroup(layout.createSequentialGroup()
  1149.                 .addGap(10, 10, 10)
  1150.                 .addComponent(viewthread, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
  1151.                 .addGap(18, 18, 18)
  1152.                 .addComponent(viewscripts, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
  1153.                 .addGap(18, 18, 18)
  1154.                 .addComponent(donate, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
  1155.             .addGroup(layout.createSequentialGroup()
  1156.                 .addGap(10, 10, 10)
  1157.                 .addComponent(startscript, javax.swing.GroupLayout.PREFERRED_SIZE, 504, javax.swing.GroupLayout.PREFERRED_SIZE))
  1158.         );
  1159.         layout.setVerticalGroup(
  1160.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1161.             .addGroup(layout.createSequentialGroup()
  1162.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1163.                     .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
  1164.                     .addGroup(layout.createSequentialGroup()
  1165.                         .addGap(7, 7, 7)
  1166.                         .addComponent(checkUpdates))
  1167.                     .addComponent(jLabel4))
  1168.                 .addGap(11, 11, 11)
  1169.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1170.                     .addComponent(jLabel1)
  1171.                     .addComponent(jLabel3)
  1172.                     .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  1173.                 .addGap(6, 6, 6)
  1174.                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
  1175.                 .addGap(6, 6, 6)
  1176.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  1177.                     .addComponent(viewthread)
  1178.                     .addComponent(viewscripts)
  1179.                     .addComponent(donate))
  1180.                 .addGap(6, 6, 6)
  1181.                 .addComponent(startscript, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
  1182.         );
  1183.  
  1184.         pack();
  1185.     }// </editor-fold>
  1186.  
  1187.         private void viewthreadActionPerformed(java.awt.event.ActionEvent evt) {
  1188.             log("No thread yet! Just wait :)");
  1189.             //sendToURL("");
  1190.         }
  1191.  
  1192.         private void startscriptActionPerformed(java.awt.event.ActionEvent evt) {
  1193.             setVisible(false);
  1194.             guiIsOpen = false;
  1195.         }
  1196.  
  1197.         private void viewscriptsActionPerformed(java.awt.event.ActionEvent evt) {
  1198.             sendToURL("http://fuserscripts.cz.cc/community/");
  1199.         }
  1200.  
  1201.         private void donateActionPerformed(java.awt.event.ActionEvent evt) {
  1202.             sendToURL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6BSXJFQ25ZSY8");
  1203.         }
  1204.         // Variables declaration - do not modify
  1205.         private javax.swing.JCheckBox checkUpdates;
  1206.         private javax.swing.JButton donate;
  1207.         private javax.swing.JLabel jLabel1;
  1208.         private javax.swing.JLabel jLabel2;
  1209.         private javax.swing.JLabel jLabel3;
  1210.         private javax.swing.JLabel jLabel4;
  1211.         private javax.swing.JProgressBar jProgressBar1;
  1212.         private javax.swing.JScrollPane jScrollPane1;
  1213.         private javax.swing.JTextArea jTextArea1;
  1214.         private javax.swing.JButton startscript;
  1215.         private javax.swing.JButton viewscripts;
  1216.         private javax.swing.JButton viewthread;
  1217.         // End of variables declaration
  1218.     }
  1219.     // </editor-fold>
  1220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement