Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.net.URL;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- import org.rsbot.script.*;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSTilePath;
- import org.rsbot.event.listeners.*;
- @ScriptManifest(authors = { "RoyMastha" }, name = "RockBuster", version = 1.0, description = "In Soviet Russia, rocks fight you!")
- public class RockBuster extends Script implements PaintListener {
- public enum Next {
- GUI, WALKTOCRABS, FIGHTCRAB, BANKOPEN, BANKWITHDRAW, BANKCLOSE, WALKTOCAVE, ENTERCAVE, EXITCAVE, WALKTOMID, REFILLHP, WALKING, INCOMBAT, WALKTOBANK, UNKNOWN
- }
- // IDs
- private int[] RockID = { 1266, 1268 };
- private int[] CrabID = { 1265, 1267 };
- private int[] bankerIDs = { 494, 495 };
- private int[] boothIDs = { 25808 };
- private int airRuneID = 556;
- private int lawRuneID = 563;
- private int teleTabID = 8010;
- private int CaveOutsideID = 5008;
- private int CaveInsideID = 5014;
- // Areas
- private RSArea crabArea = new RSArea(new RSTile(2694, 3707), new RSTile(
- 2719, 3731));
- private RSArea bankArea = new RSArea(new RSTile(2722, 3490), new RSTile(
- 2730, 3493));
- private RSArea teleportArea = new RSArea(new RSTile(2755, 3475),
- new RSTile(2760, 3481));
- private RSArea outsideCaveArea = new RSArea(new RSTile(2725, 3710),
- new RSTile(2730, 3717));
- // Paths
- private RSTile[] teleToBank = { new RSTile(2757, 3478),
- new RSTile(2749, 3478), new RSTile(2743, 3478),
- new RSTile(2740, 3481), new RSTile(2735, 3483),
- new RSTile(2733, 3485), new RSTile(2729, 3485),
- new RSTile(2726, 3487), new RSTile(2725, 3491) };
- private RSTile[] bankToCrabs = { new RSTile(2726, 3492),
- new RSTile(2730, 3486), new RSTile(2735, 3492),
- new RSTile(2740, 3498), new RSTile(2740, 3503),
- new RSTile(2740, 3507), new RSTile(2740, 3513),
- new RSTile(2741, 3519), new RSTile(2741, 3525),
- new RSTile(2739, 3530), new RSTile(2736, 3534),
- new RSTile(2733, 3538), new RSTile(2731, 3542),
- new RSTile(2725, 3542), new RSTile(2719, 3543),
- new RSTile(2715, 3544), new RSTile(2710, 3544),
- new RSTile(2705, 3544), new RSTile(2701, 3543),
- new RSTile(2697, 3544), new RSTile(2691, 3543),
- new RSTile(2686, 3543), new RSTile(2682, 3545),
- new RSTile(2679, 3547), new RSTile(2675, 3550),
- new RSTile(2673, 3556), new RSTile(2664, 3558),
- new RSTile(2661, 3564), new RSTile(2658, 3571),
- new RSTile(2655, 3573), new RSTile(2654, 3579),
- new RSTile(2654, 3586), new RSTile(2653, 3590),
- new RSTile(2653, 3598), new RSTile(2653, 3603),
- new RSTile(2655, 3606), new RSTile(2660, 3613),
- new RSTile(2666, 3618), new RSTile(2672, 3621),
- new RSTile(2674, 3626), new RSTile(2676, 3629),
- new RSTile(2683, 3629), new RSTile(2688, 3630),
- new RSTile(2694, 3634), new RSTile(2696, 3638),
- new RSTile(2700, 3641), new RSTile(2700, 3645),
- new RSTile(2702, 3649), new RSTile(2707, 3653),
- new RSTile(2707, 3659), new RSTile(2704, 3664),
- new RSTile(2701, 3667), new RSTile(2700, 3674),
- new RSTile(2700, 3681), new RSTile(2700, 3686),
- new RSTile(2700, 3692), new RSTile(2700, 3698),
- new RSTile(2702, 3704), new RSTile(2702, 3711),
- new RSTile(2702, 3716) };
- private RSTile[] midToCave = { new RSTile(2707, 3719),
- new RSTile(2713, 3716), new RSTile(2719, 3713),
- new RSTile(2723, 3713), new RSTile(2729, 3713) };
- // GUI Settings
- private boolean useTeleSpell = false;
- private int FoodID = 0;
- private int[] pickUpIDs = { 0 };
- JFrame gui = new JFrame();
- private JPanel jContentPane = null;
- private JLabel jLabel = null;
- private JTextField jTextField = null;
- private JCheckBox jCheckBox = null;
- private JButton jButton = null;
- private JLabel jLabel1 = null;
- private JTextField jTextField1 = null;
- private JLabel jLabel2 = null;
- private JTextField jTextField2 = null;
- private boolean guiDone = false;
- // Paint Stats
- private long startTime = System.currentTimeMillis();
- private long expStarted = 0;
- private int Killed = 0;
- private String Status = "";
- // Other
- private boolean hasDoneReset = false;
- private RSTile MiddleTile = new RSTile(2707, 3719);
- // AntiBan
- private RSTile currentTile = new RSTile(0, 0);
- private long timeCheck = 0;
- public boolean onStart() {
- log("Welcome to Rockbuster by RoyMastha!");
- log("Start the script via the GUI!");
- log("All credits to RoyMastha.");
- log("Latest version: 1.0!");
- log("In next update: Item's pickup, Chat response, Bigger AntiBan and more!");
- initGUI();
- return true;
- }
- @Override
- public int loop() {
- int val = 0;
- switch (getNext()) {
- case GUI:
- val = random(1000, 2000);
- break;
- case WALKING:
- val = random(1000, 2000);
- break;
- case INCOMBAT:
- checkFood();
- antiBan();
- val = random(1500, 2500);
- break;
- case WALKTOCAVE:
- hasDoneReset = false;
- walkPath(midToCave);
- val = random(500, 1300);
- break;
- case FIGHTCRAB:
- fightCrab();
- val = random(1500, 2500);
- break;
- case WALKTOMID:
- walkToMiddleTile();
- val = random(1000, 2000);
- break;
- case ENTERCAVE:
- RSObject cave = objects.getNearest(CaveOutsideID);
- if (cave != null) {
- camera.turnToObject(cave);
- cave.doAction("Enter");
- }
- val = random(1000, 2000);
- break;
- case EXITCAVE:
- RSObject cave1 = objects.getNearest(CaveInsideID);
- if (cave1 != null) {
- camera.turnToObject(cave1);
- cave1.doAction("Enter");
- }
- hasDoneReset = true;
- val = random(1000, 2000);
- break;
- case WALKTOBANK:
- walkPath(teleToBank);
- val = random(300, 1500);
- break;
- case BANKOPEN:
- openBank();
- val = random(1300, 2600);
- break;
- case BANKWITHDRAW:
- withdrawSupplies();
- val = random(1300, 2600);
- break;
- case BANKCLOSE:
- bank.close();
- val = random(1000, 1800);
- break;
- case REFILLHP:
- checkFood();
- val = random(1500, 2500);
- break;
- case WALKTOCRABS:
- walkPath(bankToCrabs);
- val = random(1000, 2000);
- break;
- case UNKNOWN:
- // log.severe("Unknown problem found. Finding workaround...");
- }
- return val;
- }
- public Next getNext() {
- if (!guiDone) {
- Status = "Waiting on GUI.";
- return Next.GUI;
- }
- if (getMyPlayer().isMoving()) {
- Status = "Walking";
- return Next.WALKING;
- } else if (crabArea.contains(getMyPlayer().getLocation())) {
- if (isFightingCrab()) {
- Status = "Fighting";
- return Next.INCOMBAT;
- } else if (needsToReset()) {
- Status = "Resetting";
- return Next.WALKTOCAVE;
- } else if (!isFightingCrab() && !needsToReset() && !walkMiddle()) {
- Status = "Finding Rock Crab";
- return Next.FIGHTCRAB;
- } else if (!isFightingCrab() && walkMiddle()) {
- Status = "Walking back to middle";
- return Next.WALKTOMID;
- }
- } else if (outsideCaveArea.contains(getMyPlayer().getLocation())) {
- if (!hasDoneReset) {
- Status = "Walking to cave";
- return Next.ENTERCAVE;
- } else if (hasDoneReset) {
- Status = "Walking back to middle";
- return Next.WALKTOMID;
- }
- } else if (insideCave()) {
- if (!hasDoneReset) {
- Status = "Exiting cave";
- return Next.EXITCAVE;
- }
- } else if (teleportArea.contains(getMyPlayer().getLocation())) {
- Status = "Walking to bank.";
- return Next.WALKTOBANK;
- } else if (bankArea.contains(getMyPlayer().getLocation())) {
- if (!restocked() && !bank.getInterface().isValid()) {
- Status = "Opening bank.";
- return Next.BANKOPEN;
- } else if (!restocked() && bank.getInterface().isValid()) {
- Status = "Restocking supplies.";
- return Next.BANKWITHDRAW;
- } else if (restocked() && bank.getInterface().isValid()) {
- Status = "Closing bank.";
- return Next.BANKCLOSE;
- } else if (!bank.getInterface().isValid() && restocked()
- && (getMyPlayer().getHPPercent() < 100)) {
- Status = "Refilling HP.";
- return Next.REFILLHP;
- } else if (!bank.getInterface().isValid() && restocked()
- && (getMyPlayer().getHPPercent() == 100)) {
- Status = "Walking back to crabs.";
- return Next.WALKTOCRABS;
- }
- } else if (!bankArea.contains(getMyPlayer().getLocation())
- && !crabArea.contains(getMyPlayer().getLocation())
- && !teleportArea.contains(getMyPlayer().getLocation())) {
- if (!isFightingCrab() && !getMyPlayer().isMoving()) {
- Status = "Walking to middle.";
- return Next.WALKTOMID;
- }
- }
- return Next.UNKNOWN;
- }
- private void withdrawSupplies() {
- if (bank.getInterface().isValid()) {
- bank.depositAll();
- sleep(random(1000, 1800));
- if (!useTeleSpell) {
- RSItem teletab = bank.getItem(teleTabID);
- if (teletab != null) {
- teletab.doAction("Withdraw-1");
- } else {
- log("No teletab found in bank! Logging out.");
- bank.close();
- sleep(random(2000, 3500));
- doLogout();
- }
- } else {
- RSItem rune1 = bank.getItem(airRuneID);
- RSItem rune2 = bank.getItem(lawRuneID);
- if ((rune1 != null) && (rune2 != null)) {
- rune1.doAction("Withdraw-5");
- sleep(random(2000, 3500));
- rune2.doAction("Withdraw-1");
- sleep(random(2000, 3500));
- } else {
- log("Runes for teleport not found! Logging out.");
- bank.close();
- sleep(random(2000, 3500));
- doLogout();
- }
- }
- RSItem food = bank.getItem(FoodID);
- if (food != null) {
- food.doAction("Withdraw-all");
- sleep(random(2000, 3500));
- } else {
- log("Food not found! Logging out.");
- bank.close();
- sleep(random(2000, 3500));
- doLogout();
- }
- }
- }
- private boolean insideCave() {
- RSObject cave = objects.getNearest(CaveInsideID);
- if (cave != null) {
- return true;
- }
- return false;
- }
- private boolean walkMiddle() {
- if (!isFightingCrab()) {
- if ((calc.distanceTo(MiddleTile) >= 12)
- || outsideCaveArea.contains(getMyPlayer().getLocation())) {
- return true;
- }
- }
- return false;
- }
- private void openBank() {
- int i = random(1, 100);
- if (i >= 50) {
- RSNPC banker = npcs.getNearest(bankerIDs);
- if (banker != null) {
- banker.doAction("Bank banker");
- }
- } else {
- RSObject booth = objects.getNearest(boothIDs);
- if (booth != null) {
- booth.doAction("Use-quickly");
- }
- }
- sleep(random(1300, 1600));
- if (!bank.getInterface().isValid()) {
- openBank();
- }
- }
- private boolean needsToReset() {
- if (isByRock()) {
- sleep(1000);
- if (!isFightingCrab() && isByRock()) {
- return true;
- }
- }
- return false;
- }
- private void checkFood() {
- if (getMyPlayer().getHPPercent() <= 25) {
- if (inventory.contains(FoodID)) {
- RSItem food = inventory.getItem(FoodID);
- if (food != null) {
- food.doAction("Eat");
- }
- } else {
- if (!useTeleSpell) {
- if (inventory.contains(teleTabID)) {
- RSItem tele = inventory.getItem(teleTabID);
- tele.doAction("Break");
- } else {
- log.severe("No teletab found! Logging out.");
- if (getMyPlayer().isInCombat()) {
- while (getMyPlayer().isInCombat()) {
- sleep(300);
- }
- }
- doLogout();
- }
- } else {
- if (inventory.contains(airRuneID)
- && inventory.contains(lawRuneID)) {
- interfaces.get(146).getComponent(135).doClick();
- sleep(random(1000, 2000));
- interfaces.get(192).getComponent(51).doClick();
- } else {
- log.severe("No teletab found! Logging out.");
- if (getMyPlayer().isInCombat()) {
- while (getMyPlayer().isInCombat()) {
- sleep(300);
- }
- }
- doLogout();
- }
- }
- }
- }
- }
- private void doLogout() {
- if (!game.isOnLogoutTab()) {
- interfaces.get(548).getComponent(181).doClick();
- sleep(random(1000, 2000));
- doLogout();
- } else {
- interfaces.get(182).getComponent(6).doClick();
- }
- stopScript(true);
- }
- private boolean restocked() {
- if (!useTeleSpell) {
- if (inventory.contains(teleTabID) && inventory.contains(FoodID)
- && inventory.isFull()) {
- return true;
- }
- } else {
- if (inventory.contains(airRuneID) && inventory.contains(lawRuneID)
- && inventory.isFull()) {
- return true;
- }
- }
- return false;
- }
- private void walkToMiddleTile() {
- // new RSTile(2704, 3718)
- int[] x = { 0 };
- int[] y = { 0 };
- int spacing = calc.distanceTo(new RSTile(2704, 3719)) / 3;
- x = new int[spacing + 1];
- y = new int[spacing + 1];
- if (getMyPlayer().getLocation().getX() > 2704) {
- for (int xVal = 0; xVal < spacing; xVal++) {
- if ((getMyPlayer().getLocation().getX() - (xVal * 3)) <= 2704) {
- x[xVal] = getMyPlayer().getLocation().getX();
- } else {
- x[xVal] = getMyPlayer().getLocation().getX() - (xVal * 3);
- }
- }
- x[x.length - 1] = 2704;
- } else {
- for (int xVal = 0; xVal < spacing; xVal++) {
- if ((getMyPlayer().getLocation().getX() + (xVal * 3)) >= 2704) {
- x[xVal] = getMyPlayer().getLocation().getX();
- } else {
- x[xVal] = getMyPlayer().getLocation().getX() + (xVal * 3);
- }
- }
- x[x.length - 1] = 2704;
- }
- if (getMyPlayer().getLocation().getY() > 3719) {
- for (int yVal = 0; yVal < spacing; yVal++) {
- if ((getMyPlayer().getLocation().getY() - (yVal * 3)) <= 3719) {
- y[yVal] = getMyPlayer().getLocation().getY();
- } else {
- y[yVal] = getMyPlayer().getLocation().getY() - (yVal * 3);
- }
- }
- y[y.length - 1] = 3718;
- } else {
- for (int yVal = 0; yVal < spacing; yVal++) {
- if ((getMyPlayer().getLocation().getY() + (yVal * 3)) >= 3719) {
- y[yVal] = getMyPlayer().getLocation().getY();
- } else {
- y[yVal] = getMyPlayer().getLocation().getY() + (yVal * 3);
- }
- }
- y[y.length - 1] = 3719;
- }
- RSTile[] midPath = new RSTile[spacing + 1];
- for (int i = 0; i < spacing + 1; i++) {
- midPath[i] = new RSTile(x[i], y[i]);
- }
- walkPath(midPath);
- }
- private void walkPath(RSTile[] path) {
- if (!walking.isRunEnabled()) {
- int i = random(55, 70);
- if (walking.getEnergy() >= i) {
- walking.setRun(true);
- }
- }
- antiBan();
- RSTilePath h = walking.newTilePath(path);
- h.traverse();
- sleep(500);
- if (calc.distanceTo(path[path.length - 1]) > 2) {
- walkPath(path);
- }
- }
- private boolean isByRock() {
- RSNPC rock = npcs.getNearest(RockID);
- if (rock != null) {
- int x = rock.getLocation().getX();
- int y = rock.getLocation().getY();
- RSTile[] aroundCrab = { new RSTile(x - 1, y + 1),
- new RSTile(x, y + 1), new RSTile(x + 1, y + 1),
- new RSTile(x - 1, y), new RSTile(x, y),
- new RSTile(x + 1, y), new RSTile(x - 1, y - 1),
- new RSTile(x, y - 1), new RSTile(x + 1, y - 1) };
- for (int i = 0; i < aroundCrab.length; i++) {
- if (getMyPlayer().getLocation().getX() == aroundCrab[i].getX()) {
- if (getMyPlayer().getLocation().getY() == aroundCrab[i]
- .getY())
- return true;
- }
- }
- }
- return false;
- }
- private boolean canGetName(RSNPC n) {
- try {
- if (n != null) {
- if (n.getInteracting() != null) {
- if (n.getInteracting().getName().length() > 0) {
- return true;
- }
- }
- }
- return false;
- } catch (NullPointerException ex) {
- return false;
- }
- }
- private boolean isFightingCrab() {
- try {
- if (getMyPlayer().isMoving()) {
- sleep(500);
- return isFightingCrab();
- }
- RSNPC[] allNpcs = npcs.getAll();
- if (allNpcs == null) {
- return false;
- }
- for (int i = 0; i < allNpcs.length; i++) {
- if (allNpcs[i] != null) {
- if ((allNpcs[i].getID() == 1265)
- || (allNpcs[i].getID() == 1267)) {
- if (canGetName(allNpcs[i])) {
- if (allNpcs[i].getInteracting().getName() == getMyPlayer()
- .getName()) {
- return true;
- }
- }
- }
- }
- }
- } catch (NullPointerException ex) {
- log("Exception here...something to do with Interacting detection.");
- return false;
- }
- return false;
- }
- private void fightCrab() {
- if (getMyPlayer().isMoving()) {
- sleep(500);
- fightCrab();
- }
- if (!walking.isRunEnabled()) {
- if (walking.getEnergy() > 35) {
- walking.setRun(true);
- }
- }
- try {
- if (!isFightingCrab()) {
- RSNPC crab = npcs.getNearest(CrabID);
- if (crab != null
- && ((crab.getInteracting() == null) || (crab
- .getInteracting().getName() == getMyPlayer()
- .getName()))
- && crabArea.contains(crab.getLocation())) {
- if (!calc.tileOnScreen(crab.getLocation())) {
- walking.walkTileMM(crab.getLocation());
- }
- ;
- crab.doAction("Attack");
- } else {
- RSNPC rock = npcs.getNearest(RockID);
- if (rock != null && crabArea.contains(rock.getLocation())) {
- if (!calc.tileOnScreen(rock.getLocation())) {
- walking.walkTileMM(rock.getLocation());
- } else {
- walking.walkTileOnScreen(rock.getLocation());
- }
- }
- }
- }
- } catch (NullPointerException ex) {
- fightCrab();
- }
- }
- private void antiBan() {
- if (currentTile == null) {
- currentTile = getMyPlayer().getLocation();
- }
- if (timeCheck == 0) {
- timeCheck = System.currentTimeMillis();
- }
- if (getMyPlayer().getLocation() != currentTile) {
- currentTile = null;
- timeCheck = 0;
- }
- if (getMyPlayer().getLocation() == currentTile) {
- log("hi");
- if ((System.currentTimeMillis() - timeCheck) > 180000) {
- log("You have not been moved for 3 minutes, LOGGING OUT!");
- doLogout();
- }
- }
- }
- private final Color color1 = new Color(0, 0, 0);
- private final Color color2 = new Color(0, 153, 204);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(2);
- private final Font font1 = new Font("Arial", 1, 13);
- private final Font font2 = new Font("Arial", 0, 12);
- @Override
- public void onRepaint(Graphics g1) {
- if (expStarted == 0) {
- expStarted = skills.getCurrentExp(Skills.ATTACK)
- + skills.getCurrentExp(Skills.STRENGTH)
- + skills.getCurrentExp(Skills.DEFENSE)
- + skills.getCurrentExp(Skills.RANGE)
- + skills.getCurrentExp(Skills.MAGIC);
- }
- long expGained = (skills.getCurrentExp(Skills.ATTACK)
- + skills.getCurrentExp(Skills.STRENGTH)
- + skills.getCurrentExp(Skills.DEFENSE)
- + skills.getCurrentExp(Skills.RANGE) + skills
- .getCurrentExp(Skills.MAGIC)) - expStarted;
- Killed = (int) expGained / 200;
- long currentTime = System.currentTimeMillis() - startTime;
- long expPerHour = (expGained * 3600000) / currentTime;
- long hours = currentTime / 3600000;
- currentTime -= hours * 3600000;
- long mins = currentTime / 60000;
- currentTime -= mins * 60000;
- long secs = currentTime / 1000;
- Graphics2D g = (Graphics2D) g1;
- g.drawString("RockBuster (V1.0) ~ By RoyMastha", 14, 40);
- g.setFont(font2);
- g.drawString("Killed: " + Killed, 14, 60);
- g.drawString("Time Running: " + hours + ":" + mins + ":" + secs, 14, 75);
- g.drawString("Exp Gained: " + expGained, 14, 90);
- g.drawString("Exp Per Hour: " + expPerHour, 14, 105);
- g.drawString("Status: " + Status, 14, 120);
- }
- private void initGUI() {
- gui.setSize(191, 200);
- gui.setContentPane(getJContentPane());
- gui.setTitle("RockBuster ~ RoyMastha");
- gui.setVisible(true);
- }
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jLabel1 = new JLabel();
- jLabel1.setBounds(new Rectangle(16, 90, 114, 16));
- jLabel1.setFont(new Font("SansSerif", Font.PLAIN, 12));
- jLabel1.setText("Pickup IDs");
- jLabel = new JLabel();
- jLabel.setBounds(new Rectangle(14, 15, 116, 16));
- jLabel.setFont(new Font("SansSerif", Font.PLAIN, 14));
- jLabel.setText("Food IDs (Auto Eat)");
- jContentPane = new JPanel();
- jContentPane.setLayout(null);
- jContentPane.add(jLabel, null);
- jContentPane.add(getJTextField(), null);
- jContentPane.add(getJCheckBox(), null);
- jContentPane.add(jLabel1, null);
- jContentPane.add(getJTextField1(), null);
- jContentPane.add(getJButton(), null);
- }
- return jContentPane;
- }
- private JTextField getJTextField() {
- if (jTextField == null) {
- jTextField = new JTextField();
- jTextField.setBounds(new Rectangle(14, 33, 142, 20));
- }
- return jTextField;
- }
- private JCheckBox getJCheckBox() {
- if (jCheckBox == null) {
- jCheckBox = new JCheckBox();
- jCheckBox.setBounds(new Rectangle(12, 61, 139, 21));
- jCheckBox.setFont(new Font("SansSerif", Font.PLAIN, 12));
- jCheckBox.setText("Use Teleport Spell");
- }
- return jCheckBox;
- }
- private JTextField getJTextField1() {
- if (jTextField1 == null) {
- jTextField1 = new JTextField();
- jTextField1.setBounds(new Rectangle(15, 108, 138, 20));
- jTextField1.setEnabled(false);
- jTextField1.setText("TO BE IMPLEMENTED");
- }
- return jTextField1;
- }
- private JButton getJButton() {
- if (jButton == null) {
- jButton = new JButton();
- jButton.setBounds(new Rectangle(4, 133, 166, 26));
- jButton.setFont(new Font("SansSerif", Font.BOLD, 12));
- jButton.setText("Start Script!");
- jButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- FoodID = getFoodId(jTextField.getText());
- useTeleSpell = jCheckBox.isSelected();
- gui.setVisible(false);
- gui.dispose();
- guiDone = true;
- }
- });
- }
- return jButton;
- }
- private int getFoodId(String s) {
- int i = 0;
- try {
- i = Integer.parseInt(s);
- } catch (Exception ex) {
- }
- return i;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement