Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.event.KeyEvent;
- import java.util.concurrent.TimeUnit;
- import org.tbot.util.Condition;
- import org.tbot.wrappers.GameObject;
- import org.tbot.wrappers.Item;
- import org.tbot.wrappers.NPC;
- import org.tbot.wrappers.Player;
- import org.tbot.wrappers.WidgetChild;
- import org.tbot.bot.TBot;
- import org.tbot.internal.AbstractScript;
- import org.tbot.internal.Manifest;
- import org.tbot.internal.event.listeners.PaintListener;
- import org.tbot.methods.Game;
- import org.tbot.methods.Menu;
- import org.tbot.methods.Mouse;
- import org.tbot.methods.Npcs;
- import org.tbot.methods.Players;
- import org.tbot.methods.Random;
- import org.tbot.methods.Shop;
- import org.tbot.methods.Time;
- import org.tbot.methods.Widgets;
- import org.tbot.methods.input.keyboard.Keyboard;
- import org.tbot.methods.tabs.Inventory;
- @Manifest(name = "featherPacks", authors = "James", version = 0.1, description = "Buys/Hops")
- public class featherPacks extends AbstractScript implements PaintListener{
- GameObject rocks;
- public enum State {
- WAIT, BUY, OPEN, HOP, LOGIN;
- }
- private int mY, mX;
- char f4 = KeyEvent.VK_F4;
- int barsGained=0;
- private int moneyBefore= Inventory.getCount(995);
- private long timeBegan;
- private long timeRan;
- char control = KeyEvent.VK_CONTROL;
- int invb4;
- boolean cool=false;
- int i=0;
- int totalGold=0;
- int totalCoal=0;
- int totalIron=0;
- int invcount=0;
- boolean hopp=false;
- int moneyGained=0;
- int sold=0;
- int now=0;
- int p=0;
- Item myItem;
- int feath=0;
- int inv1=0;
- int currfeath=0;
- NPC banker;
- NPC shantay;
- int[] worldArray;
- String haha="18109";
- int accCount;
- private int currentWorld;
- boolean logCountC=false;
- private String currentState = "";
- WidgetChild welcomeScreen = Widgets.getWidget(378, 17);
- private final Condition WELCOME = new Condition(){
- public boolean check(){
- return (welcomeScreen.isVisible());
- }
- };
- private final Condition SHOP_OPEN = new Condition(){
- public boolean check(){
- return (Shop.isOpen());
- }
- };
- private final Condition DROPPED = new Condition(){
- public boolean check(){
- return ((Inventory.getCount(11881)<inv1));
- }
- };
- private State getState(){
- currfeath=Inventory.getCount(314);
- invcount = Inventory.getCount();
- if(!welcomeScreen.isValid() && !Game.isLoggedIn())
- {
- return State.LOGIN;
- }
- if(!Inventory.contains(11881))
- {
- cool=false;
- }
- if(welcomeScreen.isValid())
- welcome();
- if (!welcomeScreen.isValid() && Shop.isOpen())
- Time.sleepUntil(SHOP_OPEN,500);
- if(Shop.isOpen() && Shop.getItem(11881).getStackSize()<26)
- {
- return State.HOP;
- }
- //buy
- if(!welcomeScreen.isValid() && (Game.isLoggedIn() && Npcs.getNearest(4642)!=null) && !Inventory.isFull() && cool!=true)
- return State.BUY;
- if(!welcomeScreen.isValid() && (Game.isLoggedIn() && Npcs.getNearest(4642)!=null) && Inventory.isFull() && cool!=true)
- {
- cool=true;
- return State.OPEN;
- }
- if(hopp=true && cool==true && !Inventory.containsOneOf(11881))
- {
- return State.HOP;
- }
- if(Inventory.getCount(11881)<2)
- {
- hopp=true;
- }
- if(Game.isLoggedIn() && Npcs.getNearest(4642)==null)
- {
- //logout();
- }
- return State.WAIT;
- }
- @Override
- public int loop() {
- try{
- switch (getState()) {
- case BUY:
- currentState = "Buying";
- loot();
- break;
- case HOP:
- currentState = "Hopping";
- hop();
- break;
- case WAIT:
- currentState = "Waiting";
- Time.sleep(400);
- break;
- case LOGIN:
- currentState = "Logging in";
- login();
- break;
- case OPEN:
- currentState = "Opening";
- open();
- break;
- default:
- log("Error, Stopping the script.");
- return -1;
- }
- }catch(Exception e)
- {
- }
- return 0;
- }
- @Override
- public boolean onStart(){
- feath=Inventory.getCount(314);
- worldArray=new int[]{
- 302, 303, 305, 305, 306, 309, 310, 314, 317, 318, 322, 327, 328, 329, 330, 333, 334, 336, 341,
- 342, 343, 344, 346, 350, 351, 352, 354, 358, 362, 365, 367, 368, 369, 370, 375, 376, 377, 386
- };
- Mouse.setSpeed(50);
- timeBegan = System.currentTimeMillis();
- return true;
- }
- int money=(int) (moneyGained * 3600000D / (System.currentTimeMillis() - timeBegan));
- @Override
- public void onRepaint(Graphics g) {
- g.setColor(Color.WHITE);
- mX = Mouse.getX();
- mY = Mouse.getY();
- g.drawLine(mX-1, mY+5, mX-1, mY-5);
- g.drawLine(mX, mY+6, mX, mY-6);
- g.drawLine(mX+1, mY+5, mX+1, mY-5);
- g.drawLine(mX+5, mY-1, mX-5, mY-1);
- g.drawLine(mX+6, mY, mX-6, mY);
- g.drawLine(mX+5, mY+1, mX-5, mY+1);
- timeRan = System.currentTimeMillis() - this.timeBegan;
- g.drawString("Money spent: " + (moneyBefore-Inventory.getCount(995)), 20, 325);
- g.drawString("Time: " + ft(timeRan), 20, 310);
- g.drawString("Money p/hr: " + ((moneyGained * 3600000D )/( (System.currentTimeMillis() - timeBegan))),20, 295);
- g.drawString("World: " + currentWorld, 20, 280);
- g.drawString("State: " + currentState, 20, 265);
- g.drawString("Iron earned: " + (totalIron), 20, 250);
- g.drawString("Coal earned: " + ("sold: " + sold), 20, 235);
- g.drawString("Gold earned: " + (totalGold), 20, 220);
- g.drawString("Money earned: " + (((currfeath-feath)*3)-(moneyBefore-Inventory.getCount(995))), 20, 205);
- //g.drawRect(15, 250, 125, 80);
- //
- currentWorld = Game.getCurrentWorld();
- }
- //Other methods
- private void logout()
- {
- if(!Widgets.isOpen(Widgets.TAB_LOGOUT))
- Widgets.openTab(Widgets.TAB_LOGOUT);
- Game.logout();
- TBot.getBot().getScriptHandler().stopScript();
- }
- private void loot()
- {
- myItem=null;
- shantay = Npcs.getNearest(4642);
- if (!Shop.isOpen()){
- if(shantay.interact("Trade"))
- {
- Time.sleepUntil(SHOP_OPEN, 1000);
- }
- }
- Time.sleep(200, 300);
- if (Shop.isOpen() && Shop.getItem(11881)!=null && Shop.getItem(11881).getStackSize()>24)
- {
- Shop.getItem(11881).interact("Buy 10");
- }
- }
- private void welcome(){
- WidgetChild welcomeScreen = Widgets.getWidget(378,17);
- if(welcomeScreen.isValid()){
- welcomeScreen.interact("Play Runescape");
- }
- }
- public void login() {
- final WidgetChild wc = Widgets.getWidget(378, 17);
- final int state = Game.getGameState();
- if (state == 30) {
- if (wc != null && wc.isValid() && wc.isVisible()) {
- if (wc != null)
- if (wc.click())
- Time.sleepUntil(new Condition() {
- @Override
- public boolean check() {
- return !wc.isValid() && !wc.isVisible();
- }
- }, 1500);
- }
- } else if (state == 10) {
- final String loginText = getLoginText();
- if (Game.getLoginMenuIndex() == 2) {
- final String wantedUsername = "james2@james.com";
- final String currentUsername = Game.getCurrentUsername();
- final String currentPassword = TBot.getBot().getClient().getCurrentPassword();
- final String wantedPassword = TBot.getBot().getCurrentAccount().getPassword();
- if (currentUsername.equalsIgnoreCase(wantedUsername) && currentPassword.equalsIgnoreCase(wantedPassword)) {
- if (Game.getGameState() == 10)
- if (Mouse.click((int) (235 + (Math.random() * (370 - 235))), (int) (305 + (Math.random() * (335 - 305))), true))
- Time.sleep(Random.nextInt(2000, 3000));
- } else {
- if (!currentUsername.equalsIgnoreCase(wantedUsername)) {
- if (!currentUsername.isEmpty()) {
- Mouse.click(Random.nextInt(400, 512), Random.nextInt(307, 330), true);
- } else {
- Mouse.click((int) (340 + (Math.random() * (450 - 340))), (int) (246 + (Math.random() * (260 - 246))), true);
- Keyboard.sendText(wantedUsername);
- }
- }
- if (!currentPassword.equalsIgnoreCase(wantedPassword)) {
- if (!currentPassword.isEmpty()) {
- Mouse.click(Random.nextInt(400, 512), Random.nextInt(307, 330), true);
- } else {
- Mouse.click((int) (340 + (Math.random() * (450 - 340))), (int) (261 + (Math.random() * (275 - 261))), true);
- Keyboard.sendText(wantedPassword);
- }
- }
- }
- if (loginText.contains("Too many")) {
- Time.sleep(3000, 5000);
- }
- if (loginText.contains("exceeded")) {
- Game.instaHopNextP2P();
- Time.sleep(1000, 2000);
- }
- if (loginText.contains("disable")) {
- TBot.getBot().getScriptHandler().stopScript();
- } else if (loginText.contains("update")) {
- System.exit(0);
- TBot.getBot().getScriptHandler().stopScript();
- }
- } else if (loginText.contains("Locked")) {
- TBot.getBot().getScriptHandler().stopScript();
- } else if (Game.getLoginMenuIndex() == 0) {
- Mouse.click((int) (395 + (Math.random() * (530 - 395))), (int) (275 + (Math.random() * (305 - 275))), true);
- Time.sleep(Random.nextInt(500, 750));
- } else if (Game.getLoginMenuIndex() == 3) {
- Mouse.click((int) (315 + (Math.random() * (450 - 315))), (int) (335 + (Math.random() * (335 - 305))), true);
- Time.sleep(Random.nextInt(500, 750));
- }
- }
- }
- private static String getLoginText() {
- return Game.getLoginMessage1() + Game.getLoginMessage2();
- }
- private void hop(){
- if (i==worldArray.length)
- {
- i=0;
- }
- if(Game.instaHop(worldArray[i]))
- Time.sleepUntil(WELCOME,5000);
- currentWorld = Game.getCurrentWorld();
- i++;
- hopp=false;
- }
- private void open(){
- if (Shop.isOpen()){
- Shop.close();
- }
- if (Inventory.contains(11881))
- {
- Time.sleep(200);
- Mouse.click(Inventory.getFirst(11881).getRandomPoint(), true);
- Time.sleep(500);
- while(Inventory.contains(11881))
- {
- inv1=Inventory.getCount(11881);
- Time.sleepUntil(DROPPED,5000);
- if(Inventory.getCount(11881)<inv1)
- {
- //
- }
- else
- {
- open();
- }
- }
- }
- }
- private String ft(long duration)
- {
- String res = "";
- 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));
- res = (hours + ":" + minutes + ":" + seconds);
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement