import java.awt.Rectangle;
import impsoft.ibot.Areas;
import impsoft.ibot.Info;
import impsoft.ibot.methods.Menu;
import impsoft.ibot.methods.RGB;
import impsoft.ibot.methods.Script;
/**
* my copy :) Made By HaXiRs,Drop Procedure from poweranything(by
* GenoDemoN,Ruler,rikioh)
*/
public class Xmine1 extends Script {
public static double version = 1.1;
public static String author = "HaXiRs,GenoDemoN,Ruler,rikioh)";
public static String[] commands = new String[] { "Rock,Min Sleep,Max Sleep,Rock R,Rock G,Rock B" };
public static String arugs[];
public String searchName;
public int minsleep;
public int maxsleep;
public RGB searchColor;
public boolean doStart(String cmd, String[] args) {
if (args.length == 0) {
return false;
}
Xmine1.arugs = args;
searchName = arugs[0];
minsleep = Integer.parseInt(arugs[1]);
maxsleep = Integer.parseInt(arugs[2]);
searchColor = new RGB(Integer.parseInt(arugs[3]), Integer
.parseInt(arugs[4]), Integer.parseInt(arugs[5]));
log("To mine" + searchName);
return true;
}
public void script() throws InterruptedException {
log("Welcome To HaXiRs's haxPwminer");
sleep(1500);
if (getTab() != Info.TAB_INVENTORY)
setTab(Info.TAB_INVENTORY);
while (true) {
if (theBot.loggedIn) {
if (inventoryCount() >= 28) {
doAllInventory(new String[] { "axe" }, "Drop");
}
pickRock();
}
sleep(500);
}
}
public void pickRock() throws InterruptedException {
// find a rock a mine it?
// TODO
String top = getTopText();
if (top.indexOf(searchName) != -1) {
log("Attempting to mine");
mouseClickLeft(currentMouseX(), currentMouseY());
}
}
/**
*
* @param ignoreItemNames
* The item names you dont want to do this action to
* @param Action
* The name of the thing that comes up in the menu, dont have
* spaces plz!
* @author ruler, aikon
* @throws InterruptedException
*/
public void doAllInventory(String ignoreItemNames[], String Action)
throws InterruptedException {
// Check Tab to make sure we are in the inventory if not switch to the
// Inventory
if (getTab() != Info.TAB_INVENTORY && getTab() != -1) {
setTab(Info.TAB_INVENTORY);
}
for (int i = 1; i < 29; i++) {
// if no item is in the slot skip this slot;
int attempt = 0;
int maxAttempt = 10;
while (itemExist(i)) {
mouseMove(Info.getInventoryRectangle(i));
String topText = getTopText().trim();
if (topText.indexOf(" ") != -1 && topText.indexOf("/") != -1) {
// This determines the items name from the topText
String item = topText.substring(topText.indexOf(" "),
topText.indexOf("/")).trim();
if (item.length() > 1) {
// We dont want to drop our pickaxe
boolean ignore = false;
if (ignoreItemNames != null)
for (int ignoreIndex = 0; ignoreIndex < ignoreItemNames.length; ignoreIndex++) {
if (topText
.indexOf(ignoreItemNames[ignoreIndex]) != -1) {
ignore = true;
}
}
if (ignore) {
attempt = maxAttempt;
break;
} else {
log("Found a " + item + " in Inventory Slot " + i
+ " '" + Action + "ing'");
doInventory(i, Action);
if (itemExist(i)) {
i--;
}
break;
}
}
}
attempt++;
if (attempt > maxAttempt) {
log("Attempt " + attempt + " > " + maxAttempt);
break;
}
sleep(300);
}
}
}
/**
*
* @param invIndex
* The index you want to bring the menu up on
* @param Action
* The name of the thing that comes up in the menu, dont have
* spaces plz!
* @author ruler, aikon
* @throws InterruptedException
*/
public int doInventory(int invIndex, String Action)
throws InterruptedException {
Rectangle inventorySpot = Info.getInventoryRectangle(invIndex);
int currentMouseX = currentMouseX();
int currentMouseY = currentMouseY();
if (inventorySpot.contains(currentMouseX, currentMouseY)) {
mouseClickRight(currentMouseX, currentMouseY);
Menu bankBoothMenu = getMenu(Areas.GAME, 2000);
//if(bankBoothMenu.getOption(0).toLowerCase().contains("cancel")){log("woot");}
// if (bankBoothMenu != null) {
int selectindex=-1;
for(int i=0; i<bankBoothMenu.options.length; i++)
{
String options = bankBoothMenu.getOption(i);
sleep(100);
//if(options.toLowerCase().contains("cancel")) { bankBoothMenu.exit(); return 0; }
log("menu containing" + options);
if(options.contains(Action)) { log("found the All text and set the selectindex"); bankBoothMenu.select(i);}
}
if(selectindex==-1) { return 0; }
//}
} /*else {
mouseClickRight(inventorySpot);
Menu bankBoothMenu = getMenu(Areas.GAME, 2000);
if (bankBoothMenu != null) {
sleep(100);
int selectindex=-1;
for(int i=0; i<bankBoothMenu.options.length; i++)
{
String options = bankBoothMenu.getOption(i);
sleep(100);
if(options.toLowerCase().contains("cancel")) { bankBoothMenu.exit(); return 0;}
log("menu containing" + options);
if(options.contains(Action)) { selectindex = i; }
}
bankBoothMenu.select(selectindex);
}//ifbankboothnotnull
}//else */
sleep(250);
return 1;
}//doinventory
}