Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.awt.Graphics;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JDialog;
- import xobot.client.callback.listeners.MessageListener;
- import xobot.client.callback.listeners.PaintListener;
- import xobot.script.ActiveScript;
- import xobot.script.Manifest;
- import xobot.script.methods.Bank;
- import xobot.script.methods.GameObjects;
- import xobot.script.methods.NPCs;
- import xobot.script.methods.Packets;
- import xobot.script.methods.Players;
- import xobot.script.methods.Walking;
- import xobot.script.methods.Widgets;
- import xobot.script.methods.tabs.Inventory;
- import xobot.script.util.Time;
- import xobot.script.util.Timer;
- import xobot.script.wrappers.Tile;
- import xobot.script.wrappers.interactive.GameObject;
- import xobot.script.wrappers.interactive.Item;
- import xobot.script.wrappers.interactive.NPC;
- @Manifest(authors = { "Josef, Skeleton Rain" }, name = "jBuyer gem buyer", version = 1.0 ,description = "Buys gems and banks them ")
- public class jBuyer extends ActiveScript implements PaintListener, MessageListener {
- public static Timer runTime = null;
- int NPCid = 0;
- int Itemid = 0;
- int slotid = 0;
- String itemtype = "...";
- private long startTime;
- /*
- * Gets invoked before the script starts looping If this returns false the
- * script will stop
- */
- public boolean onStart() {
- startTime = System.currentTimeMillis();
- JDialog frame = new JDialog();
- frame.setPreferredSize(new Dimension(250,90));
- frame.setLocationRelativeTo(null);
- frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- FlowLayout layout = new FlowLayout();
- layout.setHgap(5);
- layout.setVgap(5);
- frame.setLayout(layout);
- JComboBox<String> combo = new JComboBox<String>();
- combo.setPreferredSize(new Dimension(150,30));
- combo.setFocusable(false);
- combo.addItem("Uncut Ruby");
- combo.addItem("Uncut Sapphire");
- combo.addItem("Uncut Emerald");
- combo.addItem("Uncut Diamond");
- JButton button = new JButton("Start");
- button.setFocusable(false);
- button.setPreferredSize(new Dimension(60,32));
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- itemtype = (String)combo.getSelectedItem();
- switch(itemtype) {
- case "Uncut Ruby":
- NPCid = 519;
- Itemid = 1619;
- slotid = 12;
- break;
- case "Uncut Sapphire":
- NPCid = 519;
- Itemid = 1623;
- slotid = 10;
- break;
- case "Uncut Emerald":
- NPCid = 519;
- Itemid = 1621;
- slotid = 11;
- break;
- case "Uncut Diamond":
- NPCid = 519;
- Itemid = 1617;
- slotid = 13;
- break;
- }
- frame.dispose();
- }
- });
- frame.add(combo);
- frame.add(button);
- frame.setTitle("jBuyer-Gem Buyer");
- frame.pack();
- frame.setVisible(true);
- while(frame.isVisible()) {
- Time.sleep(500);
- }
- return Itemid != 0 && slotid != 0;
- }
- public void interact() {
- Tile t = new Tile(2342, 3813);
- NPC Shop = NPCs.getNearest(NPCid);
- Walking.walkTo(t);
- Time.sleep(4500);
- Shop.interact("Trade");
- Time.sleep(1000);
- if (Widgets.getOpenInterface() == 3824) {
- Time.sleep(300, 400);
- Packets.sendAction(54, Itemid, slotid, 3900);
- Time.sleep(300, 600);
- Packets.sendAction(54, Itemid, slotid, 3900);
- }
- }
- public void bankAllExcept() {
- ArrayList<Integer> list = new ArrayList<Integer>( Arrays.asList());
- list.add(Itemid);
- if (Bank.isOpen()) {
- for (Item i : Inventory.getItems()) {
- if (list.contains(i.getID())) {
- i.interact("store all");
- Time.sleep(100);
- }
- }
- } else {
- return;
- }
- }
- public void bank() {
- GameObject obj = GameObjects.getNearest(21301);
- if (!Players.getMyPlayer().isMoving() && !Bank.isOpen() && obj != null && Inventory.isFull()) {
- obj.interact("Bank");
- Time.sleep(1000);
- }
- if (Bank.isOpen()) {
- bankAllExcept();
- }
- }
- /*
- * The main script's look, the return value is the time it'll get invoked
- * again
- */
- @Override
- public int loop() {
- if (Inventory.isFull()) {
- bank();
- } else {
- interact();
- }
- return 1000;
- }
- @Override
- public void repaint(Graphics g) {
- int topX = 515 - 190, topY = 337 - 80, x = topX + 5, y = topY + 5;
- g.setColor(new Color(100, 0, 0, 100));
- g.fill3DRect(topX, topY, 515 - topX, 337 - topY, true);
- g.setColor(Color.white);
- g.drawString("Runtime: " + runTime(startTime), x, y += 15);
- }
- public static String runTime(long i) {
- DecimalFormat nf = new DecimalFormat("00");
- long millis = System.currentTimeMillis() - i;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- return nf.format(hours) + ":" + nf.format(minutes) + ":"
- + nf.format(seconds);
- }
- @Override
- public void MessageRecieved(String arg0, int arg1, String arg2) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement