Advertisement
Guest User

TsuMiner

a guest
Apr 10th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.20 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.Toolkit;
  5.  
  6. import org.tribot.api.input.Mouse;
  7. import org.tribot.api2007.Banking;
  8. import org.tribot.api2007.Camera;
  9. import org.tribot.api2007.Inventory;
  10. import org.tribot.api2007.Objects;
  11. import org.tribot.api2007.Player;
  12. import org.tribot.api2007.Walking;
  13. import org.tribot.api2007.WebWalking;
  14. import org.tribot.api2007.types.RSObject;
  15. import org.tribot.api2007.types.RSTile;
  16. import org.tribot.script.Script;
  17. import org.tribot.script.ScriptManifest;
  18.  
  19.  
  20. @ScriptManifest(authors = { "Tsuyoshi" }, name = "TsuMiner", category = "Mining")
  21.  
  22. public class TsuMiner extends Script {
  23.  
  24.     private boolean shouldBank;
  25.     private final int[] ORE_ID = { 7484, 7453 };
  26.     private final int MINING_ANIM = 625;
  27.     private final int ORE_INV_ID = 436;
  28.     private RSObject[] ores;
  29.     private RSObject nearestOre;
  30.     private RSTile START_TILE;
  31.     private boolean GUI_COMPLETE = false;
  32.     private int PICKAXE_ID[] = {1265, 1267, 1271, 1273, 1275, 11929, 12297};
  33.  
  34.     @Override
  35.     public void run() {
  36.         GUI GUI = new GUI();
  37.        
  38.         Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  39.         int screenW = (screensize.width) / 2;
  40.         int screenH = (screensize.height) / 2;
  41.        
  42.         Dimension dim = GUI.getSize();
  43.        
  44.         GUI.setVisible(true);
  45.        
  46.         GUI.setLocation((screenW / 2), (screenH / 2));
  47.        
  48.         while (!GUI_COMPLETE){
  49.             sleep(300);
  50.         }
  51.        
  52.         GUI.setVisible(false);
  53.    
  54.         startScript();
  55.  
  56.         while (loop()) {
  57.         }
  58.    
  59.         }
  60.        
  61.    
  62.         private boolean loop() {
  63.    
  64.             if (Inventory.isFull() && shouldBank) {
  65.                 bank(START_TILE);
  66.             } else if (Inventory.isFull() && !shouldBank) {
  67.                 dropOre();
  68.             } else {
  69.                 mineOre();
  70.             }
  71.             return true;
  72.         }
  73.    
  74.         private void startScript() {
  75.             Mouse.setSpeed(170);
  76.             START_TILE = Player.getPosition();
  77.    
  78.         }
  79.    
  80.         private void mineOre() {
  81.             ores = Objects.findNearest(20, ORE_ID);
  82.             nearestOre = ores[0];
  83.             if (Player.getAnimation() != MINING_ANIM && !Player.isMoving()) {
  84.                 if (nearestOre.isOnScreen()) {
  85.    
  86.                     nearestOre.click();
  87.                     sleep(1800, 2900);
  88.                 } else {
  89.                     Camera.turnToTile(nearestOre.getPosition());
  90.                     Walking.walkTo(nearestOre.getPosition());
  91.    
  92.                 }
  93.             }
  94.         }
  95.        
  96.         private void dropOre() {
  97.             Inventory.drop(ORE_INV_ID);
  98.         }
  99.    
  100.         private void bank(RSTile startTile) {
  101.             if (WebWalking.walkToBank()) {
  102.                 if (Banking.openBank()) {
  103.                     Banking.depositAllExcept(PICKAXE_ID);
  104.                     Banking.close();
  105.                     WebWalking.walkTo(startTile);
  106.             }
  107.         }
  108.     }
  109.  
  110.     /**
  111.      *
  112.      * @author Jordan
  113.      */
  114.     public class GUI extends javax.swing.JFrame {
  115.  
  116.         /**
  117.          * Creates new form UI
  118.          */
  119.         public GUI() {
  120.             initComponents();
  121.         }
  122.  
  123.         /**
  124.          * This method is called from within the constructor to initialize the
  125.          * form. WARNING: Do NOT modify this code. The content of this method is
  126.          * always regenerated by the Form Editor.
  127.          */
  128.         @SuppressWarnings("unchecked")
  129.         // <editor-fold defaultstate="collapsed" desc="Generated Code">
  130.         private void initComponents() {
  131.  
  132.             buttonGroup1 = new javax.swing.ButtonGroup();
  133.             jLabel1 = new javax.swing.JLabel();
  134.             start = new javax.swing.JButton();
  135.             bank = new javax.swing.JRadioButton();
  136.             drop = new javax.swing.JRadioButton();
  137.  
  138.             jLabel1.setFont(new java.awt.Font("Segoe UI Light", 1, 36)); // NOI18N
  139.             jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  140.             jLabel1.setText("TsuMiner");
  141.  
  142.             start.setText("Start");
  143.             start.addActionListener(new java.awt.event.ActionListener() {
  144.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  145.                     startActionPerformed(evt);
  146.                 }
  147.             });
  148.  
  149.             buttonGroup1.add(bank);
  150.             bank.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
  151.             bank.setSelected(true);
  152.             bank.setText("Bank");
  153.             bank.addActionListener(new java.awt.event.ActionListener() {
  154.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  155.                    
  156.                 }
  157.             });
  158.  
  159.             buttonGroup1.add(drop);
  160.             drop.setFont(new java.awt.Font("Segoe UI Light", 0, 18)); // NOI18N
  161.             drop.setText("Drop");
  162.             drop.addActionListener(new java.awt.event.ActionListener() {
  163.                 public void actionPerformed(java.awt.event.ActionEvent evt) {
  164.                    
  165.                 }
  166.             });
  167.  
  168.             javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  169.             getContentPane().setLayout(layout);
  170.             layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  171.                     .addGroup(layout.createSequentialGroup().addGap(60, 60, 60)
  172.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  173.                                     .addComponent(drop).addComponent(bank))
  174.                             .addGap(0, 0, Short.MAX_VALUE))
  175.                     .addGroup(layout.createSequentialGroup().addContainerGap()
  176.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  177.                                     .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
  178.                                     .addComponent(start, javax.swing.GroupLayout.Alignment.TRAILING,
  179.                                             javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
  180.                                             Short.MAX_VALUE))
  181.                             .addContainerGap()));
  182.             layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  183.                     .addGroup(layout.createSequentialGroup().addComponent(jLabel1)
  184.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(bank)
  185.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(drop)
  186.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(start)
  187.                             .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
  188.  
  189.             pack();
  190.         }// </editor-fold>
  191.  
  192.         private void startActionPerformed(java.awt.event.ActionEvent evt) {
  193.            
  194.             if (bank.isSelected()){
  195.                 shouldBank = true;
  196.             } else {
  197.                 shouldBank = false;
  198.             }
  199.            
  200.             GUI_COMPLETE = true;
  201.         }
  202.  
  203.         /**
  204.          * @param args
  205.          *            the command line arguments
  206.          */
  207.  
  208.         // Variables declaration - do not modify
  209.         private javax.swing.JRadioButton bank;
  210.         private javax.swing.ButtonGroup buttonGroup1;
  211.         private javax.swing.JRadioButton drop;
  212.         private javax.swing.JLabel jLabel1;
  213.         private javax.swing.JButton start;
  214.         // End of variables declaration
  215.     }
  216.  
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement