mirror of
https://github.com/2006Scape-Scripts/ParaScript.git
synced 2026-07-02 16:49:02 +00:00
Add ores and mine
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package ParaScript.data.variables;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum Ores {
|
||||
COPPER("Copper", new int[]{2090}),
|
||||
TIN("Tin", new int[]{2094}),
|
||||
COPPER_TIN("Copper & Tin", new int[]{2090, 2094}),
|
||||
IRON ("Iron", new int[]{2092}),
|
||||
COAL("Coal", new int[]{});
|
||||
|
||||
private String name;
|
||||
private int[] ids;
|
||||
|
||||
Ores(String name, int[] ids) {
|
||||
this.name = name;
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
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 int[] getIDs() {
|
||||
return this.ids;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
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;
|
||||
import org.rev317.min.api.methods.Players;
|
||||
@@ -8,25 +12,41 @@ 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() {
|
||||
for (SceneObject i : SceneObjects.getNearest(100)) {
|
||||
if (Variables.running
|
||||
&& i !=null
|
||||
&& i.distanceTo() <= 10
|
||||
&& !Players.getMyPlayer().isInCombat()
|
||||
&& Players.getMyPlayer().getAnimation() == -1
|
||||
&& !Inventory.isFull()) {
|
||||
return true;
|
||||
}
|
||||
ore = ore(); // set the local Variable
|
||||
if (Variables.running
|
||||
&& ore != null
|
||||
&& (Variables.getStatus() == "none" || Variables.getStatus() == "mining")
|
||||
&& !Players.getMyPlayer().isInCombat()
|
||||
&& Players.getMyPlayer().getAnimation() == -1
|
||||
&& !Inventory.isFull()) {
|
||||
Variables.setStatus("mining");
|
||||
return true;
|
||||
}
|
||||
Variables.setStatus("none");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
for (SceneObject i : SceneObjects.getNearest(100)) {
|
||||
i.interact(SceneObjects.Option.MINE);
|
||||
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(){
|
||||
for(SceneObject tree : SceneObjects.getNearest(Ores.COPPER_TIN.getIDs())){
|
||||
if(tree != null){
|
||||
return ore;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user