Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Adam on 5/16/2017.
- */
- import org.osbot.rs07.api.filter.AreaFilter;
- import org.osbot.rs07.api.filter.NameFilter;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.map.constants.Banks;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- @ScriptManifest(name = "WoodCutter", author = "Mechagoober", version = 1.0, info = "", logo = "")
- public class WoodCutter extends Script {
- Banking banking = new Banking();
- State state;
- Area area = new Area(3274, 3436, 3288, 3409);
- Area bank = new Area(3250, 3423, 3257, 3419);
- String tree = new String();
- boolean startScript = false;
- public enum State {
- Bank, Chop, Drop, Walk
- }
- public State getState() {
- switch (state) {
- case Bank:
- if (inventory.isFull()) {
- banking.bank();
- return State.Bank;
- }
- case Walk:
- if (!area.contains(myPlayer()) && !inventory.isFull()) ;
- return State.Walk;
- case Chop:
- if ((area.contains(myPlayer())) && (!inventory.isFull()) && !myPlayer().isAnimating() && area.contains(getObjects().closest("Tree"))) {
- cutTree();
- }
- }
- return State.Chop;
- }
- @Override
- public void onStart() {
- //Code here will execute before the loop is started
- }
- @Override
- public void onExit() {
- //Code here will execute after the script ends
- }
- @Override
- public int onLoop() {
- if (startScript == true) {
- getState();
- }
- return 100; //The amount of time in milliseconds before the loop starts over
- }
- public void walk() {
- if ((inventory.isEmptyExcept("Bronze axe")) && (!area.contains(myPlayer()))) {
- getWalking().webWalk(area);
- }
- }
- public void bank() {
- while (inventory.isFull() && !bank.contains(myPlayer())) {
- getWalking().webWalk(Banks.VARROCK_EAST);
- }
- if (inventory.isFull() && bank.contains(myPlayer())) {
- objects.closest(new NameFilter<>("Bank booth"), new AreaFilter<>(Banks.VARROCK_EAST)).interact("Bank");
- new ConditionalSleep(5000, 1000) {
- @Override
- public boolean condition() throws InterruptedException {
- return objects.closest("Bank booth").interact("Bank");
- }
- }.sleep();
- }
- }
- public void cutTree() {
- if ((area.contains(myPlayer())) && (!inventory.isFull()) && !myPlayer().isAnimating() && area.contains(getObjects().closest("Tree"))) {
- objects.closest(new NameFilter<>("Tree"), new AreaFilter<>(area)).interact("Chop down");
- new AreaFilter<>(area);
- new ConditionalSleep(5000, 600) {
- @Override
- public boolean condition() throws InterruptedException {
- return objects.closest("Tree").interact("Chop down");
- }
- }.sleep();
- }
- }
- @Override
- public void onPaint(Graphics2D g) {
- //This is where you will put your code for paint(s)
- }
- public void createGUI() {
- JFrame frame = new JFrame();
- frame.setSize(600, 400);
- JPanel panel = new JPanel(new GridBagLayout());
- JCheckBox c1 = new JCheckBox("Tree");
- JCheckBox c2 = new JCheckBox("Oak");
- JButton start = new JButton("Start");
- c1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // tree = "Tree";
- }
- });
- c2.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // tree = "Oak";
- }
- });
- start.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- frame.dispose();
- // startScript = true;
- }
- });
- GridBagConstraints c = new GridBagConstraints();
- c.insets = new Insets(10, 10, 10, 10);
- c.gridx = 0;
- c.gridy = 1;
- panel.add(c1, c);
- c.gridx = 0;
- c.gridy = 2;
- panel.add(c2, c);
- c.gridx = 0;
- c.gridy = 3;
- panel.add(start, c);
- frame.add(panel);
- frame.pack();
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement