Guest User

Untitled

a guest
Jul 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.95 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Desktop.Action;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.RenderingHints;
  7.  
  8. import org.powerbot.concurrent.Task;
  9. import org.powerbot.concurrent.strategy.Condition;
  10. import org.powerbot.concurrent.strategy.Strategy;
  11. import org.powerbot.game.api.ActiveScript;
  12. import org.powerbot.game.api.Manifest;
  13. import org.powerbot.game.api.methods.Widgets;
  14. import org.powerbot.game.api.methods.node.Locations;
  15. import org.powerbot.game.api.methods.tab.Inventory;
  16. import org.powerbot.game.api.methods.tab.Skills;
  17. import org.powerbot.game.api.util.Filter;
  18. import org.powerbot.game.api.util.Random;
  19. import org.powerbot.game.api.util.Time;
  20. import org.powerbot.game.api.wrappers.node.Item;
  21. import org.powerbot.game.api.wrappers.node.Location;
  22. import org.powerbot.game.bot.event.listener.PaintListener;
  23.  
  24.  
  25.  
  26. @Manifest(authors = { "Zomah2" }, name = "[HClean]", description = "The best cleaner around nowadays! (theres no others :p)", version = 0.1)
  27. public class HClean extends ActiveScript implements PaintListener {
  28. private final static int GRIMY_AVANTOE_ID = 211;
  29. private final static int CLEAN_AVANTOE_ID = 261;
  30. private int startXP;
  31. private int expGained;
  32. public long startTime = 0;
  33. public long millis = 0;
  34. public long hours = 0;
  35. public long minutes = 0;
  36. public long seconds = 0;
  37. public long last = 0;
  38. public int expHour = 0;
  39. public boolean guiInitialized;
  40.  
  41. @Override
  42. protected void setup() {
  43. startXP = Skills.getExperiences()[15];
  44. startTime = System.currentTimeMillis();
  45. bank banker = new bank();
  46. Strategy BANKACTION = new Strategy((Condition) banker, banker);
  47. provide(BANKACTION);
  48. clean cleaner = new clean();
  49. Strategy CLEANACTION = new Strategy((Condition) cleaner, cleaner);
  50. provide(CLEANACTION);
  51. }
  52. private class bank implements Task, Condition {
  53.  
  54. @Override
  55. public void run() {
  56. final Location bankChest = Locations.getNearest(new Filter<Location>() {
  57. public boolean accept(final Location loc) {
  58. return loc.getId() == 42192;
  59. }
  60. });
  61. if (bankChest != null) {
  62. if (Random.nextInt(0, 200) < 10) {
  63. bankChest.interact("use");
  64. Time.sleep(1000);
  65. } else {
  66. bankChest.click(true);
  67. Time.sleep(1000);
  68. }
  69. }
  70. if (Inventory.getItems().length == 0) {
  71. Widgets.get(762, 99).interact("Withdraw-All");
  72. Time.sleep(Random.nextInt(137, 241));
  73. } else {
  74. Widgets.get(762, 34).click(true);
  75. Widgets.get(762, 99).interact("Withdraw-All");
  76. Time.sleep(Random.nextInt(337, 447));
  77. Widgets.get(762, 45).click(true);
  78. }
  79. if (!cont() && Inventory.getItems().length > 0) {
  80. log.info("out of herbs.");
  81. stop();
  82. }
  83. }
  84. @Override
  85. public boolean validate() {
  86. return Widgets.get(762, 1).isOnScreen() && guiInitialized;
  87. }
  88. public boolean cont() {
  89. for (Item i : Inventory.getItems()) {
  90. if (i.getId() == GRIMY_AVANTOE_ID) {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. }
  97.  
  98. private class clean implements Task, Condition {
  99.  
  100. @Override
  101. public void run() {
  102. for (Item i : Inventory.getItems()) {
  103. if (i.getId() == GRIMY_AVANTOE_ID) {
  104. i.getWidgetChild().interact("Clean");
  105. }
  106. }
  107. }
  108. @Override
  109. public boolean validate() {
  110. if (Inventory.getCount() >= 1) {
  111. for (Item i : Inventory.getItems()) {
  112. if (i.getId() == GRIMY_AVANTOE_ID) {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. return false;
  119. }
  120.  
  121. }
  122. public void onRepaint(Graphics graphics) {
  123. Graphics2D g = (Graphics2D) graphics;
  124. expHour = (int) ((expGained) * 3600000D / (System
  125. .currentTimeMillis()- startTime));
  126. millis = System.currentTimeMillis() - startTime;
  127. hours = millis / (1000 * 60 * 60);
  128. millis -= hours * (1000 * 60 * 60);
  129. minutes = millis / (1000 * 60);
  130. millis -= minutes * (1000 * 60);
  131. seconds = millis / 1000;
  132. expGained = Skills.getExperiences()[15] - startXP;
  133. g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF));
  134. g.setColor(new Color(0, 102, 51));
  135. g.fillRoundRect(6, 344, 507, 129, 5, 5);
  136. g.setColor(new Color(102, 255, 102));
  137. g.setFont(new Font("Arial", 0, 10));
  138. g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds, 19, 378);
  139. g.setColor(new Color(102, 255, 102));
  140. g.setFont(new Font("Arial", 0, 10));
  141. g.drawString("XP Gained: "+expGained, 20, 411);
  142. g.setColor(new Color(102, 255, 102));
  143. g.setFont(new Font("Arial", 0, 10));
  144. g.drawString("XP/HR: "+ expHour, 19, 430);
  145. g.setColor(new Color(102, 255, 102));
  146. g.setFont(new Font("Arial", 0, 25));
  147. g.drawString("HClean by Zomah2", 248, 452);
  148. g.setColor(new Color(153, 0, 0));
  149. }
  150. public boolean cont() {
  151. // TODO Auto-generated method stub
  152. return false;
  153. }
  154. public void withdraw(int i, int j) {
  155. // TODO Auto-generated method stub
  156.  
  157. }
Add Comment
Please, Sign In to add comment