Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.AWTException;
- import java.awt.Robot;
- import java.awt.event.InputEvent;
- public class Menu {
- public static MenuButton back = new MenuButton("back", 3, 3, 80, 25, 20, 150, 30);
- public static MenuButton farm = new MenuButton("farm", 400, 150, 440, 265, 60, 200, 200);
- public static MenuButton af = new MenuButton("autofarm", 970, 5, 860, 25, 25, 25, 25);
- static Window w = Main.w;
- //All positions for the robot to farm for noob player
- static int[] noobMousePositionsX = new int[] {1750, 50, 950, 950, 115, 790, 750, 770, 750, 770, 750, 770, 750, 770, 750, 770, 750, 1750};
- static int[] noobMousePositionsY = new int[] {160, 80, 80, 130, 100, 500, 750, 340, 750, 340, 750, 340, 750, 340, 750, 340, 750, 160};
- //All positions for the robot to farm for legend player
- static int[] legendMousePositionsX = new int[] {1510, 390, 750, 950, 300, 620, 700, 715, 700, 715, 700, 715, 700, 715, 700, 715, 700, 1510};
- static int[] legendMousePositionsY = new int[] {350, 170, 150, 195, 175, 420, 710, 398, 710, 405, 710, 405, 710, 405, 710, 405, 710, 350};
- //Array with all the positions of the farming spots [noob/legend][x/y][data]
- static int[][][] mousePositions = new int[2][2][noobMousePositionsX.length];
- public static void drawAll() {
- draw(back);
- draw(farm);
- draw(af);
- click();
- }
- public static void draw(MenuButton b) {
- w.setColor(0, 0, 0);
- w.setFontSize(b.fontSize);
- w.drawRect(b.x, b.y, b.width, b.height);
- w.drawString(b.name, b.textx, b.texty);
- click();
- }
- public static void click() {
- if(w.isLeftMouseButtonPressed()) {
- double x = w.getMouseX();
- double y = w.getMouseY();
- //BACKBUTTON
- if(isClickedInside(back, x, y)) {
- Main.player = 2;
- }
- //FARMBUTTON
- else if(isClickedInside(farm, x, y)) {
- farm();
- }
- //AUTOFARMBUTTON
- else if(isClickedInside(af, x, y)) {
- while(w.isOpen()) {
- farm();
- try {Thread.sleep(595000);} catch (InterruptedException e1) {e1.printStackTrace();}
- Window remind = new Window("ALERT ALERT ALERT ALERT ALERT", 500, 500);
- remind.setFontSize(200);
- remind.open();
- for(int i = 5; i > 0; i--) {
- remind.setColor((int) (Math.random()*256), (int) (Math.random()*256), (int) (Math.random()*256));
- remind.drawString("" + i, 200, 300);
- remind.refreshAndClear();
- try {Thread.sleep(1000);} catch (InterruptedException e1) {e1.printStackTrace();}
- }
- remind.close();
- }
- }
- }
- }
- public static void farm() {
- Robot robot = null;
- try {robot = new Robot();} catch (AWTException e) {e.printStackTrace();}
- //Click somewhere in the window so the farm() doesn't start over again because the program thinks it's still clicking the farmbutton.
- robot.mouseMove(750, 750);
- robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
- //Actually farming.
- for(int i = 0; i < noobMousePositionsX.length; i++) {
- robot.mouseMove(mousePositions[Main.player][0][i], mousePositions[Main.player][1][i]);
- try {Thread.sleep(10);} catch (InterruptedException e1) {e1.printStackTrace();}
- robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
- try {Thread.sleep(400);} catch (InterruptedException e) {e.printStackTrace();}
- }
- }
- public static boolean isClickedInside(MenuButton mb, double x, double y) {
- if(x > mb.x && x < mb.x + mb.width && y > mb.y && y < mb.y + mb.height) return true;
- else return false;
- }
- public static void initialize() {
- int[][] noobMousePositions = new int[2][noobMousePositionsX.length];
- int[][] legendMousePositions = new int[2][noobMousePositionsX.length];
- for(int i = 0; i < noobMousePositionsX.length; i++) {
- noobMousePositions[0][i] = noobMousePositionsX[i];
- noobMousePositions[1][i] = noobMousePositionsY[i];
- legendMousePositions[0][i] = legendMousePositionsX[i];
- legendMousePositions[1][i] = legendMousePositionsY[i];
- }
- mousePositions[0] = noobMousePositions;
- mousePositions[1] = legendMousePositions;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement