hi dis my 1st script ever so if anything is wrong let me know (you can change the rock id to copper/tin aswell)
credits to @Vilius and @Keven for helping
also this does not have antiban or gui , only paint
import java.awt.Color;
import java.awt.Graphics2D;
import java.util.concurrent.TimeUnit;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(author = "assnerd", info = "mines iron ore and drops em for you", name = "ironore powerminer for leechers", version = 69, logo = "")
public class PowerMiner extends Script {
private long timeBegan;
private long timeRan;
String state = "IdleIdle"; // first state
@Override
public void onStart() {
timeBegan = System.currentTimeMillis();
getExperienceTracker().startAll();
log("enjoy this you leecher");
}
private enum State {
MINEMINE, DROPDROP, SLEEPSLEEP // the 3 states
};
private State getState() {
RS2Object rock = getObjects().closest(13446); // gets nearest objects of the ID (change them if they get updated)
if (inventory.isFull()) // checks if inventory is full
return State.DROPDROP;
if (rock != null && !myPlayer().isAnimating()) // checks if rock is visible and if character (your player) is not animating
return State.MINEMINE;
return State.SLEEPSLEEP;
}
@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case MINEMINE:
state = "MineMine"; // changes state to MineMine
log("mine mine motherfucker"); // rofl
RS2Object rock = getObjects().closest(13446); // gets nearest objects of the ID (change them if they get updated)
if (rock != null) { // checks if rock is visible
rock.interact("Mine"); // mines the rock
sleep(random(1000, 3000));
}
break;
case DROPDROP:
state = "DropDrop"; // changes state to DropDrop
log("drop drop motherfucker"); // rofl
inventory.dropAllExcept(getInventory().filter(item -> item.getName().contains("pickaxe"))); // will drop everything in the inventory except pickaxes
break;
case SLEEPSLEEP:
state = "SleepSleep"; // changes state to SleepSleep
log("sleep sleep motherfucker"); // rofl
sleep(random(500, 1500));
break;
}
return random(400, 600);
}
@Override
public void onExit() {
log("perish you degenerate");
}
@Override
public void onPaint(Graphics2D g) {
timeRan = System.currentTimeMillis() - this.timeBegan;
g.setColor(Color.GREEN); // this makes the paint text green
g.drawString("RUNTIME: " + (ft(timeRan)), 15, 50); // this prints out runtime
g.drawString("XP/HR(" + getExperienceTracker().getGainedXPPerHour(Skill.MINING) + ")", 15, 65); // this prints out xp/hr
g.drawString("STATE: " + state, 15, 80); // this prints out state
}
private String ft(long duration) {
String res = "";
long days = TimeUnit.MILLISECONDS.toDays(duration);
long hours = TimeUnit.MILLISECONDS.toHours(duration)
- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
if (days == 0) {
res = (hours + ":" + minutes + ":" + seconds);
} else {
res = (days + ":" + hours + ":" + minutes + ":" + seconds);
}
return res;
}
}