* Initial Maven

* Fixup

* Close window on script stop

* Extend Varrock mining area

* Allow selection of tree/ore to collect

* Show items gained, exp gained

* Fixup exp gain

* Add check for user logged in while walking

* Use Skill from the api

* Add drop, bank, fletch methods. Add Bank runner

* fixup Bank Runner

* fixup Bank Runner

* idk

* -

* Fixup Bank Runner
This commit is contained in:
Danial
2019-10-15 21:45:33 +13:00
committed by GitHub
parent 15eb36b99a
commit 377caf2346
31 changed files with 752 additions and 201 deletions
+108
View File
@@ -0,0 +1,108 @@
package ParaScript;
import ParaScript.data.Variables;
import ParaScript.strategies.*;
import ParaScript.ui.UI;
import org.parabot.environment.api.interfaces.Paintable;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.Script;
import org.parabot.environment.scripts.framework.Strategy;
import org.parabot.environment.scripts.Category;
import org.parabot.environment.scripts.ScriptManifest;
import org.rev317.min.api.events.MessageEvent;
import org.rev317.min.api.events.listeners.MessageListener;
import org.rev317.min.api.methods.Skill;
import java.awt.*;
import java.util.ArrayList;
@ScriptManifest(author = "RedSparr0w", category = Category.OTHER, description = "ParaScript", name = "ParaScript", servers = { "2006rebotted" }, version = 1)
public class Main extends Script implements MessageListener, Paintable {
private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
private UI ui = new UI();
@Override
public boolean onExecute() {
ui.setVisible(true);
while (!Variables.running) {
Time.sleep(300);
}
Variables.setBaseExp();
strategies.add(new ScriptState());
if(Variables.skill_to_train == Skill.WOODCUTTING) {
strategies.add(new MakeArrowShafts());
strategies.add(new WoodcutTree());
}
if(Variables.skill_to_train == Skill.MINING) {
strategies.add(new Mine());
strategies.add(new Bank());
strategies.add(new Walk());
}
if(Variables.skill_to_train == null) {
strategies.add(new Bank());
strategies.add(new Walk());
strategies.add(new PickupItems());
}
strategies.add(new HandleLogin());
provide(strategies);
return true;
}
@Override
public void onFinish() {
ui.dispose();
System.out.println("Script Stopped");
}
@Override
public void paint(Graphics graphics) {
Graphics2D g = (Graphics2D) graphics;
Color c2=new Color(0f,.749f,1.0f,.3f );
g.setColor(c2);
g.setBackground(c2);
g.fillRect(355, 232, 160, 20);
Color c=new Color(.686f,.933f,.933f,.3f );
g.setColor(c);
g.setBackground(c);
g.fillRect(355, 252, 160, 85);
g.setColor(Color.WHITE);
g.setFont(new Font("Arial", 1, 14));
g.drawString("ParaScript", 360, 247);
g.setFont(new Font("Arial", 1, 11));
g.drawString("Status: " + Variables.getStatus(), 360, 270);
g.drawString("Items(P/H): " + Methods.formatNumber(Variables.itemsGained) + "(" + Methods.formatNumber(Variables.SCRIPT_TIMER.getPerHour(Variables.itemsGained)) + ")", 360, 290);
g.drawString("EXP(P/H): " + Methods.formatNumber((int) Variables.expGained) + "(" + Methods.formatNumber(Variables.SCRIPT_TIMER.getPerHour((int) Variables.expGained)) + ")", 360, 310);
g.drawString("Runtime: " + Variables.SCRIPT_TIMER.toString(), 360, 330);
}
public void messageReceived(MessageEvent message) {
switch (message.getType()) {
case 0:
if (message.getMessage().startsWith("You manage to ")) {
Variables.addItemGained(1);
Variables.updateExpGained();
}
if (message.getMessage().contains("Congratulations, you advanced a woodcutting level.")) {
// add in level up to paint
}
break;
case 4:
if(Variables.skill_to_train == null) {
if (message.getMessage().startsWith(Variables.slaveMaster.toLowerCase() + " wishes to trade with you")) {
// accept trade
// take items, give items if smithing or similar
// goto bank, deposit/withdraw items
// go back to user
}
}
break;
}
}
}
+17
View File
@@ -0,0 +1,17 @@
package ParaScript;
import java.text.DecimalFormat;
public class Methods {
public static String formatNumber(int number) {
DecimalFormat nf = new DecimalFormat("0.0");
double i = number;
if (i >= 1000000) {
return nf.format((i / 1000000)) + "M";
}
if (i >= 1000) {
return nf.format((i / 1000)) + "K";
}
return "" + number;
}
}
@@ -0,0 +1,139 @@
package ParaScript.data;
import ParaScript.data.variables.Ores;
import ParaScript.data.variables.Trees;
import ParaScript.data.variables.Zone;
import org.parabot.environment.api.utils.Timer;
import org.rev317.min.api.methods.Skill;
import org.rev317.min.api.wrappers.Tile;
import org.rev317.min.api.wrappers.TilePath;
import java.util.List;
public class Variables {
public static final Timer SCRIPT_TIMER = new Timer();
public static boolean running = false;
private static String currentStatus = "none";
public static int itemsGained = 0;
public static double baseExperience = 0;
public static double expGained = 0;
// Login Panel
private static String username = "";
private static String password = "";
// Settings Panel
public static Skill skill_to_train = Skill.WOODCUTTING;
// Woodcutting
public static Trees woodcutting_tree_selected = Trees.NORMAL;
public static String woodcutting_method = "Fletch";
// Mining
public static Ores mining_ore_selected = Ores.COPPER_TIN;
public static String mining_method = "Bank";
// Used for slave accounts
public static String slaveMaster = "";
// Used to walk places
public static TilePath pathToWalk;
public static String getStatus() {
return currentStatus;
}
public static void setStatus(String i) {
currentStatus = i;
}
public final static Zone LUMBRIDGE_NORMAL_TREE_ZONE = new Zone(new Tile(3140, 3260), new Tile(3206, 3206));
// Mining Varrock
public final static Zone VARROCK_EAST_BANK_ZONE = new Zone(new Tile(3250, 3424), new Tile(3257, 3416));
public final static Zone VARROCK_EAST_MINE_ZONE = new Zone(new Tile(3276, 3375), new Tile(3298, 3354));
public final static Tile[] VARROCK_EAST_MINE_PATH_TO_BANK = new Tile[]{
new Tile(3289, 3373),
new Tile(3289, 3373),
new Tile(3290, 3384),
new Tile(3290, 3395),
new Tile(3289, 3406),
new Tile(3281, 3416),
new Tile(3275, 3425),
new Tile(3264, 3426),
new Tile(3253, 3425),
new Tile(3253, 3420),
};
public final static Tile[] VARROCK_EAST_BANK_PATH_TO_MINE = new Tile[] {
new Tile(3253, 3423),
new Tile(3253, 3423),
new Tile(3262, 3427),
new Tile(3273, 3427),
new Tile(3280, 3418),
new Tile(3288, 3408),
new Tile(3290, 3397),
new Tile(3290, 3386),
new Tile(3288, 3375),
new Tile(3287, 3370),
};
public static String getAccountUsername() { return username; }
public static void setAccountUsername(String i) { username = i; }
public static String getAccountPassword() { return password; }
public static void setAccountPassword(String i) { password = i; }
public static void addItemGained(int amount){
itemsGained += amount;
}
public static void setBaseExp(){
if (skill_to_train == null) return;
baseExperience = skill_to_train.getExperience();
}
public static void updateExpGained(){
if (skill_to_train == null) return;
expGained = skill_to_train.getExperience() - baseExperience;
}
public static boolean shouldBankItems(){
if (skill_to_train == null) return true;
switch (skill_to_train.getName()){
case "Woodcutting":
return woodcutting_method.equalsIgnoreCase("Bank");
case "Mining":
return mining_method.equalsIgnoreCase("Bank");
default:
return true;
}
}
public static boolean shouldDropItems(){
if (skill_to_train == null) return false;
switch (skill_to_train.getName()){
case "Woodcutting":
return woodcutting_method.equalsIgnoreCase("Drop");
case "Mining":
return mining_method.equalsIgnoreCase("Drop");
default:
return false;
}
}
public static boolean shouldFletchItems(){
if (skill_to_train == null) return false;
switch (skill_to_train.getName()){
case "Woodcutting":
return woodcutting_method.equalsIgnoreCase("Fletch");
default:
return false;
}
}
}
@@ -0,0 +1,41 @@
package ParaScript.data.variables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public enum Ores {
COPPER_TIN("Copper & Tin", new int[]{2090, 2094}, 17.5),
COPPER("Copper", new int[]{2090}, 17.5),
TIN("Tin", new int[]{2094}, 17.5),
IRON ("Iron", new int[]{2092}, 35),
COAL("Coal", new int[]{}, 50);
private String name;
private int[] ids;
private double xp;
Ores(String name, int[] ids, double xp) {
this.name = name;
this.ids = ids;
this.xp = xp;
}
public static String[] toStringArray() {
List<Ores> enumList = Arrays.asList(Ores.values());
List<String> locationsArray = new ArrayList<>();
for (Ores obj : enumList) {
locationsArray.add(obj.name);
}
String[] simpleArray = new String[ locationsArray.size() ];
locationsArray.toArray( simpleArray );
return(simpleArray);
}
public String getName() { return this.name; }
public int[] getIDs() { return this.ids; }
public double getXP() { return this.xp; }
}
@@ -0,0 +1,40 @@
package ParaScript.data.variables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public enum Trees {
NORMAL("Normal", new int[]{1276, 1278, 1279}, 25),
OAK("Oak", new int[]{1281}, 37.5),
WILLOW ("Willow", new int[]{5551, 1308, 5553, 5552}, 47.5),
MAPLE("Maple", new int[]{1307}, 100);
private String name;
private int[] ids;
private double xp;
Trees(String name, int[] ids, double xp) {
this.name = name;
this.ids = ids;
this.xp = xp;
}
public static String[] toStringArray() {
List<Trees> enumList = Arrays.asList(Trees.values());
List<String> locationsArray = new ArrayList<>();
for (Trees obj : enumList) {
locationsArray.add(obj.name);
}
String[] simpleArray = new String[ locationsArray.size() ];
locationsArray.toArray( simpleArray );
return(simpleArray);
}
public String getName() { return this.name; }
public int[] getIDs() { return this.ids; }
public double getXP() { return this.xp; }
}
@@ -0,0 +1,39 @@
package ParaScript.data.variables;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.wrappers.SceneObject;
import org.rev317.min.api.wrappers.Tile;
public class Zone
{
Tile topLeftTile;
Tile botRightTile;
public Zone(Tile topLeftTile, Tile botRightTile)
{
this.topLeftTile = topLeftTile;
this.botRightTile = botRightTile;
}
public boolean inTheZone()
{
if ((Players.getMyPlayer().getLocation().getX() > this.topLeftTile.getX()) &&
(Players.getMyPlayer().getLocation().getY() < this.topLeftTile.getY()) &&
(Players.getMyPlayer().getLocation().getX() < this.botRightTile.getX()) &&
(Players.getMyPlayer().getLocation().getY() > this.botRightTile.getY())) {
return true;
}
return false;
}
public boolean inTheZoneObject(SceneObject tree)
{
if ((tree.getLocation().getX() > this.topLeftTile.getX()) &&
(tree.getLocation().getY() < this.topLeftTile.getY()) &&
(tree.getLocation().getX() < this.botRightTile.getX()) &&
(tree.getLocation().getY() > this.botRightTile.getY())) {
return true;
}
return false;
}
}
@@ -0,0 +1,52 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.*;
import org.rev317.min.api.wrappers.Npc;
import org.rev317.min.api.wrappers.TilePath;
public class Bank implements Strategy {
@Override
public boolean activate() {
return Variables.running
&& Game.isLoggedIn()
&& Variables.shouldBankItems()
&& (Variables.getStatus() == "none" || Variables.getStatus() == "banking items")
&& Inventory.isFull();
}
@Override
public void execute() {
Variables.pathToWalk = new TilePath(Variables.VARROCK_EAST_MINE_PATH_TO_BANK);
Variables.setStatus("banking items");
while (Variables.pathToWalk != null && !Variables.pathToWalk.hasReached()) {
if (!Game.isLoggedIn()) new HandleLogin().execute();
Variables.pathToWalk.traverse();
Time.sleep(2000, 3000);
}
depositItems();
}
public void depositItems() {
Npc banker[] = Npcs.getNearest(494);
if (banker != null) {
banker[0].interact(Npcs.Option.BANK);
Time.sleep(3000);
if (Game.getOpenInterfaceId() == 5292) {
if (Variables.skill_to_train == Skill.MINING)
org.rev317.min.api.methods.Bank.depositAllExcept(1266, 1268, 1270, 1272, 1274, 1276);
if (Variables.skill_to_train == Skill.WOODCUTTING)
org.rev317.min.api.methods.Bank.depositAllExcept(1350, 1352, 1354, 1356, 1358, 1360, 6740);
if (Variables.skill_to_train == null) {
org.rev317.min.api.methods.Bank.depositAllExcept(1);
Variables.addItemGained(28);
}
Variables.setStatus("none");
}
}
}
}
@@ -0,0 +1,74 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.input.Keyboard;
import org.parabot.environment.input.Mouse;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Game;
import java.awt.*;
import java.awt.event.KeyEvent;
public class HandleLogin implements Strategy {
private Point point = new Point(432, 282);
private Point point2 = new Point(328, 324);
private Boolean typed = false;
@Override
public boolean activate() {
return !Game.isLoggedIn() || Game.getOpenBackDialogId() == 15812;
}
public void execute() {
Variables.setStatus("logging in");
if (Game.isLoggedIn() && Game.getOpenInterfaceId() == 15812) {
Mouse.getInstance().click(point2);
Variables.setStatus("none");
}
if (!Game.isLoggedIn()) {
if(Variables.getAccountPassword() != null && Variables.getAccountUsername() != null) {
if(!typed) {
Mouse.getInstance().click(point);
Time.sleep(1000);
clearInput();
Keyboard.getInstance().sendKeys(Variables.getAccountUsername());
Time.sleep(2000);
clearInput();
// Checking again so people don't type their passwords ingame.
if(!Game.isLoggedIn()) {
Keyboard.getInstance().sendKeys(Variables.getAccountPassword());
}
typed = true;
}
}
if(typed) {
Time.sleep(new SleepCondition() {
@Override
public boolean isValid() {
return Game.isLoggedIn();
}
}, 5000);
Mouse.getInstance().click(point);
Time.sleep(1000);
Keyboard.getInstance().clickKey(KeyEvent.VK_ENTER);
Time.sleep(1000);
Keyboard.getInstance().clickKey(KeyEvent.VK_ENTER);
Variables.setStatus("none");
}
}
}
private void clearInput() {
for(int i = 0; i < 30; i ++) {
Keyboard.getInstance().clickKey(KeyEvent.VK_DELETE);
Time.sleep(100);
}
}
}
@@ -0,0 +1,51 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import ParaScript.data.variables.Trees;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Menu;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Items;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
import java.awt.*;
public class MakeArrowShafts implements Strategy {
@Override
public boolean activate() {
if (Variables.running
&& hasRequiredItems()
&& (Variables.getStatus() == "none" || Variables.getStatus() == "making arrow shafts")
&& !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1) {
Variables.setStatus("making arrow shafts");
return true;
}
Variables.setStatus("none");
return false;
}
@Override
public void execute() {
try {
System.out.println("making arrow shafts");
Inventory.getItem(947).interact(Items.Option.USE);
Inventory.getItem(1512).interact(Items.Option.USE_WITH);
Menu.clickButton(8886);
Time.sleep(3000);
//Wait for the Player to chop the Tree
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 3000);
} catch (Exception err) {
System.out.println("Fletching error: ¯\\_(ツ)_/¯");
}
}
private boolean hasRequiredItems(){
// Make sure we have a knife and logs
return Inventory.getItem(947) != null && Inventory.getItem(1512) != null;
}
}
@@ -0,0 +1,62 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import ParaScript.data.variables.Ores;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Items;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
public class Mine implements Strategy {
private SceneObject ore;
@Override
public boolean activate() {
ore = ore(); // set the local Variable
if (Variables.running
&& ore != null
&& (Variables.getStatus() == "none" || Variables.getStatus() == "mining")
&& Variables.VARROCK_EAST_MINE_ZONE.inTheZone()
&& !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1
&& !Inventory.isFull()) {
Variables.setStatus("mining");
return true;
}
Variables.setStatus("none");
return false;
}
@Override
public void execute() {
try {
if (Variables.shouldDropItems()) {
if (Inventory.getCount(441) >= 1) Inventory.getItem(441).interact(Items.Option.DROP);
}
ore.interact(SceneObjects.Option.MINE);
Time.sleep(1000);
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 3000);
} catch (Exception err){
System.out.println("Mining error: ¯\\_(ツ)_/¯");
}
}
private SceneObject ore(){
int[] ore_to_mine = Variables.mining_ore_selected.getIDs();
if (ore_to_mine == Ores.COPPER_TIN.getIDs()) {
if (Inventory.getCount(437) >= 14)
ore_to_mine = Ores.TIN.getIDs();
if (Inventory.getCount(439) >= 14)
ore_to_mine = Ores.COPPER.getIDs();
}
for(SceneObject ore : SceneObjects.getNearest(ore_to_mine)){
if(Variables.VARROCK_EAST_MINE_ZONE.inTheZoneObject(ore)) {
return ore;
}
}
return null;
}
}
@@ -0,0 +1,47 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import ParaScript.data.variables.Ores;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.GroundItem;
import org.rev317.min.api.wrappers.SceneObject;
public class PickupItems implements Strategy {
@Override
public boolean activate() {
if (Variables.running
&& (Variables.getStatus() == "none" || Variables.getStatus() == "picking up items")
&& Variables.VARROCK_EAST_MINE_ZONE.inTheZone()
&& !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1
&& !Inventory.isFull()) {
Variables.setStatus("picking up items");
return true;
}
Variables.setStatus("none");
return false;
}
@Override
public void execute() {
try {
GroundItem[] items = GroundItems.getNearest(436, 438, 440);
for (GroundItem item : items) {
item.take();
Time.sleep(1500);
if (Inventory.isFull()){
Variables.setStatus("none");
return;
}
}
} catch (Exception err){
System.out.println("Pickup items error: ¯\\_(ツ)_/¯");
}
}
}
@@ -0,0 +1,26 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
public class ScriptState implements Strategy {
@Override
public boolean activate() {
if (!Variables.running) {
return true;
}
return false;
}
@Override
public void execute() {
//Wait for the Player to finish pickpocketing
Time.sleep(() -> !Variables.running, 1000);
}
}
@@ -0,0 +1,43 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
public class Thieving implements Strategy {
private SceneObject victim;
@Override
public boolean activate() {
victim = victim(); // set the local Variable
if (Variables.running
&& victim != null
&& !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1
&& !Inventory.isFull()) {
return true;
}
return false;
}
@Override
public void execute() {
victim.interact(SceneObjects.Option.STEAL_FROM);
Time.sleep(1000);
//Wait for the Player to finish pickpocketing
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 500);
}
private SceneObject victim(){
for(SceneObject victim : SceneObjects.getNearest(1, 2, 3, 4)){
if(victim != null){
return victim;
}
}
return null;
}
}
@@ -0,0 +1,32 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.wrappers.TilePath;
public class Walk implements Strategy {
@Override
public boolean activate() {
return Variables.running
&& Game.isLoggedIn()
&& (Variables.getStatus() == "none" || Variables.getStatus() == "walking to mine")
&& !Inventory.isFull()
&& Variables.VARROCK_EAST_BANK_ZONE.inTheZone();
}
@Override
public void execute() {
Variables.setStatus("walking to mine");
Variables.pathToWalk = new TilePath(Variables.VARROCK_EAST_BANK_PATH_TO_MINE);
//Variables.setBotStatus("walking to " + Variables.getTree().getName());
while (Variables.pathToWalk != null && !Variables.pathToWalk.hasReached()) {
if (!Game.isLoggedIn()) new HandleLogin().execute();
Variables.pathToWalk.traverse();
Time.sleep(2000, 3000);
}
}
}
@@ -0,0 +1,50 @@
package ParaScript.strategies;
import ParaScript.data.Variables;
import ParaScript.data.variables.Trees;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
public class WoodcutTree implements Strategy {
private SceneObject tree;
@Override
public boolean activate() {
tree = tree(); // set the local Variable
if (Variables.running
&& tree != null
&& (Variables.getStatus() == "none" || Variables.getStatus() == "woodcutting")
&& !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1
&& !Inventory.isFull()) {
Variables.setStatus("woodcutting");
return true;
}
Variables.setStatus("none");
return false;
}
@Override
public void execute() {
tree.interact(SceneObjects.Option.CHOP_DOWN);
Time.sleep(1000);
//Wait for the Player to chop the Tree
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 3000);
}
private SceneObject tree(){
int[] tree_to_cut = Variables.woodcutting_tree_selected.getIDs();
for(SceneObject tree : SceneObjects.getNearest(tree_to_cut)){
if(tree != null){
if(Variables.LUMBRIDGE_NORMAL_TREE_ZONE.inTheZoneObject(tree)) {
return tree;
}
}
}
return null;
}
}
+324
View File
@@ -0,0 +1,324 @@
package ParaScript.ui;
import ParaScript.data.variables.Ores;
import ParaScript.data.variables.Trees;
import ParaScript.data.Variables;
import org.rev317.min.api.methods.Game;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.Skill;
import org.rev317.min.api.wrappers.Player;
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 {
private final ButtonGroup woodcutOptionButtonGroup = new ButtonGroup();
private JPanel contentPane;
// Login tab
private JTextField username = new JTextField();
private JPasswordField password = new JPasswordField();
private JCheckBox autoLogin = new JCheckBox();
// Settings
private JComboBox skillSelect = new JComboBox();
// Woodcutting
private JComboBox treeSelect = new JComboBox();
private JComboBox woodcuttingMethod = new JComboBox();
private JComboBox location = new JComboBox();
private JCheckBox birdsNest = new JCheckBox();
// Mining
private JComboBox oreSelect = new JComboBox();
private JComboBox miningMethod = new JComboBox();
// Our colors
private Color Color_MidnightBlue = new Color(44, 62, 80);
private Color Color_WetAsphalt = new Color(52, 73, 94);
private Color Color_WhiteSmoke = new Color(245, 245, 245);
private Color Color_Emerald = new Color(46, 204, 113);
private Color Color_Alizarin = new Color(231, 76, 60);
public UI() {
setTitle("src/ParaScript");
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 400, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(null);
contentPane.setForeground(Color_WhiteSmoke);
contentPane.setBackground(Color_MidnightBlue);
setContentPane(contentPane);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(0, 0, 395, 215);
contentPane.add(tabbedPane);
/*
* Login Panel
*/
JPanel loginPanel = new JPanel();
loginPanel.setForeground(Color_WhiteSmoke);
loginPanel.setBackground(Color_WetAsphalt);
tabbedPane.addTab("Login", null, loginPanel, null);
loginPanel.setLayout(null);
// Username
JLabel lblUsername = new JLabel("Username:");
lblUsername.setForeground(Color_WhiteSmoke);
lblUsername.setBounds(20, 20, 73, 20);
loginPanel.add(lblUsername);
username.setText(Game.isLoggedIn() ? Players.getMyPlayer().getName() : "");
username.setBounds(20, 40, 150, 20);
loginPanel.add(username);
// Password
JLabel lblPassword = new JLabel("Password:");
lblPassword.setForeground(Color_WhiteSmoke);
lblPassword.setBounds(200, 20, 73, 20);
loginPanel.add(lblPassword);
password.setBounds(200, 40, 150, 20);
loginPanel.add(password);
// Auto Login
JLabel lblAutoLogin = new JLabel("Auto Login Enabled");
lblAutoLogin.setForeground(Color_WhiteSmoke);
lblAutoLogin.setBounds(40, 80, 130, 20);
loginPanel.add(lblAutoLogin);
autoLogin.setBackground(Color_WetAsphalt);
autoLogin.setForeground(Color_WhiteSmoke);
autoLogin.setBounds(15, 80, 20, 20);
autoLogin.setSelected(true);
loginPanel.add(autoLogin);
/*
* Settings Panel
*/
JPanel settingsPanel = new JPanel();
settingsPanel.setForeground(Color_WhiteSmoke);
settingsPanel.setBackground(Color_WetAsphalt);
tabbedPane.addTab("Settings", null, settingsPanel, null);
settingsPanel.setLayout(null);
// Which skill are we training
JLabel lblSkillToTrain = new JLabel("Skill to train");
lblSkillToTrain.setForeground(Color_WhiteSmoke);
lblSkillToTrain.setBounds(20, 20, 73, 20);
settingsPanel.add(lblSkillToTrain);
skillSelect.setModel(new DefaultComboBoxModel(new String[]{
Skill.WOODCUTTING.getName(),
Skill.MINING.getName(),
"Bank Runner",
}));
skillSelect.setBounds(20, 40, 150, 20);
skillSelect.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
for (Skill skill : Skill.values()) {
if (skill.getName().equalsIgnoreCase(skillSelect.getSelectedItem().toString())) {
Variables.skill_to_train = skill;
return;
}
Variables.skill_to_train = null;
}
}
});
settingsPanel.add(skillSelect);
/*
* Woodcutting Panel
*/
JPanel woodcuttingPanel = new JPanel();
woodcuttingPanel.setForeground(Color_WhiteSmoke);
woodcuttingPanel.setBackground(Color_WetAsphalt);
tabbedPane.addTab("Woodcutting", null, woodcuttingPanel, null);
woodcuttingPanel.setLayout(null);
// Select which tree to cut
JLabel lblTree = new JLabel("Tree");
lblTree.setForeground(Color_WhiteSmoke);
lblTree.setBounds(20, 20, 150, 20);
woodcuttingPanel.add(lblTree);
treeSelect.setModel(new DefaultComboBoxModel(Trees.toStringArray()));
treeSelect.setBounds(20, 40, 150, 20);
treeSelect.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
for (Trees tree : Trees.values()) {
if (tree.getName().equalsIgnoreCase(treeSelect.getSelectedItem().toString())) {
Variables.woodcutting_tree_selected = tree;
}
}
}
});
woodcuttingPanel.add(treeSelect);
// What should we do with our logs
JLabel lblWoodcuttingMethod = new JLabel("Method");
lblWoodcuttingMethod.setForeground(Color_WhiteSmoke);
lblWoodcuttingMethod.setBounds(20, 60, 150, 20);
woodcuttingPanel.add(lblWoodcuttingMethod);
woodcuttingMethod.setModel(new DefaultComboBoxModel(new String[]{
"Fletch",
"Bank",
"Drop",
}));
woodcuttingMethod.setBounds(20, 80, 150, 20);
woodcuttingMethod.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
Variables.woodcutting_method = woodcuttingMethod.getSelectedItem().toString();
}
});
woodcuttingPanel.add(woodcuttingMethod);
/*
JLabel lblLocation = new JLabel("Location");
lblLocation.setBounds(200, 20, 73, 20);
woodcuttingPanel.add(lblLocation);
location.setModel(new DefaultComboBoxModel(Methods.locationToStringArray()));
location.setBounds(200, 40, 150, 20);
woodcuttingPanel.add(location);
JLabel lblBirdsNest = new JLabel("Bird nests");
lblBirdsNest.setForeground(WhiteSmoke);
lblBirdsNest.setBounds(200, 120, 150, 20);
woodcuttingPanel.add(lblBirdsNest);
birdsNest.setBounds(195, 140, 20, 20);
birdsNest.setSelected(true);
woodcuttingPanel.add(birdsNest);
JLabel lblBirdsNestCheckBox = new JLabel("Pickup");
lblBirdsNestCheckBox.setBounds(215, 140, 150, 20);
woodcuttingPanel.add(lblBirdsNestCheckBox);
location.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
for (Location loc : Location.values()) {
if (loc.getName().equalsIgnoreCase(location.getSelectedItem().toString())) {
treeSelect.setModel(
new DefaultComboBoxModel(Methods.treeToStringArray(loc)));
}
}
}
});
*/
/*
* Mining Panel
*/
JPanel miningPanel = new JPanel();
miningPanel.setForeground(Color_WhiteSmoke);
miningPanel.setBackground(Color_WetAsphalt);
tabbedPane.addTab("Mining", null, miningPanel, null);
miningPanel.setLayout(null);
// Select which ore to mine
JLabel lblOre = new JLabel("Ore");
lblOre.setForeground(Color_WhiteSmoke);
lblOre.setBounds(20, 20, 73, 20);
miningPanel.add(lblOre);
oreSelect.setModel(new DefaultComboBoxModel(Ores.toStringArray()));
oreSelect.setBounds(20, 40, 150, 20);
oreSelect.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
for (Ores ore : Ores.values()) {
if (ore.getName().equalsIgnoreCase(oreSelect.getSelectedItem().toString())) {
Variables.mining_ore_selected = ore;
}
}
}
});
miningPanel.add(oreSelect);
// What should we do with our ores
JLabel lblMiningMethod = new JLabel("Method");
lblMiningMethod.setForeground(Color_WhiteSmoke);
lblMiningMethod.setBounds(20, 60, 150, 20);
miningPanel.add(lblMiningMethod);
miningMethod.setModel(new DefaultComboBoxModel(new String[]{
"Bank",
"Drop",
}));
miningMethod.setBounds(20, 80, 150, 20);
miningMethod.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
Variables.mining_method = miningMethod.getSelectedItem().toString();
}
});
miningPanel.add(miningMethod);
/*
* Slave Panel
*/
JPanel slavePanel = new JPanel();
slavePanel.setForeground(Color_WhiteSmoke);
slavePanel.setBackground(Color_WetAsphalt);
tabbedPane.addTab("Bank Runner", null, slavePanel, null);
slavePanel.setLayout(null);
// Which skill are we training
JLabel lblSlaveMaster = new JLabel("Slave Master");
lblSlaveMaster.setForeground(Color_WhiteSmoke);
lblSlaveMaster.setBounds(20, 20, 73, 20);
slavePanel.add(lblSlaveMaster);
JTextField slaveMaster = new JTextField();
slaveMaster.setBounds(20, 40, 150, 20);
slavePanel.add(slaveMaster);
slaveMaster.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
Variables.slaveMaster = slaveMaster.getText();
}
});
JButton start = new JButton("START");
start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(autoLogin.isSelected() && !username.getText().equals("")) {
Variables.setAccountUsername(username.getText());
Variables.setAccountPassword(password.getText());
}
/*
for (Location loc : Location.values()) {
if (loc.getName().equalsIgnoreCase(location.getSelectedItem().toString())) {
Variables.setLocation(loc);
}
}
for (Tree selectedTree : Tree.values()) {
if (selectedTree.getName().equalsIgnoreCase(treeSelect.getSelectedItem().toString())) {
Variables.setTree(selectedTree);
System.out.println(selectedTree.getName());
}
}
if (drop.isSelected()) {
Variables.setDrop(true);
}
if (bank.isSelected()) {
Variables.setBanking(true);
}
if (birdsNest.isSelected()) {
Variables.setPickupBirdNests(true);
}
dispose();
*/
Variables.running = !Variables.running;
start.setText(Variables.running ? "PAUSE" : "START");
start.setBackground(Variables.running ? Color_Alizarin : Color_Emerald);
}
});
start.setBackground(Color_Emerald);
start.setForeground(Color_MidnightBlue);
// these next two lines do the magic..
start.setContentAreaFilled(false);
start.setOpaque(true);
start.setBounds(20, 220, 360, 40);
contentPane.add(start);
}
}
+37
View File
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
<jars basedir="${project.basedir}/target/">
<jar in="${project.build.finalName}.jar" out="/home/ci/jars/${project.build.finalName}.jar"/>
</jars>
<classpath basedir="/home/ci/allatori/libs">
<jar name="./*.jar"/>
</classpath>
<!-- String encryption -->
<property name="string-encryption" value="enable"/>
<property name="string-encryption-type" value="fast"/>
<property name="string-encryption-version" value="v4"/>
<!-- Control flow obfuscation -->
<property name="control-flow-obfuscation" value="enable"/>
<property name="extensive-flow-obfuscation" value="normal"/>
<!-- Renaming -->
<property name="default-package" value=""/>
<property name="force-default-package" value="disable"/>
<property name="classes-naming" value="unique"/>
<property name="methods-naming" value="iii"/>
<property name="fields-naming" value="iii"/>
<property name="local-variables-naming" value="abc"/>
<!-- Other -->
<property name="line-numbers" value="keep"/>
<property name="generics" value="keep"/>
<property name="member-reorder" value="enable"/>
<property name="finalize" value="disable"/>
<property name="synthetize-methods" value="private"/>
<property name="synthetize-fields" value="private"/>
<property name="remove-toString" value="disable"/>
</config>