Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. import java.awt.AWTException;
  2. import java.awt.Robot;
  3. import java.awt.event.InputEvent;
  4.  
  5. public class Menu {
  6.  
  7. public static MenuButton back = new MenuButton("back", 3, 3, 80, 25, 20, 150, 30);
  8. public static MenuButton farm = new MenuButton("farm", 400, 150, 440, 265, 60, 200, 200);
  9. public static MenuButton af = new MenuButton("autofarm", 970, 5, 860, 25, 25, 25, 25);
  10. static Window w = Main.w;
  11.  
  12. //All positions for the robot to farm for noob player
  13. static int[] noobMousePositionsX = new int[] {1750, 50, 950, 950, 115, 790, 750, 770, 750, 770, 750, 770, 750, 770, 750, 770, 750, 1750};
  14. static int[] noobMousePositionsY = new int[] {160, 80, 80, 130, 100, 500, 750, 340, 750, 340, 750, 340, 750, 340, 750, 340, 750, 160};
  15.  
  16. //All positions for the robot to farm for legend player
  17. static int[] legendMousePositionsX = new int[] {1510, 390, 750, 950, 300, 620, 700, 715, 700, 715, 700, 715, 700, 715, 700, 715, 700, 1510};
  18. static int[] legendMousePositionsY = new int[] {350, 170, 150, 195, 175, 420, 710, 398, 710, 405, 710, 405, 710, 405, 710, 405, 710, 350};
  19.  
  20. //Array with all the positions of the farming spots [noob/legend][x/y][data]
  21. static int[][][] mousePositions = new int[2][2][noobMousePositionsX.length];
  22.  
  23.  
  24.  
  25. public static void drawAll() {
  26. draw(back);
  27. draw(farm);
  28. draw(af);
  29. click();
  30. }
  31.  
  32. public static void draw(MenuButton b) {
  33.  
  34. w.setColor(0, 0, 0);
  35. w.setFontSize(b.fontSize);
  36. w.drawRect(b.x, b.y, b.width, b.height);
  37. w.drawString(b.name, b.textx, b.texty);
  38. click();
  39. }
  40.  
  41. public static void click() {
  42. if(w.isLeftMouseButtonPressed()) {
  43. double x = w.getMouseX();
  44. double y = w.getMouseY();
  45.  
  46. //BACKBUTTON
  47. if(isClickedInside(back, x, y)) {
  48. Main.player = 2;
  49. }
  50. //FARMBUTTON
  51. else if(isClickedInside(farm, x, y)) {
  52. farm();
  53. }
  54. //AUTOFARMBUTTON
  55. else if(isClickedInside(af, x, y)) {
  56. while(w.isOpen()) {
  57. farm();
  58. try {Thread.sleep(595000);} catch (InterruptedException e1) {e1.printStackTrace();}
  59. Window remind = new Window("ALERT ALERT ALERT ALERT ALERT", 500, 500);
  60. remind.setFontSize(200);
  61. remind.open();
  62. for(int i = 5; i > 0; i--) {
  63. remind.setColor((int) (Math.random()*256), (int) (Math.random()*256), (int) (Math.random()*256));
  64. remind.drawString("" + i, 200, 300);
  65. remind.refreshAndClear();
  66. try {Thread.sleep(1000);} catch (InterruptedException e1) {e1.printStackTrace();}
  67. }
  68. remind.close();
  69. }
  70. }
  71. }
  72. }
  73.  
  74. public static void farm() {
  75.  
  76. Robot robot = null;
  77. try {robot = new Robot();} catch (AWTException e) {e.printStackTrace();}
  78.  
  79. //Click somewhere in the window so the farm() doesn't start over again because the program thinks it's still clicking the farmbutton.
  80. robot.mouseMove(750, 750);
  81. robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
  82. robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
  83.  
  84. //Actually farming.
  85. for(int i = 0; i < noobMousePositionsX.length; i++) {
  86. robot.mouseMove(mousePositions[Main.player][0][i], mousePositions[Main.player][1][i]);
  87. try {Thread.sleep(10);} catch (InterruptedException e1) {e1.printStackTrace();}
  88. robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
  89. robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
  90. try {Thread.sleep(400);} catch (InterruptedException e) {e.printStackTrace();}
  91. }
  92. }
  93.  
  94. public static boolean isClickedInside(MenuButton mb, double x, double y) {
  95. if(x > mb.x && x < mb.x + mb.width && y > mb.y && y < mb.y + mb.height) return true;
  96. else return false;
  97. }
  98.  
  99. public static void initialize() {
  100. int[][] noobMousePositions = new int[2][noobMousePositionsX.length];
  101. int[][] legendMousePositions = new int[2][noobMousePositionsX.length];
  102. for(int i = 0; i < noobMousePositionsX.length; i++) {
  103. noobMousePositions[0][i] = noobMousePositionsX[i];
  104. noobMousePositions[1][i] = noobMousePositionsY[i];
  105.  
  106. legendMousePositions[0][i] = legendMousePositionsX[i];
  107. legendMousePositions[1][i] = legendMousePositionsY[i];
  108. }
  109. mousePositions[0] = noobMousePositions;
  110. mousePositions[1] = legendMousePositions;
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement