So much duplicated code, I think you need to try break it down more.
There are 3 states
Alching
Buying
Exiting
There are X Number of items which you are iterating in order
Rune2h -> Rune Plate -> Rune Legs
Heres is what I would try to do
Create an array which which holds the data for the item I wish to alch(Only name right now, but could hold things such as Times alched etc)
The initial state would be alching until no items
buy items (Trigger a flag saying bought items for current item once done)
alch until done
Switch the reference to the index of the array(Reset bought flag etc)
continue until x number of items done
reset index to 0, repeat.
Using this way of having the current item stored in an array you can reduce duplicated code y taking a parameter into the method
EG
public void alchRpl8() throws InterruptedException {
if (getInventory().contains("Rune platebody")) {
if (!getPlayers().myPlayer().isAnimating()) {
magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
Sleep.sleepUntil(() -> magic.isSpellSelected(), 5000);
getInventory().interact("cast", "Rune platebody");
runepl8 =+ 1;
}
}
}
could become
public void alchItem(String itemName) throws InterruptedException {
if (getInventory().contains(itemName)) {
if (!getPlayers().myPlayer().isAnimating()) {
magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
Sleep.sleepUntil(() -> magic.isSpellSelected(), 5000);
getInventory().interact("cast", itemName);
}
}
}
That way you don't need a separate method for each item you wish to alch