Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Version 1.2
- /**
- * Fixed depositing error
- */
- // Version 1.1
- /**
- * Fixed the messed up ids
- * Fixed some banking errors and waiting methods
- */
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.BufferedImage;
- import java.io.*;
- import java.net.*;
- import java.text.DecimalFormat;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import com.rarebot.event.events.MessageEvent;
- import com.rarebot.event.listeners.MessageListener;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.methods.Game.Tab;
- import com.rarebot.script.methods.Skills;
- import com.rarebot.script.wrappers.RSObject;
- import com.rarebot.script.wrappers.RSPlayer;
- import com.rarebot.script.wrappers.RSTile;
- import com.rarebot.script.wrappers.RSWeb;
- @ScriptManifest(authors = { "MegaAlgos" }, version = 1.1, keywords = ("Smithing"), description = "Smithing and smelting needs", name = "MegaBlacksmith")
- public class MegaBlacksmith extends Script implements PaintListener, MessageListener,MouseListener {
- // Script Info for paint and proggies...
- public double getVersion() {
- return (1.1);
- }
- public String getName() {
- return ("MegaBlacksmith");
- }
- public String getAuthor() {
- return ("MegaAlgos");
- }
- RSTile b;
- RSTile m;
- int o, o2, oCount, o2Count, bar, cI, barLeft, counter, iCount,
- sXP, cXP, sLVL, cLVL;
- double work = 0, hXP, TTNL;
- boolean smelt = false, start = false, scroll = false, safe = false,
- hidePaint = false, timedOut;
- Point mP;
- String pName, whatToDo, status;
- long startTime;
- Image arrow = null;
- Rectangle r;
- public boolean onStart() {
- log("MegaBlacksmith, for all your smelting and smithing needs");
- java.awt.EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- new MegaGUI().setVisible(true);
- }
- });
- if (getOVersion() != getVersion()) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- new VersionGUI().setVisible(true);
- }
- });
- }
- try {
- arrow = ImageIO.read(new URL("http://megascripts.comyr.com/Arrow.png").openStream());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- while (!start) {
- sleep(1000);
- }
- mouse.setSpeed(6);
- startTime = System.currentTimeMillis();
- return true;
- }
- // Script's graphics
- public void onRepaint(Graphics g) {
- long runTime = System.currentTimeMillis() - startTime;
- long TotalSecs = runTime / 1000;
- long TotalMins = TotalSecs / 60;
- long TotalHours = TotalMins / 60;
- int seconds = (int) TotalSecs % 60;
- int minutes = (int) TotalMins % 60;
- int hours = (int) TotalHours % 60;
- StringBuilder b = new StringBuilder();
- if (hours < 10)
- b.append('0');
- b.append(hours);
- b.append(':');
- if (minutes < 10)
- b.append('0');
- b.append(minutes);
- b.append(':');
- if (seconds < 10)
- b.append('0');
- b.append(seconds);
- if (start) {
- work = iCount / (minutes + hours * 60 + seconds / 60f) * 60f;
- if (minutes == 30 && seconds == 1 || minutes == 0 && seconds == 30
- && game.isLoggedIn()) {
- String fS = File.separator;
- String path = null;
- File directory;
- try {
- path = new File(".").getCanonicalPath();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- directory = new File(path + fS + getName() + " " + getVersion());
- if (!directory.exists()) {
- directory.mkdirs();
- log("Made the directory for proggies");
- }
- BufferedImage img = new BufferedImage(184, 242,
- BufferedImage.TYPE_INT_RGB);
- File file = new File(directory + fS + "MegaBlacksmith " + counter
- + ".gif");
- g = img.getGraphics();
- g.setColor(new Color(153, 0, 0));
- g.fill3DRect(0, 0, 184, 242, true);
- int w = 0;
- int z = 0;
- g.setColor(Color.black);
- g.drawString(getName() + " " + getVersion(), w, z += 20);
- g.setFont(new Font("Verdana", 0, 12));
- g.drawString("Ran for: " + b.toString(), w += 20, z += 27);
- g.drawString("Made: " + iCount + " " + pName, w, z += 19);
- g.drawString("Making: " + roundToTenth(work) + " " + pName +"/hour.", w,
- z += 19);
- g.drawString("Gained: " + (cXP - sXP) + " xp", w, z += 19);
- g.drawString("Gaining: " + hXP + " an hour", w, z += 19);
- g.drawString("LVLs gained: " + (cLVL - sLVL), w, z += 19);
- g.drawString("Current LVL: " + cLVL , w, z += 19);
- try {
- ImageIO.write(img, "gif", file);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- log("Sent a proggy image to the MegaBlacksmith folder in program files folder...");
- counter++;
- sleep(2000);
- }
- }
- if (game.isLoggedIn()) {
- if (sXP == 0 && sLVL == 0) {
- sXP = skills.getCurrentExp(Skills.SMITHING);
- sLVL = skills.getCurrentLevel(Skills.SMITHING);
- }
- cXP = skills.getCurrentExp(Skills.SMITHING);;
- cLVL = skills.getCurrentLevel(Skills.SMITHING);
- hXP = (cXP - sXP) / (minutes + hours * 60 + seconds / 60f) * 60f;
- if ((cXP - sXP) != 0) {
- TTNL = skills.getExpToNextLevel(Skills.SMITHING) / ((cXP - sXP) / (minutes + hours * 60 + seconds / 60f));
- }
- if (arrow != null) {
- g.drawImage(arrow, mouse.getLocation().x - 9, mouse.getLocation().y - 2, null);
- }
- if (!hidePaint) {
- g.setColor(new Color(153, 0, 0, 225));
- g.fillRoundRect(551, 217, 184, 242, 16, 16);
- g.setColor(new Color(102, 102, 102));
- r = new Rectangle(596, 415, 88, 36);
- g.fillRect(596, 415, 88, 36);
- g.setFont(new Font("Verdana", 1, 16));
- g.setColor(new Color(167, 91, 3));
- g.drawString(getName() + " " + getVersion(), 555, 251);
- g.setColor(Color.black);
- g.setFont(new Font("Verdana", 1, 18));
- g.drawString("Hide", 611, 443);
- int x = 550;
- int y = 254;
- g.setFont(new Font("Verdana", 0, 12));
- g.drawString("Ran for: " + b.toString(), x, y += 23);
- g.drawString("Made: " + iCount + " " + pName, x, y += 15);
- g.drawString("Making: " + addCommas((int)roundToTenth(work), false) + " " + pName +"/hour.", x,
- y += 15);
- g.drawString("Gained: " + addCommas((cXP - sXP), false) + " xp", x, y += 15);
- g.drawString("Gaining: " + addCommas((int)roundToTenth(hXP), false) + " an hour", x, y += 15);
- g.drawString("LVLs gained: " + (cLVL - sLVL), x, y += 15);
- g.drawString("Current LVL: " + cLVL , x, y += 15);
- g.drawString("Time till n/lvl: " + roundToTenth(TTNL) + " min(s)", x, y += 15);
- g.setFont(new Font("Verdana", 0, 10));
- g.drawString("Status: " + status, x, y += 15);
- } else {
- g.setColor(new Color(102, 102, 102, 175));
- r = new Rectangle(596, 415, 88, 36);
- g.fillRect(596, 415, 88, 36);
- g.setColor(Color.white);
- g.setFont(new Font("Verdana", 1, 18));
- g.drawString("Show", 611, 443);
- }
- }
- }
- @Override
- public int loop() {
- int c = 0;
- if (whatToDo == "Smelt") {
- if (smelt) {
- timedOut = waitFor(bar, 0, oCount, 0, 1500);
- if (inventory.getCount(bar) == oCount || timedOut) {
- smelt = false;
- return 50;
- }
- c++;
- if (c > inventory.getCount()) {
- smelt = false;
- return 50;
- }
- return antiBan();
- }
- if (o2 > 0) {
- sleep(500);
- if (inventory.getCount(o) == oCount
- && inventory.getCount(o2) == o2Count) {
- if (atSmith()) {
- smith();
- } else {
- walkToSmith();
- }
- } else {
- if (atBank()) {
- depositAndGetItems();
- } else {
- walkToBank();
- }
- }
- } else {
- sleep(500);
- if (inventory.getCount(o) == oCount) {
- if (atSmith()) {
- smith();
- } else {
- walkToSmith();
- }
- } else {
- if (atBank()) {
- depositAndGetItems();
- } else {
- walkToBank();
- }
- }
- }
- } else if (whatToDo == "Smith") {
- if (smelt) {
- timedOut = !waitForInvChange(bar, 3500);
- if (inventory.getCount(bar) == barLeft || timedOut) {
- smelt = false;
- return 50;
- }
- }
- if (inventory.getCount(bar) > barLeft) {
- if (atSmith()) {
- smith();
- } else {
- walkToSmith();
- }
- } else {
- if (atBank()) {
- depositAndGetItems();
- } else {
- walkToBank();
- }
- }
- }
- return random(300, 500);
- }
- public boolean smithing() {
- status = "Smithing";
- int iCount = inventory.getCount(bar);
- sleep(3000);
- if (inventory.getCount(bar) == iCount) {
- safe = true;
- return true;
- }
- return false;
- }
- public void smith() {
- status = "Smithing";
- int counter = 0;
- if (whatToDo == "Smelt") {
- RSObject furnace = objects.getNearest(11666);
- if (furnace != null && getMyPlayer().getAnimation() == -1
- && getMyPlayer().isIdle()) {
- if (clickObject(furnace, "Smelt")) {
- sleep(1500);
- if (interfaces.get(916).isValid()) {
- mouse.click(mP, 10, 10, true);
- smelt = true;
- sleep(100);
- antiBan();
- }
- return;
- }
- }
- } else {
- RSObject anvil = objects.getNearest(2783);
- if (anvil != null && getMyPlayer().getAnimation() == -1
- && getMyPlayer().isIdle()) {
- if (interfaces.get(300).isValid()) {
- if (interfaces.clickComponent(interfaces.getComponent(300, cI), "Make all")) {
- smelt = true;
- sleep(100);
- }
- return;
- }
- if (clickObject(anvil, "Smith")) {
- while (!interfaces.get(300).isValid()) {
- sleep(500);
- counter++;
- if(counter > 3) {
- anvil.doClick();
- break;
- }
- }
- if (interfaces.get(300).isValid()) {
- if (cI > 185 && interfaces.getComponent(300, 16).getComponents()[1].getAbsoluteY() < 140) {
- mouse.move(interfaces.getComponent(300, 16).getComponents()[1].getPoint());
- mouse.drag(interfaces.getComponent(300, 16).getComponents()[1].getPoint().x,
- interfaces.getComponent(300, 16).getComponents()[1].getPoint().y + 69);
- }
- if (interfaces.clickComponent(interfaces.getComponent(300, cI), "Make all")) {
- smelt = true;
- sleep(100);
- }
- }
- }
- }
- }
- }
- public boolean atSmith() {
- if (calc.tileOnScreen(m)) {
- return true;
- }
- return false;
- }
- public boolean atBank() {
- if (calc.tileOnScreen(b)) {
- return true;
- }
- return false;
- }
- // Walks to bank
- public boolean walkToBank() {
- status = "Walking to bank";
- RSWeb walkWeb = web.getWeb(b);
- if (walkWeb != null) {
- if (getMyPlayer().isMoving() && !walkWeb.finished()) {
- if (calc.distanceTo(walking.getDestination()) < 10) {
- walkWeb.step();
- return true;
- } else {
- sleep(250);
- return true;
- }
- }
- walkWeb.step();
- }
- return true;
- }
- // Walks to operator
- public boolean walkToSmith() {
- status = "Walking to smithing area";
- if (whatToDo.contains("Smelt")) {
- RSWeb walkWeb = web.getWeb(m);
- if (walkWeb != null) {
- if (getMyPlayer().isMoving() && !walkWeb.finished()) {
- if (calc.distanceTo(walking.getDestination()) < 10) {
- walkWeb.step();
- return true;
- } else {
- sleep(250);
- return true;
- }
- }
- walkWeb.step();
- }
- } else {
- if (getMyPlayer().isMoving()) {
- return true;
- }
- mouse.click(calc.tileToMinimap(m).x + 5, calc.tileToMinimap(m).y, 0, 0, true);
- }
- return true;
- }
- public boolean depositAndGetItems() {
- status = "Depositing and getting items";
- int counter = 0;
- if (bank.open()) {
- while (!bank.isOpen()) {
- sleep(500);
- counter++;
- if (counter > 5) {
- bank.open();
- counter = 0;
- }
- }
- }
- if (bank.isOpen()) {
- if (inventory.getCount() > 0) {
- bank.depositAll();
- sleep(500);
- }
- if (whatToDo == "Smelt") {
- if (bank.withdraw(o, oCount)) {
- sleep(250);
- }
- if (o2 > 0) {
- if (bank.withdraw(o2, 0)) {
- sleep(250);
- }
- }
- if (!waitFor(o, o2, oCount, o2Count, 1500)) {
- log("Out of ores stopping script");
- stopScript();
- return false;
- }
- } else {
- if (bank.withdraw(bar, 28)) {
- sleep(500);
- }
- if (!waitFor(bar, 0, 28, 0, 2500)) {
- log("Out of bars stopping script");
- stopScript();
- return false;
- }
- }
- } else {
- return false;
- }
- return true;
- }
- // Waits for the item to show up in inventory
- public boolean waitFor(int item, int item2, int itemC, int itemC2, int timer) {
- for (int w = 0; w < timer; w++) {
- if (item2 != 0) {
- if(inventory.getCount(item) == itemC &&
- inventory.getCount(item2) == itemC2) {
- return true;
- }
- } else {
- if (inventory.getCount(item) == itemC) {
- return true;
- }
- }
- sleep(1);
- }
- return false;
- }
- public boolean waitForInvChange(int item, int timer) {
- int count = inventory.getCount(item);
- for (int w = 0; w < timer; w++) {
- if (inventory.getCount(item) != count) {
- return true;
- }
- if(random(0,100000) == 500) {
- antiBan();
- }
- sleep(1);
- }
- return false;
- }
- public boolean clickObject(RSObject c, String action) {
- try {
- while (getMyPlayer().isMoving()) {
- sleep(50);
- }
- Point screenLoc = calc.tileToScreen(c.getLocation());
- mouse.move(screenLoc, 5, 5);
- String[] items = menu.getActions();
- if (items.length <= 1) {
- return false;
- }
- if (items[0].toLowerCase().contains(action.toLowerCase())) {
- mouse.click(true);
- return true;
- } else {
- mouse.click(false);
- return menu.doAction(action);
- }
- } catch (NullPointerException e) {
- }
- return true;
- }
- // Rounds a double to the nearest tenth
- public double roundToTenth(double d) {
- DecimalFormat twoDForm = new DecimalFormat("#.#");
- twoDForm = new DecimalFormat("#.#");
- return Double.valueOf(twoDForm.format(d));
- }
- public String addCommas(int d, boolean money) {
- DecimalFormat twoDForm = new DecimalFormat("###,###");
- if(money) {
- twoDForm = new DecimalFormat("$###,###");
- return twoDForm.format(d);
- }
- return twoDForm.format(d);
- }
- // Checks for the recent version
- public double getOVersion() {
- try {
- URL url = new URL("http://megascripts.comyr.com/MegaBlacksmith/Version");
- BufferedReader br = new BufferedReader(new InputStreamReader(
- new BufferedInputStream(url.openConnection()
- .getInputStream())));
- double ver = Double.parseDouble(br.readLine().trim());
- br.close();
- return ver;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- public int antiBan() {
- Point m;
- int x = random(0, 750);
- int y = random(0, 500);
- int xx = random(710, 554);
- int yy = random(444, 230);
- int screenx = random(1, 510);
- int screeny = random(1, 450);
- int gamble = random(0, 22);
- final long start = System.currentTimeMillis();
- final RSPlayer myPlayer = getMyPlayer();
- int anim = -1;
- while (System.currentTimeMillis() - start > 2000) {
- if ((anim = myPlayer.getAnimation()) != -1) {
- break;
- }
- sleep(15);
- }
- switch (gamble) {
- case 1:
- break;
- case 2:
- mouse.move(x, y);
- while (System.currentTimeMillis() - start > 2000) {
- if ((anim = myPlayer.getAnimation()) != -1) {
- break;
- }
- }
- break;
- case 3:
- game.openTab(Tab.INVENTORY);
- break;
- case 4:
- if (getMyPlayer().isMoving()) {
- break;
- }
- case 5:
- mouse.move(x, y);
- int checkTime = 0;
- long lastCheck = 0;
- if (System.currentTimeMillis() - lastCheck >= checkTime) {
- lastCheck = System.currentTimeMillis();
- checkTime = random(60000, 180000);
- break;
- }
- case 6:
- if (game.getTab() != Tab.STATS) {
- game.openTab(Tab.STATS);
- mouse.move(xx, yy);
- sleep(1500,3000);
- game.openTab(Tab.INVENTORY);
- break;
- }
- case 8:
- mouse.move(screenx, screeny);
- break;
- case 9:
- mouse.move(screenx, screeny);
- break;
- case 10:
- game.openTab(game.getRandomTab());
- break;
- case 11:
- mouse.move(x, y);
- break;
- case 13:
- mouse.move(x, y);
- break;
- case 12:
- mouse.move(x, y);
- break;
- case 14:
- m = mouse.getLocation();
- mouse.move(m, 20, 20);
- break;
- case 15:
- m = mouse.getLocation();
- mouse.move(m, 20, 20);
- break;
- case 16:
- m = mouse.getLocation();
- mouse.move(m, 20, 20);
- break;
- case 17:
- m = mouse.getLocation();
- mouse.move(m, 20, 20);
- break;
- case 19:
- mouse.move(x, y);
- break;
- case 20:
- mouse.move(x, y);
- break;
- case 21:
- mouse.move(x, y);
- break;
- }
- return 100;
- }
- // JButton startButton;
- // JComboBox whereandwhat;
- // JLabel text;
- // JLabel text2;
- // String[] list = { "Smelt", "Smith"};
- // String[] list2 = { "Bronze", "Iron", "Steel" };
- public class MegaGUI extends JFrame implements ItemListener, ActionListener {
- /**
- * Initialize the contents of the
- */
- JLabel text;
- JLabel lblWhatItem;
- JLabel lblWhatBar;
- JComboBox comboBox;
- JComboBox comboBox_1;
- JComboBox comboBox_2;
- JButton btnStart;
- public MegaGUI() {
- setTitle("MegaBlacksmith");
- setSize(350, 239);
- setLocationRelativeTo(null);
- getContentPane().setLayout(null);
- text = new JLabel("Smelt or Smith?");
- text.setBounds(25, 11, 91, 20);
- getContentPane().add(text);
- comboBox = new JComboBox();
- comboBox.addItemListener((ItemListener) this);
- comboBox.setModel(new DefaultComboBoxModel(new String[] { "Smelt",
- "Smith" }));
- comboBox.setMaximumRowCount(2);
- comboBox.setBounds(122, 11, 73, 20);
- getContentPane().add(comboBox);
- lblWhatBar = new JLabel("What bar?");
- lblWhatBar.setBounds(25, 56, 73, 14);
- getContentPane().add(lblWhatBar);
- comboBox_1 = new JComboBox();
- comboBox_1.setModel(new DefaultComboBoxModel(new String[] {
- "Bronze", "Iron", "Silver", "Steel", "Gold", "Mithril", "Adamant", "Rune" }));
- comboBox_1.setBounds(122, 53, 73, 20);
- getContentPane().add(comboBox_1);
- btnStart = new JButton("Start");
- btnStart.setBounds(122, 145, 89, 23);
- btnStart.addActionListener(this);
- getContentPane().add(btnStart);
- lblWhatItem = new JLabel("What item?");
- lblWhatItem.setBounds(25, 100, 73, 14);
- getContentPane().add(lblWhatItem);
- lblWhatItem.setVisible(false);
- comboBox_2 = new JComboBox();
- comboBox_2.setModel(new DefaultComboBoxModel(new String[] {
- "Dagger", "Hatchet", "Mace", "Bolts", "Med helm",
- "Dart tips", "Sword", "Nails", "Arrow tips",
- "Scimitar", "Limbs", "Longsword", "Throwing knives",
- "Full helm", "Square shield", "Warhammer", "Battleaxe",
- "Chainbody", "Kiteshield", "Claws", "2h sword",
- "Platelegs", "Plateskirt", "Platebody" }));
- comboBox_2.setBounds(122, 97, 95, 20);
- getContentPane().add(comboBox_2);
- comboBox_2.setVisible(false);
- }
- public void itemStateChanged(ItemEvent e) {
- if (e.getItem().equals("Smith")) {
- comboBox_1.setModel(new DefaultComboBoxModel(new String[] {
- "Bronze", "Iron", "Steel", "Mithril", "Adamant", "Rune" }));
- lblWhatItem.setVisible(true);
- comboBox_2.setVisible(true);
- } else {
- comboBox_1.setModel(new DefaultComboBoxModel(new String[] {
- "Bronze", "Iron", "Silver", "Steel", "Gold", "Mithril", "Adamant", "Rune" }));
- lblWhatItem.setVisible(false);
- comboBox_2.setVisible(false);
- }
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().contains("Start")) {
- String doingString = comboBox.getSelectedItem().toString();
- String barString = comboBox_1.getSelectedItem().toString();
- String itemString = comboBox_2.getSelectedItem().toString();
- if (doingString.equals("Smelt")) {
- b = new RSTile(3270, 3168);
- m = new RSTile(3276, 3186);
- whatToDo = "Smelt";
- pName = barString;
- if (barString.equals("Bronze")) {
- o = 436;
- o2 = 438;
- oCount = 14;
- o2Count = 14;
- mP = new Point(260, 425);
- bar = 2349;
- }
- if (barString.equals("Iron")) {
- o = 440;
- oCount = 28;
- mP = new Point(260, 425);
- bar = 2351;
- }
- if (barString.equals("Silver")) {
- o = 442;
- oCount = 28;
- mP = new Point(260, 425);
- bar = 2355;
- }
- if (barString.equals("Steel")) {
- o = 440;
- o2 = 453;
- oCount = 9;
- o2Count = 19;
- mP = new Point(290, 425);
- bar = 2353;
- }
- if (barString.equals("Gold")) {
- o = 444;
- oCount = 28;
- mP = new Point(260, 425);
- bar = 2357;
- }
- if (barString.equals("Mithril")) {
- o = 447;
- o2 = 453;
- oCount = 5;
- o2Count = 23;
- mP = new Point(260, 425);
- bar = 2359;
- }
- if (barString.equals("Adamant")) {
- o = 449;
- o2 = 453;
- oCount = 5;
- o2Count = 23;
- mP = new Point(260, 425);
- bar = 2361;
- }
- if (barString.equals("Rune")) {
- o = 451;
- o2 = 453;
- oCount = 3;
- o2Count = 25;
- mP = new Point(260, 425);
- bar = 2363;
- }
- log("Making " + pName + " bars");
- } else {
- b = new RSTile(3187, 3435);
- m = new RSTile(3187, 3426);
- whatToDo = "Smith";
- if (barString.equals("Bronze")) {
- log("Using bronze bars");
- bar = 2349;
- }
- if (barString.equals("Iron")) {
- log("Using iron bars");
- bar = 2351;
- }
- if (barString.equals("Steel")) {
- log("Using steel bars");
- bar = 2353;
- }
- if (barString.equals("Mithril")) {
- log("Using mithril bars");
- bar = 2359;
- }
- if (barString.equals("Adamant")) {
- log("Using adamant bars");
- bar = 2361;
- }
- if (barString.equals("Rune")) {
- log("Using rune bars");
- bar = 2363;
- }
- if (itemString.contains("Dagger")) {
- cI = 21;
- barLeft = 0;
- }
- if (itemString.contains("Hatchet")) {
- cI = 27;
- barLeft = 0;
- }
- if (itemString.contains("Mace")) {
- cI = 35;
- barLeft = 0;
- }
- if (itemString.contains("Bolts")) {
- cI = 51;
- barLeft = 0;
- }
- if (itemString.contains("Med helm")) {
- cI = 43;
- barLeft = 0;
- }
- if (itemString.contains("Dart tips")) {
- cI = 67;
- barLeft = 0;
- }
- if (itemString.contains("Sword")) {
- cI = 59;
- barLeft = 0;
- }
- if (itemString.contains("Nails")) {
- cI = 21;
- barLeft = 0;
- }
- if (itemString.contains("Scimitar")) {
- cI = 117;
- barLeft = 0;
- }
- if (itemString.contains("Arrow tips")) {
- cI = 107;
- barLeft = 0;
- }
- if (itemString.contains("Limbs")) {
- cI = 125;
- barLeft = 0;
- }
- if (itemString.contains("Longsword")) {
- cI = 133;
- barLeft = 0;
- }
- if (itemString.contains("Throwing knives")) {
- cI = 141;
- barLeft = 0;
- }
- if (itemString.contains("Full helm")) {
- cI = 149;
- barLeft = 0;
- }
- if (itemString.contains("Square shield")) {
- cI = 157;
- barLeft = 0;
- }
- if (itemString.contains("Claws")) {
- cI = 213;
- barLeft = 0;
- }
- if (itemString.contains("Warhammer")) {
- cI = 181;
- barLeft = 1;
- }
- if (itemString.contains("Battleaxe")) {
- cI = 189;
- barLeft = 1;
- }
- if (itemString.contains("Chainbody")) {
- cI = 197;
- barLeft = 1;
- }
- if (itemString.contains("2h sword")) {
- cI = 221;
- barLeft = 1;
- }
- if (itemString.contains("Plateskirt")) {
- cI = 229;
- barLeft = 1;
- }
- if (itemString.contains("Platelegs")) {
- cI = 237;
- barLeft = 1;
- }
- if (itemString.contains("Kiteshield")) {
- cI = 205;
- barLeft = 1;
- }
- if (itemString.contains("Platebody")) {
- cI = 245;
- scroll = true;
- barLeft = 3;
- }
- pName = itemString;
- log("Making " + pName + "s");
- }
- dispose();
- setVisible(false);
- start = true;
- }
- }
- }
- JButton oB;
- JButton gN;
- JLabel oL;
- public class VersionGUI extends JFrame implements ActionListener {
- public VersionGUI() {
- setTitle("OUTDATED");
- oB = new JButton("Okay");
- oL = new JLabel("OUTDATED");
- gN = new JButton("Get new version");
- setLayout(null);
- setResizable(false);
- setSize(150, 185);
- setLocationRelativeTo(null);
- oB.setBounds(20, 35, 65, 25);
- gN.setBounds(20, 85, 115, 25);
- oB.addActionListener(this);
- gN.addActionListener(this);
- oL.setBounds(20, 5, 182, 21);
- add(oL);
- add(gN);
- add(oB);
- setVisible(true);
- }
- public void getNewVersion() {
- File directory = getCacheDirectory();
- File newDirectory = new File(new File(new File(
- directory.getParent()).getParent()).getParent()
- + File.separator
- + "Scripts"
- + File.separator
- + "Sources"
- + File.separator + "MegaBlacksmith.java");
- BufferedInputStream in;
- try {
- in = new BufferedInputStream(
- new URL(
- "http://megascripts.comyr.com/MegaBlacksmith/MegaBlacksmith.java")
- .openStream());
- FileOutputStream fos = new FileOutputStream(newDirectory);
- BufferedOutputStream bout = new BufferedOutputStream(fos, 1024);
- byte[] data = new byte[1024];
- int x = 0;
- while ((x = in.read(data, 0, 1024)) >= 0) {
- bout.write(data, 0, x);
- }
- bout.close();
- in.close();
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().contains("Okay")) {
- dispose();
- setVisible(false);
- }
- if (e.getActionCommand().contains("Get new version")) {
- getNewVersion();
- sleep(1000);
- oL.setText("Recompile the script");
- repaint();
- stopScript();
- }
- }
- }
- @Override
- public void mouseClicked(MouseEvent arg0) {
- if (r.contains(arg0.getPoint())) {
- if (hidePaint) {
- hidePaint = false;
- } else {
- hidePaint = true;
- }
- }
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void messageReceived(MessageEvent m) {
- if(m.getMessage().contains("You make")) {
- iCount++;
- }
- if(m.getMessage().contains("You smelt")) {
- iCount++;
- }
- if(m.getMessage().contains("You retrieve")) {
- iCount++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment