Advertisement
Guest User

jBuyer - Gem Buyer (Updated)

a guest
Oct 6th, 2017
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1.  
  2. import java.awt.Color;
  3. import java.awt.Dimension;
  4. import java.awt.FlowLayout;
  5. import java.awt.Graphics;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.text.DecimalFormat;
  9. import java.util.ArrayList;
  10. import java.util.Arrays;
  11.  
  12. import javax.swing.JButton;
  13. import javax.swing.JComboBox;
  14. import javax.swing.JDialog;
  15.  
  16. import xobot.client.callback.listeners.MessageListener;
  17. import xobot.client.callback.listeners.PaintListener;
  18. import xobot.script.ActiveScript;
  19. import xobot.script.Manifest;
  20. import xobot.script.methods.Bank;
  21. import xobot.script.methods.GameObjects;
  22. import xobot.script.methods.NPCs;
  23. import xobot.script.methods.Packets;
  24. import xobot.script.methods.Players;
  25. import xobot.script.methods.Walking;
  26. import xobot.script.methods.Widgets;
  27. import xobot.script.methods.tabs.Inventory;
  28. import xobot.script.util.Time;
  29. import xobot.script.util.Timer;
  30. import xobot.script.wrappers.Tile;
  31. import xobot.script.wrappers.interactive.GameObject;
  32. import xobot.script.wrappers.interactive.Item;
  33. import xobot.script.wrappers.interactive.NPC;
  34.  
  35.  
  36. @Manifest(authors = { "Josef, Skeleton Rain" }, name = "jBuyer gem buyer", version = 1.0 ,description = "Buys gems and banks them ")
  37.  
  38.  
  39.  
  40.  
  41. public class jBuyer extends ActiveScript implements PaintListener, MessageListener {
  42.  
  43. public static Timer runTime = null;
  44.  
  45. int NPCid = 0;
  46. int Itemid = 0;
  47. int slotid = 0;
  48.  
  49.  
  50. String itemtype = "...";
  51.  
  52. private long startTime;
  53.  
  54.  
  55. /*
  56. * Gets invoked before the script starts looping If this returns false the
  57. * script will stop
  58. */
  59. public boolean onStart() {
  60. startTime = System.currentTimeMillis();
  61.  
  62. JDialog frame = new JDialog();
  63. frame.setPreferredSize(new Dimension(250,90));
  64. frame.setLocationRelativeTo(null);
  65. frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  66. FlowLayout layout = new FlowLayout();
  67. layout.setHgap(5);
  68. layout.setVgap(5);
  69. frame.setLayout(layout);
  70.  
  71. JComboBox<String> combo = new JComboBox<String>();
  72. combo.setPreferredSize(new Dimension(150,30));
  73. combo.setFocusable(false);
  74. combo.addItem("Uncut Ruby");
  75. combo.addItem("Uncut Sapphire");
  76. combo.addItem("Uncut Emerald");
  77. combo.addItem("Uncut Diamond");
  78.  
  79. JButton button = new JButton("Start");
  80. button.setFocusable(false);
  81. button.setPreferredSize(new Dimension(60,32));
  82. button.addActionListener(new ActionListener() {
  83.  
  84. @Override
  85. public void actionPerformed(ActionEvent arg0) {
  86. itemtype = (String)combo.getSelectedItem();
  87. switch(itemtype) {
  88. case "Uncut Ruby":
  89. NPCid = 519;
  90. Itemid = 1619;
  91. slotid = 12;
  92. break;
  93. case "Uncut Sapphire":
  94. NPCid = 519;
  95. Itemid = 1623;
  96. slotid = 10;
  97. break;
  98. case "Uncut Emerald":
  99. NPCid = 519;
  100. Itemid = 1621;
  101. slotid = 11;
  102. break;
  103. case "Uncut Diamond":
  104. NPCid = 519;
  105. Itemid = 1617;
  106. slotid = 13;
  107. break;
  108. }
  109.  
  110. frame.dispose();
  111. }
  112.  
  113. });
  114.  
  115. frame.add(combo);
  116. frame.add(button);
  117. frame.setTitle("jBuyer-Gem Buyer");
  118.  
  119.  
  120. frame.pack();
  121. frame.setVisible(true);
  122. while(frame.isVisible()) {
  123. Time.sleep(500);
  124. }
  125. return Itemid != 0 && slotid != 0;
  126.  
  127. }
  128.  
  129.  
  130. public void interact() {
  131. Tile t = new Tile(2342, 3813);
  132. NPC Shop = NPCs.getNearest(NPCid);
  133. Walking.walkTo(t);
  134. Time.sleep(4500);
  135. Shop.interact("Trade");
  136. Time.sleep(1000);
  137. if (Widgets.getOpenInterface() == 3824) {
  138. Time.sleep(300, 400);
  139. Packets.sendAction(54, Itemid, slotid, 3900);
  140. Time.sleep(300, 600);
  141. Packets.sendAction(54, Itemid, slotid, 3900);
  142. }
  143. }
  144.  
  145. public void bankAllExcept() {
  146. ArrayList<Integer> list = new ArrayList<Integer>( Arrays.asList());
  147. list.add(Itemid);
  148. if (Bank.isOpen()) {
  149. for (Item i : Inventory.getItems()) {
  150. if (list.contains(i.getID())) {
  151. i.interact("store all");
  152. Time.sleep(100);
  153. }
  154. }
  155. } else {
  156. return;
  157. }
  158. }
  159.  
  160. public void bank() {
  161. GameObject obj = GameObjects.getNearest(21301);
  162. if (!Players.getMyPlayer().isMoving() && !Bank.isOpen() && obj != null && Inventory.isFull()) {
  163. obj.interact("Bank");
  164. Time.sleep(1000);
  165. }
  166. if (Bank.isOpen()) {
  167. bankAllExcept();
  168. }
  169. }
  170.  
  171. /*
  172. * The main script's look, the return value is the time it'll get invoked
  173. * again
  174. */
  175. @Override
  176. public int loop() {
  177. if (Inventory.isFull()) {
  178. bank();
  179. } else {
  180. interact();
  181. }
  182. return 1000;
  183. }
  184.  
  185. @Override
  186.  
  187. public void repaint(Graphics g) {
  188. int topX = 515 - 190, topY = 337 - 80, x = topX + 5, y = topY + 5;
  189. g.setColor(new Color(100, 0, 0, 100));
  190. g.fill3DRect(topX, topY, 515 - topX, 337 - topY, true);
  191. g.setColor(Color.white);
  192. g.drawString("Runtime: " + runTime(startTime), x, y += 15);
  193.  
  194.  
  195. }
  196. public static String runTime(long i) {
  197. DecimalFormat nf = new DecimalFormat("00");
  198. long millis = System.currentTimeMillis() - i;
  199. long hours = millis / (1000 * 60 * 60);
  200. millis -= hours * (1000 * 60 * 60);
  201. long minutes = millis / (1000 * 60);
  202. millis -= minutes * (1000 * 60);
  203. long seconds = millis / 1000;
  204. return nf.format(hours) + ":" + nf.format(minutes) + ":"
  205. + nf.format(seconds);
  206. }
  207.  
  208.  
  209. @Override
  210. public void MessageRecieved(String arg0, int arg1, String arg2) {
  211. // TODO Auto-generated method stub
  212.  
  213. }
  214.  
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement