Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- 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.Walking;
- import org.powerbot.game.api.methods.Widgets;
- import org.powerbot.game.api.methods.input.Keyboard;
- import org.powerbot.game.api.methods.input.Mouse;
- import org.powerbot.game.api.methods.interactive.NPCs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.node.Menu;
- 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.api.wrappers.Area;
- import org.powerbot.game.api.wrappers.Tile;
- import org.powerbot.game.api.wrappers.widget.WidgetChild;
- import org.powerbot.game.bot.event.listener.PaintListener;
- @Manifest(name = "GE Buyer", description = "Buys stuff for you at GE", version = 1.0, authors = {"Thondar"})
- public class GEBuyer extends ActiveScript implements PaintListener{
- long startTime;
- long runTime;
- long hr, min, sec;
- int SleepTimer;
- int ClerkID = 1419;
- int BuyProcent;
- int AmountBought;
- int StopAmount;
- String time;
- String status;
- String ItemName;
- String ItemAmount;
- String BuyPro;
- private static WidgetChild CheckWidget;
- Tile GETile = new Tile(3178, 3505, 0);
- Area GEArea = new Area(new Tile(3176, 3500, 0), new Tile(3185, 3510, 0));
- geGUI g;
- private boolean guiWait = true;
- boolean start = false;
- @Override
- protected void setup() {
- start = true;
- startTime = System.currentTimeMillis();
- g = new geGUI();
- g.setVisible(true);
- final WaitGui guiTask = new WaitGui();
- provide(new Strategy(guiTask, guiTask));
- provide(new Strategy(new WaitGui(), new WaitGui()));
- AntiBan ab = new AntiBan();
- Strategy abStrategy = new Strategy(ab, ab);
- provide(abStrategy);
- Buy buy = new Buy();
- Strategy buyStrategy = new Strategy(buy, buy);
- provide(buyStrategy);
- Accept accept = new Accept();
- Strategy acceptStrategy = new Strategy(accept, accept);
- provide(acceptStrategy);
- Check check = new Check();
- Strategy checkStrategy = new Strategy(check, check);
- provide(checkStrategy);
- Check1 check1 = new Check1();
- Strategy check1Strategy = new Strategy(check1, check1);
- provide(check1Strategy);
- Run run = new Run();
- Strategy runStrategy = new Strategy(run, run);
- provide(runStrategy);
- Tabs.INVENTORY.open(false);
- CheckWidget = Widgets.get(105, 1);
- }
- private class WaitGui implements Task, Condition {
- @Override
- public void run() {
- while (guiWait) {
- Time.sleep(500);
- }
- }
- public boolean validate() {
- return guiWait;
- }
- }
- private class AntiBan implements Task, Condition {
- @Override
- public void run() {
- switch(Random.nextInt(1, 1000)){
- 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(100, 200));
- }
- @Override
- public boolean validate() {
- return start;
- }
- }
- private class Buy implements Task, Condition {
- @Override
- public void run() {
- Mouse.move(Random.nextInt(204, 246), Random.nextInt(189, 210));
- Time.sleep(Random.nextInt(500, 800));
- Mouse.click(true);
- Time.sleep(Random.nextInt(2000, 3000));
- Buy();
- Time.sleep(Random.nextInt(500, 700));
- }
- @Override
- public boolean validate() {
- return Menu.contains("Make Buy Offer") && GEArea.contains(Players.getLocal());
- }
- }
- private class Accept implements Task, Condition {
- @Override
- public void run() {
- Mouse.move(Random.nextInt(204, 246), Random.nextInt(189, 210));
- Time.sleep(Random.nextInt(500, 800));
- Mouse.click(true);
- Time.sleep(Random.nextInt(5000, 7000));
- Accept();
- Time.sleep(Random.nextInt(500, 700));
- }
- @Override
- public boolean validate() {
- return Menu.contains("View Offer") && !Menu.contains("Abort Offer") && GEArea.contains(Players.getLocal());
- }
- }
- private class Check implements Task, Condition {
- @Override
- public void run() {
- Mouse.move(Random.nextInt(204, 246), Random.nextInt(189, 210));
- Time.sleep(Random.nextInt(600, 900));
- if (Menu.contains("Abort Offer")) {
- Time.sleep(SleepTimer);
- }
- Time.sleep(Random.nextInt(600, 900));
- }
- @Override
- public boolean validate() {
- return NPCs.getNearest(ClerkID).isOnScreen() && GEArea.contains(Players.getLocal()) && CheckWidget.isOnScreen();
- }
- }
- private class Check1 implements Task, Condition {
- @Override
- public void run() {
- NPCs.getNearest(ClerkID).interact("Exchange");
- Time.sleep(Random.nextInt(1500, 1900));
- }
- @Override
- public boolean validate() {
- return NPCs.getNearest(ClerkID).isOnScreen() && GEArea.contains(Players.getLocal()) && !CheckWidget.isOnScreen();
- }
- }
- private class Run implements Task, Condition {
- @Override
- public void run() {
- Walking.setRun(true);
- Walking.walk(GETile);
- }
- @Override
- public boolean validate() {
- return NPCs.getNearest(ClerkID) != null && !GEArea.contains(Players.getLocal());
- }
- }
- public void Buy() {
- Keyboard.sendText(ItemName, false);
- Time.sleep(Random.nextInt(1500, 2000));
- Mouse.move(Random.nextInt(70, 196), Random.nextInt(398, 402));
- Time.sleep(Random.nextInt(2000, 3000));
- Mouse.click(true);
- Time.sleep(Random.nextInt(2000, 3000));
- Mouse.move(Random.nextInt(227, 249), Random.nextInt(263, 278));
- Time.sleep(Random.nextInt(1100, 1700));
- Mouse.click(true);
- Time.sleep(Random.nextInt(1300, 1700));
- Keyboard.sendText(ItemAmount, true);
- Time.sleep(Random.nextInt(900, 1300));
- if(BuyProcent == 1){
- Mouse.move(Random.nextInt(279, 301), Random.nextInt(263, 278));
- Time.sleep(Random.nextInt(800, 1100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(300, 500));
- Mouse.click(true);
- Time.sleep(Random.nextInt(800, 1100));
- Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
- Time.sleep(Random.nextInt(900, 1300));
- Mouse.click(true);
- }else if(BuyProcent == 2){
- Mouse.move(Random.nextInt(279, 301), Random.nextInt(263, 278));
- Time.sleep(Random.nextInt(800, 1100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(300, 500));
- Mouse.move(Random.nextInt(211, 316), Random.nextInt(311, 358));
- Time.sleep(Random.nextInt(900, 1300));
- Mouse.click(true);
- }else if(BuyProcent == 3){
- Mouse.move(Random.nextInt(236, 301), Random.nextInt(334, 355));
- Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
- Time.sleep(Random.nextInt(900, 1300));
- Mouse.click(true);
- }else if(BuyProcent == 4){
- Mouse.move(Random.nextInt(430, 455), Random.nextInt(263, 278));
- Time.sleep(Random.nextInt(800, 1100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(300, 500));
- Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
- Time.sleep(Random.nextInt(900, 1300));
- Mouse.click(true);
- }else{
- Mouse.move(Random.nextInt(430, 455), Random.nextInt(263, 278));
- Time.sleep(Random.nextInt(800, 1100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(800, 1100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(300, 500));
- Mouse.move(Random.nextInt(211, 316), Random.nextInt(336, 358));
- Time.sleep(Random.nextInt(900, 1300));
- Mouse.click(true);
- }
- }
- public void Accept() {
- Mouse.move(Random.nextInt(405, 430), Random.nextInt(335, 359));
- Time.sleep(Random.nextInt(1500, 2100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(200, 300));
- Mouse.move(Random.nextInt(455, 477), Random.nextInt(335, 359));
- Time.sleep(Random.nextInt(1500, 2100));
- Mouse.click(true);
- Time.sleep(Random.nextInt(400, 600));
- Mouse.move(Random.nextInt(480, 490), Random.nextInt(87, 94));
- Time.sleep(Random.nextInt(500, 700));
- Mouse.click(true);
- Time.sleep(Random.nextInt(1000, 2000));
- }
- private AlphaComposite makeComposite(float alpha) {
- int type = AlphaComposite.SRC_OVER;
- return(AlphaComposite.getInstance(type, alpha));
- }
- private final Font font1 = new Font("Segoe Print", 1, 20);
- private final Font font2 = new Font("Verdana", 0, 12);
- private final Font font3 = new Font("Segoe Print", 0, 12);
- @Override
- public void onRepaint(Graphics g) {
- Graphics2D g2d = (Graphics2D) g;
- Rectangle bg = new Rectangle(10, 60, 200, 110);
- g2d.setComposite(makeComposite(.4f));
- g2d.setColor(Color.BLACK);
- g2d.fill(bg);
- g2d.setFont(font1);
- g2d.setComposite(makeComposite(1f));
- g2d.setColor(Color.RED);
- g2d.drawString("GE Buyer", 53, 80);
- g2d.setFont(font3);
- g2d.drawString("by Thondar", 65, 95);
- g2d.setFont(font2);
- g2d.setComposite(makeComposite(.8f));
- g2d.setColor(Color.WHITE);
- g2d.drawString("Time Run: " + timeRun(), 40, 130);
- g2d.drawString("Version 1.0", 65, 150);
- }
- 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;
- }
- class geGUI extends JFrame {
- public geGUI() {
- initComponents();
- }
- private void StartButtonActionPerformed(ActionEvent e) {
- String a = TimeCB.getSelectedItem().toString(); {
- if (a.equals("Every 5 sec")) {
- SleepTimer = 5000;
- } else if (a.equals("Every 30 sec")) {
- SleepTimer = 30000;
- } else if (a.equals("Every 1 min")) {
- SleepTimer = 60000;
- } else if (a.equals("Every 5 min")) {
- SleepTimer = 300000;
- } else if (a.equals("Every 10 min")) {
- SleepTimer = 600000;
- }
- }
- String b = AmountTF.getText(); {
- ItemAmount = b;
- }
- String c = NameTF.getText(); {
- ItemName = c;
- }
- String d = PerCB.getSelectedItem().toString(); {
- if (d.equals("-10%")) {
- BuyProcent = 1;
- } else if (d.equals("-5%")) {
- BuyProcent = 2;
- } else if (d.equals("0%")) {
- BuyProcent = 3;
- } else if (d.equals("+5%")) {
- BuyProcent = 4;
- } else if (d.equals("+10%")) {
- BuyProcent = 5;
- }
- }
- guiWait = false;
- g.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
- label1 = new JLabel();
- label2 = new JLabel();
- StartButton = new JButton();
- TimeCB = new JComboBox();
- label3 = new JLabel();
- label4 = new JLabel();
- label5 = new JLabel();
- AmountTF = new JTextField();
- label6 = new JLabel();
- NameTF = new JTextField();
- PerCB = new JComboBox();
- label7 = new JLabel();
- //======== this ========
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- label1 ----
- label1.setText("Grand Exchange Buyer");
- label1.setHorizontalAlignment(SwingConstants.CENTER);
- label1.setFont(new Font("Segoe Print", Font.BOLD, 26));
- contentPane.add(label1);
- label1.setBounds(5, 5, 375, 55);
- //---- label2 ----
- label2.setText("By Thondar");
- label2.setHorizontalAlignment(SwingConstants.CENTER);
- label2.setFont(new Font("Segoe Print", Font.PLAIN, 14));
- contentPane.add(label2);
- label2.setBounds(0, 50, 385, 25);
- //---- StartButton ----
- StartButton.setText("Start");
- StartButton.setFont(new Font("Verdana", Font.PLAIN, 16));
- StartButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- StartButtonActionPerformed(e);
- }
- });
- contentPane.add(StartButton);
- StartButton.setBounds(0, 500, 395, 55);
- //---- TimeCB ----
- TimeCB.setFont(new Font("Verdana", Font.PLAIN, 12));
- TimeCB.setModel(new DefaultComboBoxModel(new String[] {
- "Every 5 sec",
- "Every 30 sec",
- "Every 1 min",
- "Every 2 min",
- "Every 5 min",
- "Every 10 min"
- }));
- contentPane.add(TimeCB);
- TimeCB.setBounds(80, 300, 235, 30);
- //---- label3 ----
- label3.setText("How often do you want the bot to check");
- label3.setFont(new Font("Verdana", Font.PLAIN, 12));
- label3.setHorizontalAlignment(SwingConstants.CENTER);
- contentPane.add(label3);
- label3.setBounds(0, 260, 395, 24);
- //---- label4 ----
- label4.setText("if an item has been bought?");
- label4.setHorizontalAlignment(SwingConstants.CENTER);
- label4.setFont(new Font("Verdana", Font.PLAIN, 12));
- contentPane.add(label4);
- label4.setBounds(0, 280, 395, 20);
- //---- label5 ----
- label5.setText("Enter the amount you want the bot to buy at a time");
- label5.setFont(new Font("Verdana", Font.PLAIN, 12));
- label5.setHorizontalAlignment(SwingConstants.CENTER);
- contentPane.add(label5);
- label5.setBounds(0, 95, 395, 30);
- contentPane.add(AmountTF);
- AmountTF.setBounds(160, 125, 75, 25);
- //---- label6 ----
- label6.setText("Enter the EXACT name of the item you want the bot to buy");
- label6.setHorizontalAlignment(SwingConstants.CENTER);
- label6.setFont(new Font("Verdana", Font.PLAIN, 12));
- contentPane.add(label6);
- label6.setBounds(0, 180, 395, 20);
- contentPane.add(NameTF);
- NameTF.setBounds(30, 200, 335, 25);
- //---- PerCB ----
- PerCB.setFont(new Font("Verdana", Font.PLAIN, 12));
- PerCB.setModel(new DefaultComboBoxModel(new String[] {
- "-10%",
- "-5%",
- "0%",
- "+5%",
- "+10%"
- }));
- contentPane.add(PerCB);
- PerCB.setBounds(160, 410, 75, 30);
- PerCB.setSelectedIndex(2);
- //---- label7 ----
- label7.setText("What Percentage to buy at?");
- label7.setFont(new Font("Verdana", Font.PLAIN, 12));
- label7.setHorizontalAlignment(SwingConstants.CENTER);
- contentPane.add(label7);
- label7.setBounds(0, 390, 395, label7.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Jonas Bill Jensen
- private JLabel label1;
- private JLabel label2;
- private JButton StartButton;
- private JComboBox TimeCB;
- private JLabel label3;
- private JLabel label4;
- private JLabel label5;
- private JTextField AmountTF;
- private JLabel label6;
- private JTextField NameTF;
- private JComboBox PerCB;
- private JLabel label7;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment