Advertisement
Guest User

Untitled

a guest
Aug 19th, 2015
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.50 KB | None | 0 0
  1. package scripts.moneymaking.iplankfarmer;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Image;
  8. import java.awt.Point;
  9. import java.text.DecimalFormat;
  10. import java.util.ArrayList;
  11. import java.util.Iterator;
  12. import java.util.LinkedList;
  13. import java.util.List;
  14.  
  15. import org.tribot.api.General;
  16. import org.tribot.api.Timing;
  17. import org.tribot.api.input.Mouse;
  18. import org.tribot.api2007.Game;
  19. import org.tribot.api2007.Login;
  20. import org.tribot.api2007.Screen;
  21. import org.tribot.api2007.Skills;
  22. import org.tribot.api2007.Walking;
  23. import org.tribot.api2007.WebWalking;
  24. import org.tribot.api2007.Login.STATE;
  25. import org.tribot.script.EnumScript;
  26. import org.tribot.script.ScriptManifest;
  27. import org.tribot.script.interfaces.MouseActions;
  28. import org.tribot.script.interfaces.MousePainting;
  29. import org.tribot.script.interfaces.MouseSplinePainting;
  30. import org.tribot.script.interfaces.Painting;
  31.  
  32. import scripts.methods.Methods;
  33. import scripts.moneymaking.iplankfarmer.banking.Bank;
  34. import scripts.moneymaking.iplankfarmer.banking.Potions;
  35. import scripts.moneymaking.iplankfarmer.banking.VarrockTab;
  36. import scripts.moneymaking.iplankfarmer.equipment.Axe;
  37. import scripts.moneymaking.iplankfarmer.equipment.DuelRing;
  38. import scripts.moneymaking.iplankfarmer.player.Data;
  39. import scripts.moneymaking.iplankfarmer.sawmill.Sawmill;
  40. import scripts.moneymaking.iplankfarmer.types.EnergyPotion;
  41. import scripts.moneymaking.iplankfarmer.types.LoginState;
  42. import scripts.moneymaking.iplankfarmer.types.Plank;
  43. import scripts.moneymaking.iplankfarmer.types.ScriptTask;
  44. import scripts.moneymaking.iplankfarmer.types.State;
  45. import scripts.moneymaking.iplankfarmer.utils.AntiBan;
  46. import scripts.moneymaking.iplankfarmer.utils.Locations;
  47. import scripts.moneymaking.iplankfarmer.utils.Zybez;
  48. import scripts.moneymaking.iplankfarmer.woodcutting.Woodcutting;
  49.  
  50. @ScriptManifest(authors = { "iant06" }, category = "Money Making", name = "iPlankFarmer")
  51.  
  52. public class Script extends EnumScript<State> implements Painting,
  53. MouseSplinePainting, MousePainting, MouseActions {
  54.  
  55. private AntiBan antiBan = null;
  56. private Axe axe = null;
  57. private Bank banking = null;
  58. private Data data = null;
  59. private DuelRing duelRing = null;
  60. private Potions potions = null;
  61. private Sawmill sawmill = null;
  62. private Woodcutting woodcutting = null;
  63. private VarrockTab varrockTab = null;
  64. private GUI gui = null;
  65. private EnergyPotion energyPotion = null;
  66. private DecimalFormat decimalFormat = new DecimalFormat("#.##");
  67.  
  68. private ScriptTask task;
  69. private Plank plank;
  70. private State state;
  71.  
  72. private double plankPrice = -1;
  73. private double logPrice = -1;
  74. private double energyPotionPrice = -1;
  75. private double crushedNestPrice = -1;
  76. private double duelRingPrice = -1;
  77. private double hoursToRun = -1;
  78.  
  79. private boolean endScript = false;
  80.  
  81. public final String PAINT_PICTURE_URL = "http://i42.tinypic.com/2i9ines.png";
  82.  
  83. public final Image PAINT_IMG = Methods.getImage(PAINT_PICTURE_URL);
  84.  
  85.  
  86. @Override
  87. public void onPaint(Graphics g) {
  88. ((Graphics2D)g).drawImage(PAINT_IMG, 1, 265, null);
  89. g.setColor(Color.WHITE);
  90. g.setFont(new Font("default", Font.BOLD, 12));
  91. g.drawString(getStateToString(), 190, 358);
  92. g.drawString(getPlankToString(), 115, 377);
  93. int planksPerHr = (int) (getData().getPlanksMade() / ((getRunningTime()) / 3600000D));
  94. g.drawString(getData().getPlanksMade() + " (" + planksPerHr + ")", 160, 397);
  95. double moneyMade = getData().getMoneyMade();
  96. double moneySpent = getData().getMoneySpent();
  97. double gpMade = (moneyMade - moneySpent);
  98. double gpPerHour = (double) (gpMade / ((getRunningTime()) / 3600000D));
  99. g.drawString(setInMoneyFormat(gpMade) + " (" + setInMoneyFormat(gpPerHour) + ")", 136, 417);
  100. g.drawString("Running for: " + Timing.msToString(getRunningTime()), 77, 455);
  101.  
  102. int tripsPerHr = (int) (getData().getTripCount() / ((getRunningTime()) / 3600000D));
  103. g.drawString(getData().getTripCount() + " (" + tripsPerHr + ")", 157, 437);
  104. g.drawString(Timing.msToString(getData().getLastTripTime()), 436, 377);
  105. g.drawString(Timing.msToString(getData().getAverageTripTime()), 436, 397);
  106.  
  107. g.drawString("" + getData().getEntsDetected(), 436, 417);
  108. g.setFont(new Font("default", Font.BOLD, 14));
  109. g.drawString("" + getData().getNestsFound(), 315, 446);
  110. g.drawString(Game.getRunEnergy() + "%", 415, 446);
  111. }
  112.  
  113. @Override
  114. public State getInitialState() {
  115. setGui(new GUI(this));
  116. while(getGui().isVisible()) {
  117. sleep(50, 100);
  118. }
  119. if(data == null) {
  120. setData(new Data(this));
  121. }
  122. if(banking == null) {
  123. setBanking(new Bank(this));
  124. }
  125. if(duelRing == null) {
  126. setDuelRing(new DuelRing(this));
  127. }
  128. if(potions == null) {
  129. setPotions(new Potions(this));
  130. }
  131. if(axe == null) {
  132. setAxe(new Axe(this));
  133. }
  134. if(sawmill == null) {
  135. setSawmill(new Sawmill(this));
  136. }
  137. if(woodcutting == null) {
  138. setWoodcutting(new Woodcutting(this));
  139. }
  140. if(varrockTab == null) {
  141. setVarrockTab(new VarrockTab(this));
  142. }
  143. if(antiBan == null) {
  144. setAntiBan(new AntiBan(this));
  145. }
  146. Walking.setControlClick(true);
  147. WebWalking.setUseRun(true);
  148. println("Script Task: " + getTask().toString() + " Plank Type: " + getPlank().toString());
  149. println("Log Price: " + getLogPrice() + " Plank Price: " + getPlankPrice());
  150. setEnergyPotionPrice(grabEnergyPotionPrice());
  151. setCrushedNestPrice(grabCrushedNestPrice());
  152. setDuelRingPrice(grabDuelRingPrice());
  153. getData().getInitialData();
  154. Mouse.setSpeed(125 + General.random(10, 25));
  155. if(getAxe().isAxeBroken()) {
  156. setState(State.WALKING_TO_BOB);
  157. return State.WALKING_TO_BOB;
  158. }
  159. if(getWoodcutting().isInsideForest()) {
  160. setState(State.CHOPPING_DOWN_TREE);
  161. return State.CHOPPING_DOWN_TREE;
  162. }
  163. setState(State.BANKING);
  164. return State.BANKING;
  165. }
  166.  
  167.  
  168.  
  169. @Override
  170. public State handleState(State state) {
  171. if(isEndScript()) {
  172. getData().endScriptPrint();
  173. Thread.currentThread().interrupt();
  174. return null;
  175. }
  176. if(!isOnBreak() && !isPaused()) {
  177.  
  178. if(Game.getCurrentWorld() >= 380) {
  179. Login.logout();
  180. openWorldScreen();
  181. if(isWorldScreenOpen()) {
  182. selectWorld(randomWorlds[General.random(0, randomWorlds.length - 1)]);
  183. }
  184. }
  185.  
  186. long t = 0;
  187. switch (LoginState()) {
  188.  
  189. case WELCOME_SCREEN:
  190. case LOGIN_SCREEN:
  191. Login.login();
  192. break;
  193.  
  194. case HOW_TO_PLAY:
  195. Mouse.moveBox(13, 470, 97, 491);
  196. General.sleep(100, 300);
  197. Mouse.click(1);
  198. t = System.currentTimeMillis();
  199. while (Timing.timeFromMark(t) < General.random(7000, 10000) && LoginState().equals(LoginState.HOW_TO_PLAY)) {
  200. General.sleep(300);
  201. }
  202. General.sleep(100);
  203. break;
  204.  
  205. case LOBBY:
  206. Mouse.moveBox(280, 296, 495, 374);
  207. General.sleep(100, 300);
  208. Mouse.click(1);
  209. t = System.currentTimeMillis();
  210. while (Timing.timeFromMark(t) < General.random(7000, 10000) && LoginState().equals(LoginState.LOBBY)) {
  211. General.sleep(300);
  212. }
  213. General.sleep(100);
  214. break;
  215. }
  216. state = getState() != null ? getState() : getInitialState();
  217. getData().setCurrentXP(Skills.getXP(Skills.SKILLS.MINING));
  218. getData().setCurrentLevel(Skills.getActualLevel(Skills.SKILLS.MINING));
  219. getData().checkPlayerRun();
  220. switch(state) {
  221. case BANKING:
  222. if(Locations.isInsideBank() || Locations.isInsideCastleWars()) {
  223. getBanking().performBankTask();
  224. if(getBanking().isFinished()) {
  225. switch(getTask()) {
  226. case CHOP:
  227. setState(State.WALKING_TO_TREE);
  228. return State.WALKING_TO_TREE;
  229. case CHOP_AND_PLANK:
  230. if(getPlank().equals(Plank.TEAK)) {
  231. if(Locations.isInsideBank()) {
  232. setState(State.WALKING_TO_SAWMILL);
  233. return State.WALKING_TO_SAWMILL;
  234. }
  235. }
  236. setState(State.WALKING_TO_TREE);
  237. return State.WALKING_TO_TREE;
  238. case PLANK:
  239. setState(State.WALKING_TO_SAWMILL);
  240. return State.WALKING_TO_SAWMILL;
  241. }
  242. }
  243. }
  244. setState(State.WALKING_TO_BANK);
  245. return State.WALKING_TO_BANK;
  246.  
  247. case WALKING_TO_TREE:
  248. getWoodcutting().walkToForest();
  249. return State.WALKING_TO_TREE;
  250.  
  251. case CHOPPING_DOWN_TREE:
  252. if(getWoodcutting().canChop()) {
  253. getWoodcutting().chopTree(getWoodcutting().getClosestTree());
  254. return State.CHOPPING_DOWN_TREE;
  255. }
  256. switch(getTask()) {
  257. case CHOP:
  258. case CHOP_AND_PLANK:
  259. if(getPlank().equals(Plank.TEAK)) {
  260. if(getDuelRing().isWearing()) {
  261. getDuelRing().rub();
  262. } else {
  263. getVarrockTab().teleport();
  264. }
  265. setState(State.BANKING);
  266. return State.BANKING;
  267. }
  268. setState(State.WALKING_TO_SAWMILL);
  269. return State.WALKING_TO_SAWMILL;
  270.  
  271. }
  272. setState(State.CHOPPING_DOWN_TREE);
  273. return State.CHOPPING_DOWN_TREE;
  274.  
  275. case WALKING_TO_SAWMILL:
  276. getSawmill().walkToOperator();
  277. return State.WALKING_TO_SAWMILL;
  278.  
  279. case MAKING_PLANKS:
  280. if(Locations.isInsideSawmill()) {
  281. getSawmill().performSawmillTask();
  282. if(getSawmill().isFinished()) {
  283. setState(State.WALKING_TO_BANK);
  284. return State.WALKING_TO_BANK;
  285. }
  286. return State.MAKING_PLANKS;
  287. }
  288. setState(State.WALKING_TO_SAWMILL);
  289. return State.WALKING_TO_SAWMILL;
  290.  
  291. case WALKING_TO_BANK:
  292. getBanking().walkToBooth();
  293. return State.WALKING_TO_BANK;
  294.  
  295. case WALKING_TO_BOB:
  296. getAxe().walkToShop();
  297. return State.WALKING_TO_BOB;
  298.  
  299. case REPAIRING_AXE:
  300. getAxe().repairAxe();
  301. return State.REPAIRING_AXE;
  302.  
  303. }
  304. return null;
  305. }
  306. return State.WAITING;
  307. }
  308.  
  309. private String getStateToString() {
  310. switch(getState()) {
  311. case BANKING:
  312. return "Banking";
  313. case WALKING_TO_TREE:
  314. return "Walking to Tree";
  315. case CHOPPING_DOWN_TREE:
  316. return "Chopping Down Tree";
  317. case WALKING_TO_SAWMILL:
  318. return "Walking to Sawmill";
  319. case MAKING_PLANKS:
  320. return "Making Planks";
  321. case WALKING_TO_BANK:
  322. return "Walking to Bank";
  323. case WALKING_TO_BOB:
  324. return "Walking to Bob";
  325. case REPAIRING_AXE:
  326. return "Repairing Axe";
  327. case WAITING:
  328. return "Waiting";
  329. }
  330. return "Waiting";
  331. }
  332.  
  333. final int[] randomWorlds = {303,304,305,306,309,310,311,312,313,314,317,318,
  334. 319,320,321,322,326,327,328,329,333,334,335,336,338,
  335. 341,342,343,344,345,346,349,350,351,352,353,354,357,358,359,360,
  336. 361,362,366,367,368,369,370,373,374,375,376,377,378
  337. };
  338.  
  339. final int[] WORLD_COLUMN_1 = {301,302,303,304,305,306,308,309,310,311,312,313,314,316,317,318},
  340. WORLD_COLUMN_2 = {319,320,321,322,325,326,327,328,329,330,333,334,335,336,337,338},
  341. WORLD_COLUMN_3 = {341,342,343,344,345,346,349,350,351,352,353,354,357,358,359,360},
  342. WORLD_COLUMN_4 = {361,362,365,366,367,368,369,370,373,374,375,376,377,378};
  343.  
  344.  
  345.  
  346. final int[][] WORLD_LIST = { WORLD_COLUMN_1, WORLD_COLUMN_2, WORLD_COLUMN_3, WORLD_COLUMN_4 };
  347.  
  348. final int topX = 220,
  349. topY = 80,
  350. X_MULTIPLIER = 100,
  351. Y_MULTIPLIER = 24;
  352.  
  353. private boolean isLoggedOut() {
  354. return !(Login.getLoginState() == STATE.INGAME);
  355. }
  356.  
  357. private void openWorldScreen(){
  358. if(isLoggedOut()){
  359. Mouse.clickBox(10, 471, 88, 488, 1);
  360. sleep(1000,1500);
  361. }
  362. }
  363.  
  364. private boolean isWorldScreenOpen(){
  365. Color wScreen = Screen.getColorAt(100, 100);
  366. return (wScreen.getRed() == 0 && wScreen.getGreen() == 0 && wScreen.getBlue() == 0);
  367. }
  368.  
  369. private boolean selectWorld(int world) {
  370. int wNum = 0,
  371. xPos = 0,
  372. yPos = 0;
  373. for(int x = 0; x < WORLD_LIST.length; x++){
  374. for(int y = 0; y < WORLD_LIST[x].length; y++){
  375. wNum = WORLD_LIST[x][y];
  376. if(wNum == world){
  377. xPos = x * X_MULTIPLIER + topX;
  378. yPos = y * Y_MULTIPLIER + topY;
  379.  
  380. Mouse.click(xPos, yPos, 1);
  381. sleep(1000, 1500);
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. }
  388.  
  389.  
  390. private String getPlankToString() {
  391. switch(getPlank()) {
  392. case REGULAR:
  393. return "Regular Planks";
  394. case OAK:
  395. return "Oak Planks";
  396. case TEAK:
  397. return "Teak Planks";
  398. case MAHOGANY:
  399. return "Mahogany Planks";
  400. }
  401. return "";
  402. }
  403.  
  404. private int grabDuelRingPrice() {
  405. return Zybez.getPrice("ring of dueling");
  406. }
  407.  
  408. private int grabEnergyPotionPrice() {
  409. int averagePrice = 0;
  410. switch(getEnergyPotion()) {
  411. case REGULAR:
  412. averagePrice = Zybez.getPrice("energy");
  413. break;
  414. case SUPER:
  415. averagePrice = Zybez.getPrice("super energy");
  416. break;
  417. }
  418. return averagePrice;
  419. }
  420.  
  421. private int grabCrushedNestPrice() {
  422. return Zybez.getPrice("crushed nest");
  423. }
  424.  
  425. public String setInMoneyFormat(double amount) {
  426. final int ONE_K = 1000;
  427. final int ONE_M = 1000000;
  428. if(amount >= ONE_M) {
  429. return decimalFormat.format(((double) amount / ONE_M)) + "M";
  430. }
  431. if(amount >= ONE_K) {
  432. return decimalFormat.format(((double) amount / ONE_K)) + "K";
  433. }
  434. return "" + decimalFormat.format(amount);
  435. }
  436.  
  437. public LoginState LoginState() {
  438.  
  439. if (Screen.getColorAt(98, 129).equals(new Color(0, 0, 0))) {
  440. return LoginState.WORLD_MENU;
  441. } else if (Screen.getColorAt(423, 248).equals(new Color(255, 255, 0))) {
  442. return LoginState.WELCOME_SCREEN;
  443. } else if (Screen.getColorAt(534, 341).equals(new Color(11, 11, 11))) {
  444. return LoginState.LOGIN_SCREEN;
  445. } else if (Screen.getColorAt(382, 323).equals(new Color(255, 255, 255))) {
  446. return LoginState.HOW_TO_PLAY;
  447. } else if (Screen.getColorAt(365, 340).equals(new Color(255, 255, 255))) {
  448. return LoginState.LOBBY;
  449. } else {
  450. return LoginState.ERROR;
  451. }
  452. }
  453.  
  454.  
  455. public Bank getBanking() {
  456. return banking;
  457. }
  458.  
  459. public void setBanking(Bank banking) {
  460. this.banking = banking;
  461. }
  462.  
  463. public Data getData() {
  464. return data;
  465. }
  466.  
  467. public void setData(Data data) {
  468. this.data = data;
  469. }
  470.  
  471. public Sawmill getSawmill() {
  472. return sawmill;
  473. }
  474.  
  475. public void setSawmill(Sawmill sawmill) {
  476. this.sawmill = sawmill;
  477. }
  478.  
  479. public Woodcutting getWoodcutting() {
  480. return woodcutting;
  481. }
  482.  
  483. public void setWoodcutting(Woodcutting woodcutting) {
  484. this.woodcutting = woodcutting;
  485. }
  486.  
  487. public void setState(State state) {
  488. this.state = state;
  489. }
  490.  
  491. public State getState() {
  492. return state;
  493. }
  494.  
  495. public void setPlank(Plank plank) {
  496. this.plank = plank;
  497. }
  498.  
  499. public Plank getPlank() {
  500. return plank;
  501. }
  502.  
  503. public Axe getAxe() {
  504. return axe;
  505. }
  506.  
  507. public void setAxe(Axe axe) {
  508. this.axe = axe;
  509. }
  510.  
  511. public void setPlankPrice(double plankPrice) {
  512. this.plankPrice = plankPrice;
  513. }
  514.  
  515. public double getPlankPrice() {
  516. return plankPrice;
  517. }
  518.  
  519. public void setEndScript(boolean endScript) {
  520. this.endScript = endScript;
  521. }
  522.  
  523. public boolean isEndScript() {
  524. if(getRunningTime() >= (getHoursToRun() * 3600000)) {
  525. return true;
  526. }
  527. return endScript;
  528. }
  529.  
  530. public double getHoursToRun() {
  531. return hoursToRun;
  532. }
  533.  
  534. public void setHoursToRun(double hoursToRun) {
  535. this.hoursToRun = hoursToRun;
  536. }
  537.  
  538. public void setGui(GUI gui) {
  539. this.gui = gui;
  540. }
  541.  
  542. public GUI getGui() {
  543. return gui;
  544. }
  545.  
  546. public void setEnergyPotion(EnergyPotion energyPotion) {
  547. this.energyPotion = energyPotion;
  548. }
  549.  
  550. public EnergyPotion getEnergyPotion() {
  551. return energyPotion;
  552. }
  553.  
  554. public void setEnergyPotionPrice(int energyPotionPrice) {
  555. this.energyPotionPrice = energyPotionPrice;
  556. }
  557.  
  558. public double getEnergyPotionPrice() {
  559. return energyPotionPrice;
  560. }
  561.  
  562. public ScriptTask getTask() {
  563. return task;
  564. }
  565.  
  566. public void setTask(ScriptTask task) {
  567. this.task = task;
  568. }
  569.  
  570. public void setLogPrice(double logPrice) {
  571. this.logPrice = logPrice;
  572. }
  573.  
  574. public double getLogPrice() {
  575. return logPrice;
  576. }
  577.  
  578. public void setCrushedNestPrice(double crushedNestPrice) {
  579. this.crushedNestPrice = crushedNestPrice;
  580. }
  581.  
  582. public double getCrushedNestPrice() {
  583. return crushedNestPrice;
  584. }
  585.  
  586. public DuelRing getDuelRing() {
  587. return duelRing;
  588. }
  589.  
  590. public void setDuelRing(DuelRing duelRing) {
  591. this.duelRing = duelRing;
  592. }
  593.  
  594. public double getDuelRingPrice() {
  595. return duelRingPrice;
  596. }
  597.  
  598. public void setDuelRingPrice(double duelRingPrice) {
  599. this.duelRingPrice = duelRingPrice;
  600. }
  601.  
  602. public void setPotions(Potions potions) {
  603. this.potions = potions;
  604. }
  605.  
  606. public Potions getPotions() {
  607. return potions;
  608. }
  609.  
  610. public VarrockTab getVarrockTab() {
  611. return varrockTab;
  612. }
  613.  
  614. public void setVarrockTab(VarrockTab varrockTab) {
  615. this.varrockTab = varrockTab;
  616. }
  617.  
  618. public void setAntiBan(AntiBan antiBan) {
  619. this.antiBan = antiBan;
  620. }
  621.  
  622. public AntiBan getAntiBan() {
  623. return antiBan;
  624. }
  625.  
  626. private class Cross {
  627.  
  628. private final long time;
  629. private final Point location;
  630. private final double rot;
  631.  
  632. public Cross(long lifetime, long st, Point loc, double rot) {
  633. this.time = System.currentTimeMillis() + lifetime;
  634. location = loc;
  635. this.rot = rot;
  636. }
  637.  
  638. public long getAge() {
  639. return time - System.currentTimeMillis();
  640. }
  641.  
  642. public int getAlpha() {
  643. return Math.min(255,
  644. Math.max(0, (int) (256.0D * (getAge() / 1500.0D))));
  645. }
  646.  
  647. public boolean handle() {
  648. return System.currentTimeMillis() <= time;
  649. }
  650.  
  651. public double getRot() {
  652. return rot;
  653. }
  654.  
  655. public Point getLocation() {
  656. return location;
  657. }
  658.  
  659. @Override
  660. public boolean equals(Object o) {
  661. if (o instanceof Cross) {
  662. Cross oo = (Cross) o;
  663. return oo.location.equals(this.location);
  664. }
  665. return false;
  666. }
  667.  
  668. }
  669.  
  670. public double getRot() {
  671. return System.currentTimeMillis() % 3600 / 5.0D;
  672. }
  673.  
  674. private final List<Cross> clicks = new LinkedList<Cross>();
  675. private final Object lock = new Object();
  676.  
  677. private boolean paintClick;
  678.  
  679. public boolean isPaintClick() {
  680. return paintClick;
  681. }
  682.  
  683. public void setPaintClick(boolean paintClick) {
  684. this.paintClick = paintClick;
  685. }
  686.  
  687. @Override
  688. public void mouseDragged(Point arg0, int arg1, boolean arg2) {
  689. // TODO Auto-generated method stub
  690.  
  691. }
  692.  
  693. @Override
  694. public void mouseMoved(Point arg0, boolean arg1) {
  695. // TODO Auto-generated method stub
  696.  
  697. }
  698.  
  699. @Override
  700. public void mouseReleased(Point arg0, int arg1, boolean arg2) {
  701. // TODO Auto-generated method stub
  702.  
  703. }
  704.  
  705. @Override
  706. public void paintMouse(Graphics g, Point arg1, Point arg2) {
  707. final Point location = new Point(Mouse.getPos().x, Mouse.getPos().y);
  708. g.setColor(Color.GREEN);
  709. g.drawLine(location.x, location.y - 5, location.x, location.y + 5);
  710. g.drawLine(location.x - 5, location.y, location.x + 5, location.y);
  711. if (isPaintClick()) {
  712. setPaintClick(false);
  713. Cross newCross = new Cross(1500, General.random(40, 300), location,
  714. getRot());
  715. if (!clicks.contains(newCross)) {
  716. clicks.add(newCross);
  717. }
  718. }
  719. synchronized (lock) {
  720. Iterator<Cross> clickIterator = clicks.listIterator();
  721. while (clickIterator.hasNext()) {
  722. Cross toDraw = clickIterator.next();
  723. if (toDraw.handle()) {
  724. drawPoint(toDraw.getLocation(), toDraw.getRot(), g,
  725. toDraw.getAlpha());
  726. } else {
  727. clicks.remove(toDraw);
  728. }
  729. }
  730. }
  731.  
  732. }
  733.  
  734. private void drawPoint(Point location, double rot, Graphics g, int al) {
  735. Graphics2D g1 = (Graphics2D) g.create();
  736. g1.setColor(new Color(255, 0, 0, 155));
  737. g1.rotate(rot, location.x, location.y);
  738. g1.drawLine(location.x, location.y - 5, location.x, location.y + 5);
  739. g1.drawLine(location.x - 5, location.y, location.x + 5, location.y);
  740. }
  741. @Override
  742. public void mouseClicked(Point p, int button, boolean isBot) {
  743. setPaintClick(true);
  744. }
  745.  
  746. @Override
  747. public void paintMouseSpline(Graphics arg0, ArrayList<Point> arg1) {
  748. // TODO Auto-generated method stub
  749.  
  750. }
  751.  
  752. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement