Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import xobot.client.callback.listeners.MessageListener;
  4. import xobot.client.callback.listeners.PaintListener;
  5. import xobot.script.ActiveScript;
  6. import xobot.script.Manifest;
  7. import xobot.script.methods.*;
  8. import xobot.script.methods.input.KeyBoard;
  9. import xobot.script.methods.tabs.Inventory;
  10. import xobot.script.util.Time;
  11. import xobot.script.util.Timer;
  12. import xobot.script.wrappers.Area;
  13. import xobot.script.wrappers.Tile;
  14. import xobot.script.wrappers.WidgetChild;
  15. import xobot.script.wrappers.interactive.GameObject;
  16. import xobot.script.wrappers.interactive.NPC;
  17.  
  18. @Manifest(authors = { "Cyan" }, name = "CyanEssence")
  19. public class CyanEssence extends ActiveScript implements PaintListener, MessageListener{
  20.  
  21. private Timer t;
  22. private int essence;
  23. private Area essenceMine = new Area(new Tile(2884, 4859), new Tile(2935,4806));
  24. private String status;
  25.  
  26.  
  27. public boolean onStart() {
  28.  
  29. t = new Timer(System.currentTimeMillis());
  30. essence = 0;
  31. return true;
  32. }
  33.  
  34.  
  35. @Override
  36. public int loop() {
  37.  
  38. GameObject bankBooth = GameObjects.getNearest(6943);
  39.  
  40. if(Inventory.isFull()) {
  41. if(bankBooth != null) {
  42. if (Bank.isOpen()) {
  43. System.out.println("Depositing...");
  44. status = "Depositing...";
  45. Bank.depositAll();
  46. essence += 28;
  47. return 1000;
  48. } else {
  49. System.out.println("Banking...");
  50. status = "Banking...";
  51. bankBooth.interact("bank");
  52. return 2000;
  53. }
  54. } else {
  55. System.out.println("Telporting home...");
  56. status = "Teleporting home...";
  57. Packets.sendAction(-1,11075586,41,0,"","Continue"); //incase of levelup (stops the home tele)
  58. teleHome();
  59. return 2000;
  60. }
  61.  
  62. } else {
  63.  
  64. if(isAtEssMine()) {
  65. if (!Players.getMyPlayer().isMoving() && Players.getMyPlayer().getAnimation() == -1) {
  66. System.out.println("Mining...");
  67. status = "Mining...";
  68. GameObject essenceRock = GameObjects.getNearest(7471);
  69. essenceRock.interact("mine");
  70.  
  71. }
  72. } else {
  73. System.out.println("Teleporting to essence mine...");
  74. status = "Teleporting to esence mine...";
  75. teleport("essence mine");
  76. return 2000;
  77. }
  78. return 100;
  79. }
  80. }
  81.  
  82. private boolean isAtEssMine(){
  83. Tile[] tiles = essenceMine.getTileArray();
  84. for(Tile t : tiles) {
  85. if(t.getX() == Players.getMyPlayer().getLocation().getX() && t.getY() == Players.getMyPlayer().getLocation().getY()){
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91.  
  92.  
  93. private static void teleport(String location) {
  94. final NPC wizard = NPCs.getNearest(4397);
  95. if(wizard != null) {
  96. final WidgetChild prev = Widgets.getWidgetChild(42860954);
  97. if(prev != null && prev.getText().toLowerCase().startsWith(location.toLowerCase())) {
  98. wizard.interact("prev");
  99. return;
  100. }else {
  101. if(Widgets.isVisible(654)) {
  102. WidgetChild[] options = Widgets.get(654).getChildren();
  103. for(WidgetChild option : options) {
  104. final String text = option.getText();
  105. if(text != null && !text.isEmpty() && text.toLowerCase().trim().startsWith(location.toLowerCase())) {
  106. Packets.sendAction(0, option.getId(), 8, 0, "", "Ok");
  107. Time.sleep(150);
  108. Packets.sendAction(0, 42860643, 28, 0, "", "Close");
  109. }
  110. }
  111. }else {
  112. wizard.interact("talk-to");
  113. Time.sleep(() -> Widgets.isVisible(654), 750);
  114. Time.sleep(150);
  115. teleport(location);
  116. }
  117. }
  118. }
  119.  
  120. }
  121.  
  122. private final Color color1 = new Color(0, 255, 255);
  123. private final Font font1 = new Font("Arial", 0, 17);
  124. private final Font font2 = new Font("Arial", 2, 17);
  125.  
  126. @Override
  127. public void repaint(Graphics render) {
  128. int ph = (int) ((essence) * 3600000D / (t.getElapsed()));
  129.  
  130. Graphics2D g = (Graphics2D)render;
  131. g.setFont(font1);
  132. g.setColor(color1);
  133. g.drawString("Time: " + t.toElapsedString(), 16, 272);
  134. g.drawString("Essence: " + essence, 16, 297);
  135. g.drawString("Essence(h) " + ph, 135, 298);
  136. g.setFont(font2);
  137. g.drawString("Status: " + status, 50, 320);
  138.  
  139. }
  140.  
  141. @Override
  142. public void MessageRecieved(int i, String s, String s1, String s2) {
  143.  
  144. }
  145.  
  146. public void teleHome() {
  147. KeyBoard.typeWord("::home",true);
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement