Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lordgmage/d168ed23cb3b9305ff18 to your computer and use it in GitHub Desktop.
Save lordgmage/d168ed23cb3b9305ff18 to your computer and use it in GitHub Desktop.
Cutter
package org.parabot.lord.lordwoodcutting.data;
public class Constants {
public final static int NORMAL = 1276;
public final static int OAKS = 1226;
public final static int WILLIOWS = 298;
public final static int YEWS = 298;
public final static int MAGIC = 298;
public final static int DEPOSIT = 293;
public final static int CLOSE = 233;
}
package org.parabot.lord.lordwoodcutting.data;
public class Variables {
public static int tree;
public static boolean dropping;
public static int getTree() {
return tree;
}
public static boolean getDropping() {
return dropping;
}
}
package org.parabot.lord.lordwoodcutting.main;
import org.parabot.environment.scripts.Category;
import org.parabot.environment.scripts.Script;
import org.parabot.environment.scripts.ScriptManifest;
import org.parabot.environment.scripts.framework.Strategy;
import org.parabot.lord.lordwoodcutting.strategies.Cut;
import org.parabot.lord.lordwoodcutting.strategies.Dropping;
import java.util.ArrayList;
@ScriptManifest(author = "Lord",
category = Category.WOODCUTTING,
description = "Cuts logs and drops them",
name = "Lord Woodcutting Lite",
servers = { "PKHonor" },
version = 1)
public class Core extends Script {
private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
@Override
public boolean onExecute() {
UI GUI = new UI();
GUI.setVisible(true);
while (GUI.isVisible()) {
sleep(20);
}
strategies.add(new Cut());
strategies.add(new Dropping());
provide(strategies);
return true;
}
@Override
public void onFinish() {
super.onFinish();
}
}
package org.parabot.lord.lordwoodcutting.main;
import org.parabot.lord.lordwoodcutting.data.Constants;
import org.parabot.lord.lordwoodcutting.data.Variables;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class UI extends JFrame {
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UI frame = new UI();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public UI() {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setBounds(100, 100, 245, 370);
JPanel contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblLordCooking = new JLabel("Lord Woodcutting");
lblLordCooking.setHorizontalAlignment(SwingConstants.CENTER);
lblLordCooking.setFont(new Font("Arial Black", Font.BOLD, 20));
lblLordCooking.setBounds(0, 0, 229, 93);
contentPane.add(lblLordCooking);
final JComboBox LogSelect = new JComboBox();
LogSelect.setModel(new DefaultComboBoxModel(new String[] {"tree", "Oaks"}));
LogSelect.setBounds(58, 132, 114, 20);
contentPane.add(LogSelect);
JButton Start = new JButton("Start");
Start.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String selection = (String) LogSelect.getModel().getSelectedItem();
switch (selection) {
case "Tree":
Variables.tree = Constants.NORMAL;
break;
case "Oaks":
Variables.tree = Constants.OAKS;
break;
default:
System.out.println("Something wrong as happened please contact the script writers.");
break;
}
setVisible(false);
}
});
Start.setBounds(10, 308, 209, 23);
contentPane.add(Start);
}
}
package org.parabot.lord.lordwoodcutting.strategies;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.parabot.environment.scripts.framework.Strategy;
import org.parabot.lord.lordwoodcutting.data.Variables;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
public class Cut implements Strategy {
SceneObject[] TREE;
public boolean activate() {
TREE = SceneObjects.getNearest(Variables.tree);
return
TREE.length > 0 &&
TREE != null
&& TREE[0].distanceTo() < 20
&& Players.getMyPlayer().getAnimation() == -1;
}
public void execute() {
TREE[0].interact(SceneObjects.Option.CHOP_DOWN);
if (Players.getMyPlayer().getAnimation() != -1){
Time.sleep(new SleepCondition() {
@Override
public boolean isValid() {
return Players.getMyPlayer().getAnimation() == -1;
}
},1000);
}
}
}
package org.parabot.lord.lordwoodcutting.strategies;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.input.Keyboard;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.parabot.environment.scripts.framework.Strategy;
import org.parabot.lord.lordwoodcutting.data.Variables;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players;
public class Dropping implements Strategy{
@Override
public boolean activate() {
return Inventory.isFull() && Players.getMyPlayer().getAnimation() == -1 && Variables.dropping;
}
@Override
public void execute() {
Keyboard.getInstance().sendKeys("::empty");
Time.sleep(500);
Time.sleep(new SleepCondition() {
@Override
public boolean isValid() {
return Inventory.isEmpty();
}
},2000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment