Add settings panel, choose which skill to train

This commit is contained in:
RedSparr0w
2019-10-14 19:49:15 +13:00
parent 60ae2c1be0
commit c7b02239a1
10 changed files with 125 additions and 27 deletions
+8 -2
View File
@@ -3,8 +3,14 @@
<component name="ChangeListManager">
<list default="true" id="3ab8e8a0-ccfd-4b0b-9547-98173085dc38" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ParaScript.iml" beforeDir="false" afterPath="$PROJECT_DIR$/ParaScript.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/data/Variables.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/data/Variables.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/data/variables/Trees.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/data/variables/Trees.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/strategies/Bank.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/strategies/Bank.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/strategies/Mine.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/strategies/Mine.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/strategies/Walk.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/strategies/Walk.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ParaScript/ui/UI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ParaScript/ui/UI.java" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@@ -33,8 +39,8 @@
<property name="GenerateAntBuildDialog.forceTargetJdk" value="true" />
<property name="GenerateAntBuildDialog.generateSingleFile" value="true" />
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="parascript" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../Script-Factory" />
<property name="project.structure.last.edited" value="Modules" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
+1 -1
View File
@@ -9,7 +9,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/OneDrive/Documents/Java Dependencies/Parabot/Parabot-317-API-Minified.jar!/" />
+9 -2
View File
@@ -26,8 +26,15 @@ public class Main extends Script{
}
strategies.add(new ScriptState());
strategies.add(new MakeArrowShafts());
strategies.add(new WoodcutTree());
if(Variables.skill_to_train.equalsIgnoreCase("Woodcutting")) {
strategies.add(new MakeArrowShafts());
strategies.add(new WoodcutTree());
}
if(Variables.skill_to_train.equalsIgnoreCase("Mining")) {
strategies.add(new Mine());
strategies.add(new Bank());
strategies.add(new Walk());
}
strategies.add(new HandleLogin());
provide(strategies);
return true;
+1
View File
@@ -13,6 +13,7 @@ public class Variables {
private static String currentStatus = "none";
private static String username = "";
private static String password = "";
public static String skill_to_train = "Woodcutting";
public static TilePath pathToWalk;
public static String getStatus() {
+1 -1
View File
@@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.List;
public enum Trees {
NORMAL("Normal", new int[]{1276, 1278}),
NORMAL("Normal", new int[]{1276, 1278, 1279}),
OAK("Oak", new int[]{1281}),
WILLOW ("Willow", new int[]{5551, 1308, 5553, 5552}),
MAPLE("Maple", new int[]{1307});
+1 -1
View File
@@ -23,7 +23,7 @@ public class Bank implements Strategy {
Variables.setStatus("banking items");
while (Variables.pathToWalk != null && !Variables.pathToWalk.hasReached()) {
Variables.pathToWalk.traverse();
Time.sleep(1000, 2000);
Time.sleep(2000, 3000);
}
depositItems();
}
+56
View File
@@ -0,0 +1,56 @@
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.Players;
import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject;
public class BankRunner 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 {
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 = 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;
}
}
+2 -4
View File
@@ -2,8 +2,6 @@ package ParaScript.strategies;
import ParaScript.data.Variables;
import ParaScript.data.variables.Ores;
import ParaScript.data.variables.Trees;
import com.sun.deploy.util.ArrayUtil;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory;
@@ -44,9 +42,9 @@ public class Mine implements Strategy {
private SceneObject ore(){
int[] ore_to_mine = Ores.COPPER_TIN.getIDs();
if (Inventory.getCount(Ores.COPPER.getIDs()) >= 14)
if (Inventory.getCount(437) >= 14)
ore_to_mine = Ores.TIN.getIDs();
if (Inventory.getCount(Ores.TIN.getIDs()) >= 14)
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)) {
+1 -1
View File
@@ -25,7 +25,7 @@ public class Walk implements Strategy {
//Variables.setBotStatus("walking to " + Variables.getTree().getName());
while (Variables.pathToWalk != null && !Variables.pathToWalk.hasReached()) {
Variables.pathToWalk.traverse();
Time.sleep(1000, 2000);
Time.sleep(2000, 3000);
}
}
}
+45 -15
View File
@@ -15,15 +15,18 @@ import java.awt.event.ActionListener;
public class UI extends JFrame {
private final ButtonGroup woodcutOptionButtonGroup = new ButtonGroup();
private JPanel contentPane;
private JComboBox location = new JComboBox();
private JComboBox treeSelect = new JComboBox();
private JRadioButton bank = new JRadioButton("Bank");
private JRadioButton drop = new JRadioButton("Drop");
private JCheckBox birdsNest = new JCheckBox();
// Login tab
private JTextField username = new JTextField();
private JPasswordField password = new JPasswordField();
private JCheckBox autoLogin = new JCheckBox();
// Settings
private JComboBox skillSelect = new JComboBox();
private JRadioButton bank = new JRadioButton("Bank");
private JRadioButton drop = new JRadioButton("Drop");
// Woodcutting
private JComboBox treeSelect = new JComboBox();
private JComboBox location = new JComboBox();
private JCheckBox birdsNest = new JCheckBox();
// Our colors
private Color Color_MidnightBlue = new Color(44, 62, 80);
private Color Color_WetAsphalt = new Color(52, 73, 94);
@@ -84,22 +87,41 @@ public class UI extends JFrame {
autoLogin.setSelected(true);
loginPanel.add(autoLogin);
/*
* Settings
*/
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[]{
"Woodcutting",
"Mining",
}));
skillSelect.setBounds(20, 40, 150, 20);
settingsPanel.add(skillSelect);
skillSelect.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
Variables.skill_to_train = skillSelect.getSelectedItem().toString();
}
});
/*
* Woodcutting Stuff
*/
JPanel woodcuttingPanel = new JPanel();
woodcuttingPanel.setForeground(Color_WhiteSmoke);
woodcuttingPanel.setBackground(Color_WetAsphalt);
tabbedPane.addTab("Woodcutting", null, woodcuttingPanel, null);
woodcuttingPanel.setLayout(null);
/*
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);
*/
// Select which tree to cut
JLabel lblTree = new JLabel("Tree");
lblTree.setForeground(Color_WhiteSmoke);
@@ -110,6 +132,14 @@ public class UI extends JFrame {
woodcuttingPanel.add(treeSelect);
/*
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 lblMethod = new JLabel("Method");
lblMethod.setBounds(20, 120, 73, 20);
woodcuttingPanel.add(lblMethod);