Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.81 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.event.KeyEvent;
  4. import java.util.concurrent.TimeUnit;
  5.  
  6. import org.tbot.util.Condition;
  7. import org.tbot.wrappers.GameObject;
  8. import org.tbot.wrappers.Item;
  9. import org.tbot.wrappers.NPC;
  10. import org.tbot.wrappers.Player;
  11. import org.tbot.wrappers.WidgetChild;
  12. import org.tbot.bot.TBot;
  13. import org.tbot.internal.AbstractScript;
  14. import org.tbot.internal.Manifest;
  15. import org.tbot.internal.event.listeners.PaintListener;
  16. import org.tbot.methods.Game;
  17. import org.tbot.methods.Menu;
  18. import org.tbot.methods.Mouse;
  19. import org.tbot.methods.Npcs;
  20. import org.tbot.methods.Players;
  21. import org.tbot.methods.Random;
  22. import org.tbot.methods.Shop;
  23. import org.tbot.methods.Time;
  24. import org.tbot.methods.Widgets;
  25. import org.tbot.methods.input.keyboard.Keyboard;
  26. import org.tbot.methods.tabs.Inventory;
  27. @Manifest(name = "featherPacks", authors = "James", version = 0.1, description = "Buys/Hops")
  28. public class featherPacks extends AbstractScript implements PaintListener{
  29. GameObject rocks;
  30.  
  31. public enum State {
  32. WAIT, BUY, OPEN, HOP, LOGIN;
  33. }
  34. private int mY, mX;
  35. char f4 = KeyEvent.VK_F4;
  36. int barsGained=0;
  37. private int moneyBefore= Inventory.getCount(995);
  38. private long timeBegan;
  39. private long timeRan;
  40. char control = KeyEvent.VK_CONTROL;
  41. int invb4;
  42. boolean cool=false;
  43. int i=0;
  44. int totalGold=0;
  45. int totalCoal=0;
  46. int totalIron=0;
  47. int invcount=0;
  48. boolean hopp=false;
  49. int moneyGained=0;
  50. int sold=0;
  51. int now=0;
  52.  
  53. int p=0;
  54. Item myItem;
  55. int feath=0;
  56. int inv1=0;
  57. int currfeath=0;
  58. NPC banker;
  59. NPC shantay;
  60. int[] worldArray;
  61. String haha="18109";
  62. int accCount;
  63. private int currentWorld;
  64. boolean logCountC=false;
  65. private String currentState = "";
  66. WidgetChild welcomeScreen = Widgets.getWidget(378, 17);
  67. private final Condition WELCOME = new Condition(){
  68. public boolean check(){
  69. return (welcomeScreen.isVisible());
  70. }
  71. };
  72. private final Condition SHOP_OPEN = new Condition(){
  73. public boolean check(){
  74. return (Shop.isOpen());
  75. }
  76. };
  77. private final Condition DROPPED = new Condition(){
  78. public boolean check(){
  79. return ((Inventory.getCount(11881)<inv1));
  80. }
  81. };
  82. private State getState(){
  83. currfeath=Inventory.getCount(314);
  84. invcount = Inventory.getCount();
  85. if(!welcomeScreen.isValid() && !Game.isLoggedIn())
  86. {
  87. return State.LOGIN;
  88. }
  89. if(!Inventory.contains(11881))
  90. {
  91. cool=false;
  92. }
  93. if(welcomeScreen.isValid())
  94. welcome();
  95. if (!welcomeScreen.isValid() && Shop.isOpen())
  96. Time.sleepUntil(SHOP_OPEN,500);
  97.  
  98. if(Shop.isOpen() && Shop.getItem(11881).getStackSize()<26)
  99. {
  100. return State.HOP;
  101. }
  102. //buy
  103. if(!welcomeScreen.isValid() && (Game.isLoggedIn() && Npcs.getNearest(4642)!=null) && !Inventory.isFull() && cool!=true)
  104. return State.BUY;
  105. if(!welcomeScreen.isValid() && (Game.isLoggedIn() && Npcs.getNearest(4642)!=null) && Inventory.isFull() && cool!=true)
  106. {
  107. cool=true;
  108. return State.OPEN;
  109. }
  110. if(hopp=true && cool==true && !Inventory.containsOneOf(11881))
  111. {
  112. return State.HOP;
  113. }
  114. if(Inventory.getCount(11881)<2)
  115. {
  116. hopp=true;
  117. }
  118. if(Game.isLoggedIn() && Npcs.getNearest(4642)==null)
  119. {
  120.  
  121. //logout();
  122. }
  123. return State.WAIT;
  124. }
  125. @Override
  126. public int loop() {
  127. try{
  128. switch (getState()) {
  129. case BUY:
  130. currentState = "Buying";
  131. loot();
  132. break;
  133. case HOP:
  134. currentState = "Hopping";
  135. hop();
  136. break;
  137. case WAIT:
  138. currentState = "Waiting";
  139. Time.sleep(400);
  140. break;
  141. case LOGIN:
  142. currentState = "Logging in";
  143. login();
  144. break;
  145. case OPEN:
  146. currentState = "Opening";
  147. open();
  148. break;
  149. default:
  150. log("Error, Stopping the script.");
  151. return -1;
  152. }
  153. }catch(Exception e)
  154. {
  155.  
  156. }
  157. return 0;
  158. }
  159.  
  160. @Override
  161. public boolean onStart(){
  162. feath=Inventory.getCount(314);
  163. worldArray=new int[]{
  164. 302, 303, 305, 305, 306, 309, 310, 314, 317, 318, 322, 327, 328, 329, 330, 333, 334, 336, 341,
  165. 342, 343, 344, 346, 350, 351, 352, 354, 358, 362, 365, 367, 368, 369, 370, 375, 376, 377, 386
  166. };
  167. Mouse.setSpeed(50);
  168. timeBegan = System.currentTimeMillis();
  169. return true;
  170. }
  171. int money=(int) (moneyGained * 3600000D / (System.currentTimeMillis() - timeBegan));
  172.  
  173. @Override
  174.  
  175. public void onRepaint(Graphics g) {
  176. g.setColor(Color.WHITE);
  177. mX = Mouse.getX();
  178. mY = Mouse.getY();
  179. g.drawLine(mX-1, mY+5, mX-1, mY-5);
  180. g.drawLine(mX, mY+6, mX, mY-6);
  181. g.drawLine(mX+1, mY+5, mX+1, mY-5);
  182. g.drawLine(mX+5, mY-1, mX-5, mY-1);
  183. g.drawLine(mX+6, mY, mX-6, mY);
  184. g.drawLine(mX+5, mY+1, mX-5, mY+1);
  185. timeRan = System.currentTimeMillis() - this.timeBegan;
  186. g.drawString("Money spent: " + (moneyBefore-Inventory.getCount(995)), 20, 325);
  187. g.drawString("Time: " + ft(timeRan), 20, 310);
  188. g.drawString("Money p/hr: " + ((moneyGained * 3600000D )/( (System.currentTimeMillis() - timeBegan))),20, 295);
  189. g.drawString("World: " + currentWorld, 20, 280);
  190. g.drawString("State: " + currentState, 20, 265);
  191. g.drawString("Iron earned: " + (totalIron), 20, 250);
  192. g.drawString("Coal earned: " + ("sold: " + sold), 20, 235);
  193. g.drawString("Gold earned: " + (totalGold), 20, 220);
  194. g.drawString("Money earned: " + (((currfeath-feath)*3)-(moneyBefore-Inventory.getCount(995))), 20, 205);
  195. //g.drawRect(15, 250, 125, 80);
  196. //
  197. currentWorld = Game.getCurrentWorld();
  198. }
  199. //Other methods
  200. private void logout()
  201. {
  202. if(!Widgets.isOpen(Widgets.TAB_LOGOUT))
  203. Widgets.openTab(Widgets.TAB_LOGOUT);
  204. Game.logout();
  205. TBot.getBot().getScriptHandler().stopScript();
  206. }
  207. private void loot()
  208. {
  209. myItem=null;
  210. shantay = Npcs.getNearest(4642);
  211. if (!Shop.isOpen()){
  212. if(shantay.interact("Trade"))
  213. {
  214. Time.sleepUntil(SHOP_OPEN, 1000);
  215. }
  216. }
  217. Time.sleep(200, 300);
  218. if (Shop.isOpen() && Shop.getItem(11881)!=null && Shop.getItem(11881).getStackSize()>24)
  219. {
  220. Shop.getItem(11881).interact("Buy 10");
  221. }
  222. }
  223. private void welcome(){
  224. WidgetChild welcomeScreen = Widgets.getWidget(378,17);
  225. if(welcomeScreen.isValid()){
  226. welcomeScreen.interact("Play Runescape");
  227. }
  228. }
  229. public void login() {
  230. final WidgetChild wc = Widgets.getWidget(378, 17);
  231. final int state = Game.getGameState();
  232. if (state == 30) {
  233. if (wc != null && wc.isValid() && wc.isVisible()) {
  234. if (wc != null)
  235. if (wc.click())
  236. Time.sleepUntil(new Condition() {
  237. @Override
  238. public boolean check() {
  239. return !wc.isValid() && !wc.isVisible();
  240. }
  241. }, 1500);
  242. }
  243. } else if (state == 10) {
  244. final String loginText = getLoginText();
  245. if (Game.getLoginMenuIndex() == 2) {
  246. final String wantedUsername = "james2@james.com";
  247. final String currentUsername = Game.getCurrentUsername();
  248. final String currentPassword = TBot.getBot().getClient().getCurrentPassword();
  249. final String wantedPassword = TBot.getBot().getCurrentAccount().getPassword();
  250.  
  251. if (currentUsername.equalsIgnoreCase(wantedUsername) && currentPassword.equalsIgnoreCase(wantedPassword)) {
  252. if (Game.getGameState() == 10)
  253. if (Mouse.click((int) (235 + (Math.random() * (370 - 235))), (int) (305 + (Math.random() * (335 - 305))), true))
  254. Time.sleep(Random.nextInt(2000, 3000));
  255. } else {
  256. if (!currentUsername.equalsIgnoreCase(wantedUsername)) {
  257. if (!currentUsername.isEmpty()) {
  258. Mouse.click(Random.nextInt(400, 512), Random.nextInt(307, 330), true);
  259. } else {
  260. Mouse.click((int) (340 + (Math.random() * (450 - 340))), (int) (246 + (Math.random() * (260 - 246))), true);
  261. Keyboard.sendText(wantedUsername);
  262. }
  263. }
  264.  
  265. if (!currentPassword.equalsIgnoreCase(wantedPassword)) {
  266. if (!currentPassword.isEmpty()) {
  267. Mouse.click(Random.nextInt(400, 512), Random.nextInt(307, 330), true);
  268. } else {
  269. Mouse.click((int) (340 + (Math.random() * (450 - 340))), (int) (261 + (Math.random() * (275 - 261))), true);
  270. Keyboard.sendText(wantedPassword);
  271.  
  272. }
  273. }
  274. }
  275. if (loginText.contains("Too many")) {
  276. Time.sleep(3000, 5000);
  277. }
  278.  
  279. if (loginText.contains("exceeded")) {
  280. Game.instaHopNextP2P();
  281. Time.sleep(1000, 2000);
  282. }
  283. if (loginText.contains("disable")) {
  284. TBot.getBot().getScriptHandler().stopScript();
  285.  
  286. } else if (loginText.contains("update")) {
  287. System.exit(0);
  288.  
  289. TBot.getBot().getScriptHandler().stopScript();
  290. }
  291. } else if (loginText.contains("Locked")) {
  292. TBot.getBot().getScriptHandler().stopScript();
  293.  
  294. } else if (Game.getLoginMenuIndex() == 0) {
  295. Mouse.click((int) (395 + (Math.random() * (530 - 395))), (int) (275 + (Math.random() * (305 - 275))), true);
  296. Time.sleep(Random.nextInt(500, 750));
  297. } else if (Game.getLoginMenuIndex() == 3) {
  298. Mouse.click((int) (315 + (Math.random() * (450 - 315))), (int) (335 + (Math.random() * (335 - 305))), true);
  299. Time.sleep(Random.nextInt(500, 750));
  300. }
  301.  
  302. }
  303.  
  304. }
  305. private static String getLoginText() {
  306. return Game.getLoginMessage1() + Game.getLoginMessage2();
  307. }
  308.  
  309. private void hop(){
  310. if (i==worldArray.length)
  311. {
  312. i=0;
  313. }
  314. if(Game.instaHop(worldArray[i]))
  315. Time.sleepUntil(WELCOME,5000);
  316. currentWorld = Game.getCurrentWorld();
  317. i++;
  318. hopp=false;
  319. }
  320. private void open(){
  321. if (Shop.isOpen()){
  322. Shop.close();
  323. }
  324. if (Inventory.contains(11881))
  325. {
  326. Time.sleep(200);
  327. Mouse.click(Inventory.getFirst(11881).getRandomPoint(), true);
  328. Time.sleep(500);
  329. while(Inventory.contains(11881))
  330. {
  331. inv1=Inventory.getCount(11881);
  332. Time.sleepUntil(DROPPED,5000);
  333. if(Inventory.getCount(11881)<inv1)
  334. {
  335. //
  336. }
  337. else
  338. {
  339. open();
  340. }
  341. }
  342. }
  343. }
  344. private String ft(long duration)
  345. {
  346. String res = "";
  347. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  348. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  349. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  350. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  351. .toHours(duration));
  352. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  353. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  354. .toMinutes(duration));
  355. res = (hours + ":" + minutes + ":" + seconds);
  356. return res;
  357. }
  358.  
  359. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement