Guest User

AntiBan.java

a guest
Jan 8th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1.  
  2. package scripts;
  3.  
  4. import org.tribot.api.General;
  5. import org.tribot.api.Timing;
  6. import org.tribot.api.types.generic.Condition;
  7. import org.tribot.api.util.ABCUtil;
  8. import org.tribot.api2007.GameTab;
  9. import org.tribot.api2007.Player;
  10. import org.tribot.api2007.Skills;
  11.  
  12. public class AntiBan {
  13.  
  14. public String antiban_status;
  15. public long antiban_performed;
  16. public ABCUtil abc;
  17. private long last_anti_ban_action;
  18. private Skills.SKILLS hover_skill;
  19.  
  20. public AntiBan() {
  21. General.useAntiBanCompliance(true);
  22. log("Starting antiban");
  23. abc = new ABCUtil();
  24. antiban_performed = 0;
  25. antiban_status = "Waiting";
  26. last_anti_ban_action = 0;
  27. }
  28.  
  29. public void setHoverSkill(Skills.SKILLS skill) {
  30. this.hover_skill = skill;
  31. }
  32.  
  33. private boolean openGameTab(GameTab.TABS tab) {
  34. if (GameTab.open(tab)) {
  35. Timing.waitCondition(new Condition() {
  36. @Override
  37. public boolean active() {
  38. // control cpu usage
  39. General.sleep(150, 250);
  40. // ensure we have opened the tab
  41. return GameTab.getOpen() == tab;
  42. }
  43. }, General.random(1000, 2000));
  44.  
  45. return true;
  46. }
  47.  
  48. return false;
  49. }
  50.  
  51. private boolean performTabAntiBan(long next, GameTab.TABS tab) {
  52.  
  53. if (System.currentTimeMillis() >= next && GameTab.getOpen() != tab) {
  54. log("Performing check tab anti ban");
  55. if (openGameTab(tab)) {
  56. antiban_status = "Performing antiban action";
  57. antiban_performed ++;
  58. log("Successfully performed check tab "+"("+tab+") antiban");
  59. return true;
  60. };
  61.  
  62. return true;
  63. }
  64.  
  65. return false;
  66.  
  67. }
  68.  
  69. private void log(String string) {
  70. System.out.println(string);
  71. }
  72.  
  73. public void handleWait() {
  74. antiban_status = "Checking";
  75.  
  76. if (Timing.timeFromMark(last_anti_ban_action) >= 180000) {
  77.  
  78. if (GameTab.getOpen() != GameTab.TABS.STATS && this.hover_skill != null) {
  79. if (hoverSkill(this.hover_skill)) {
  80. resetTimer();
  81. return;
  82. };
  83. }
  84.  
  85. if (Player.isMoving() || Player.getAnimation() != -1 && General.random(1, 100) == 100) {
  86. checkGameTabAntiBan();
  87. } else if (General.random(1, 100) > 50) {
  88. checkMouseAntiBan();
  89. }
  90.  
  91. antiban_status = "Waiting";
  92. }
  93. }
  94.  
  95. public void resetTimer() {
  96. last_anti_ban_action = Timing.currentTimeMillis();
  97. }
  98.  
  99. public boolean hoverSkill(Skills.SKILLS skill) {
  100. if (openGameTab(GameTab.TABS.STATS)) {
  101. if (skill.hover()) {
  102. Timing.waitCondition(new Condition() {
  103. @Override
  104. public boolean active() {
  105. // control cpu usage
  106. General.sleep(150, 250);
  107. // ensure we have opened the tab
  108. return GameTab.getOpen() == GameTab.TABS.STATS && skill.hover();
  109. }
  110. }, General.random(2000, 6000));
  111.  
  112. return true;
  113. }
  114. }
  115.  
  116. return false;
  117. }
  118.  
  119. public void checkMouseAntiBan() {
  120. if (System.currentTimeMillis() >= abc.TIME_TRACKER.EXAMINE_OBJECT.next()) {
  121. log("Examine object antiban");
  122. abc.performExamineObject();
  123. }
  124.  
  125. if (System.currentTimeMillis() >= abc.TIME_TRACKER.ROTATE_CAMERA.next()) {
  126. log("Performing rotate camera anti ban");
  127. abc.performRotateCamera();
  128. }
  129.  
  130. if (System.currentTimeMillis() >= abc.TIME_TRACKER.PICKUP_MOUSE.next()) {
  131. log("Performing pickup mouse anti ban");
  132. abc.performPickupMouse();
  133. }
  134.  
  135. if (System.currentTimeMillis() >= abc.TIME_TRACKER.LEAVE_GAME.next()) {
  136. log("Performing mouse leave game anti ban");
  137. abc.performLeaveGame();
  138. }
  139.  
  140. if (System.currentTimeMillis() >= abc.TIME_TRACKER.RANDOM_MOUSE_MOVEMENT.next()) {
  141. log("Performing mouse movement anti ban");
  142. abc.performRandomMouseMovement();
  143. }
  144.  
  145. if (System.currentTimeMillis() >= abc.TIME_TRACKER.RANDOM_MOUSE_MOVEMENT.next()) {
  146. log("Performing mouse right click anti ban");
  147. abc.performRandomRightClick();
  148. }
  149.  
  150. resetTimer();
  151. }
  152.  
  153. public void checkGameTabAntiBan() {
  154. switch (General.random(1, 5)) {
  155. case 1:
  156. if (performTabAntiBan(abc.TIME_TRACKER.CHECK_EQUIPMENT.next(), GameTab.TABS.EQUIPMENT)) {
  157. abc.TIME_TRACKER.CHECK_EQUIPMENT.reset();
  158. };
  159. break;
  160. case 2:
  161.  
  162. if (performTabAntiBan(abc.TIME_TRACKER.CHECK_FRIENDS.next(), GameTab.TABS.FRIENDS)) {
  163. abc.TIME_TRACKER.CHECK_FRIENDS.reset();
  164. };
  165. break;
  166.  
  167. case 3:
  168.  
  169. if (performTabAntiBan(abc.TIME_TRACKER.CHECK_COMBAT.next(), GameTab.TABS.COMBAT)) {
  170. abc.TIME_TRACKER.CHECK_COMBAT.reset();
  171. };
  172. break;
  173.  
  174. case 4:
  175.  
  176. if (performTabAntiBan(abc.TIME_TRACKER.CHECK_MUSIC.next(), GameTab.TABS.MUSIC)) {
  177. abc.TIME_TRACKER.CHECK_MUSIC.reset();
  178. };
  179. break;
  180.  
  181. case 5:
  182.  
  183. if (performTabAntiBan(abc.TIME_TRACKER.CHECK_QUESTS.next(), GameTab.TABS.QUESTS)) {
  184. abc.TIME_TRACKER.CHECK_QUESTS.reset();
  185. };
  186. break;
  187. }
  188.  
  189. resetTimer();
  190. }
  191. }
Add Comment
Please, Sign In to add comment