Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.net.URLConnection;
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.strategy.Condition;
- import org.powerbot.concurrent.strategy.Strategy;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.Tabs;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.methods.widget.Camera;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(name = "Wine Drinker", description = "Drinks Wine for profit!", version = 1.0, authors = {"Thondar"})
- public class WineDrinker extends ActiveScript implements PaintListener {
- int Jug = 1935;
- int JugWine = 1993;
- int JugCount;
- int JugInv;
- int Profit;
- int ProfitHour;
- int WinePrice;
- int JugPrice;
- int Banker[] = {3418, 553, 496, 497, 9710, 42192, 2718, 3416, 3293, 4456, 4457, 4458, 4459, 6200, 2759};
- long startTime;
- long runTime, xpTime;
- long hr, min, sec, xphr, xpmin, xpsec;
- long xpGain;
- String time;
- String status;
- boolean start = true;
- private int getPrice(int id) throws IOException {
- URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + id);
- URLConnection con = url.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(
- con.getInputStream()));
- String line = "";
- String inputLine;
- while ((inputLine = in.readLine()) != null) {
- line += inputLine;
- }
- in.close();
- if (!line.contains("mark_price"))
- return -1;
- line = line.substring(line.indexOf("mark_price\":\"")
- + "mark_price\":\"".length());
- line = line.substring(0, line.indexOf("\""));
- return Integer.parseInt(line.replaceAll(",", ""));
- }
- @Override
- protected void setup() {
- startTime = System.currentTimeMillis();
- JugCount = 0;
- try {
- WinePrice = getPrice(JugWine);
- JugPrice = getPrice(Jug);
- } catch (IOException e) {
- e.printStackTrace();
- }
- BankOpen bankopen = new BankOpen();
- Strategy bankopenStrategy = new Strategy(bankopen, bankopen);
- provide(bankopenStrategy);
- Bank bank = new Bank();
- Strategy bankStrategy = new Strategy(bank, bank);
- provide(bankStrategy);
- Drink drink = new Drink();
- Strategy drinkStrategy = new Strategy(drink, drink);
- provide(drinkStrategy);
- AntiBan ab = new AntiBan();
- Strategy abStrategy = new Strategy(ab, ab);
- provide(abStrategy);
- Tabs.INVENTORY.open(false);
- }
- private class BankOpen implements Task, Condition {
- @Override
- public void run() {
- status = ("Banking");
- NPCs.getNearest(Banker).interact("Bank");
- Time.sleep(Random.nextInt(2000, 3500));
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount(JugWine) == 0) && NPCs.getNearest(Banker).isOnScreen() && !org.powerbot.game.api.methods.widget.Bank.isOpen();
- }
- }
- private class Bank implements Task, Condition {
- @Override
- public void run() {
- status = ("Banking");
- JugInv = Inventory.getCount(Jug);
- JugCount += JugInv;
- org.powerbot.game.api.methods.widget.Bank.depositInventory();
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.withdraw(JugWine, 28);
- Time.sleep(Random.nextInt(300, 500));
- org.powerbot.game.api.methods.widget.Bank.close();
- }
- @Override
- public boolean validate() {
- return Inventory.getCount(JugWine) < 1 && org.powerbot.game.api.methods.widget.Bank.isOpen();
- }
- }
- private class Drink implements Task, Condition {
- @Override
- public void run() {
- status = ("Drinking Wine");
- Inventory.getItem(JugWine).getWidgetChild().interact("Drink");
- Time.sleep(Random.nextInt(350, 410));
- }
- @Override
- public boolean validate() {
- return (Inventory.getCount(JugWine) > 0) && !org.powerbot.game.api.methods.widget.Bank.isOpen();
- }
- }
- private class AntiBan implements Task, Condition {
- @Override
- public void run() {
- switch(Random.nextInt(1, 100)){
- case 3:
- Camera.setAngle(Random.nextInt(1, 150));
- case 33:
- Camera.setAngle(Random.nextInt(1, 310));
- case 75:
- Camera.setAngle(Random.nextInt(1, 210));
- default:
- }
- Time.sleep(Random.nextInt(500, 1000));
- }
- @Override
- public boolean validate() {
- return start;
- }
- }
- private AlphaComposite makeComposite(float alpha) {
- int type = AlphaComposite.SRC_OVER;
- return(AlphaComposite.getInstance(type, alpha));
- }
- private final Font font1 = new Font("Verdana", 0, 16);
- private final Font font2 = new Font("Verdana", 0, 12);
- private final Font font3 = new Font("Verdana", 0, 13);
- private final Font font4 = new Font("Verdana", 0, 9);
- @Override
- public void onRepaint(Graphics g) {
- Graphics2D g2d = (Graphics2D) g;
- g2d.setColor(Color.MAGENTA);
- g2d.drawLine((Mouse.getX() -3), Mouse.getY(), (Mouse.getX() +3), Mouse.getY());
- g2d.drawLine(Mouse.getX(), (Mouse.getY() - 3), Mouse.getX(), (Mouse.getY() + 3));
- g2d.drawLine((Mouse.getX() - 1), (Mouse.getY() - 1), (Mouse.getX() + 1), (Mouse.getY() + 1));
- g2d.drawLine((Mouse.getX() + 1), (Mouse.getY() - 1), (Mouse.getX() - 1), (Mouse.getY() + 1));
- int JugHour = (int) ((JugCount) * 3600000D / (System
- .currentTimeMillis() - startTime));
- int JugPrice1 = JugPrice - WinePrice;
- Profit = JugCount * JugPrice1;
- ProfitHour = JugHour * JugPrice1;
- Rectangle bg = new Rectangle(0, 0, 800, 50);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.BLACK);
- g2d.fill(bg);
- g2d.setFont(font1);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.RED);
- g2d.drawString("WineDrinker", 15, 20);
- g2d.setFont(font3);
- g2d.drawString("by Thondar", 27, 35);
- g2d.setFont(font4);
- g2d.drawString("Version 1.0", 33, 45);
- g2d.setFont(font2);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.GRAY);
- g2d.drawString("Time Run: " + timeRun(), 150, 20);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.GRAY);
- g2d.drawString("Status: " + status, 150, 40);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.GRAY);
- g2d.drawString("Jugs Banked: " + JugCount, 350, 20);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.GRAY);
- g2d.drawString("Jugs Banked/H: " + JugHour, 350, 40);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.GRAY);
- g2d.drawString("Profit: " + Profit, 550, 20);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.GRAY);
- g2d.drawString("Profit/H: " + ProfitHour, 550, 40);
- }
- public String timeRun() {
- runTime = System.currentTimeMillis() - startTime;
- time = "";
- hr = runTime / (1000 * 60 * 60);
- min = (runTime % (1000 * 60 * 60)) / (1000 * 60);
- sec = ((runTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
- if (hr < 10)
- time += "0" + hr + ":";
- else
- time += hr + ":";
- if (min < 10)
- time += "0" + min + ":";
- else
- time += min + ":";
- if (sec < 10)
- time += "0" + sec;
- else
- time += sec;
- return time;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment