Advertisement
joedezzy1

Clicker

Mar 12th, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.04 KB | None | 0 0
  1. package scripts.autoMerchanter;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api.types.generic.Condition;
  6. import org.tribot.api2007.Interfaces;
  7. import org.tribot.api2007.Inventory;
  8. import org.tribot.api2007.types.RSInterface;
  9.  
  10. public class Clicker {
  11.    
  12.     private Check values;
  13.     private Typer typer = new Typer(values);
  14.    
  15.     public Clicker(Check values) {
  16.         this.values = values;
  17.     }
  18.    
  19.     public void handleTradeScreen (boolean accept) {   
  20.         //*
  21.         /* Handels trade screen based off if we are accepting the trade
  22.          * and which trade screen is currently valid
  23.          */
  24.         switch (Interfaces.isInterfaceValid(335) ? 1 : 2) {
  25.         case 1:
  26.         if (accept && Interfaces.isInterfaceValid(335) && Interfaces.get(335, 17).click()) {                                           
  27.                     Timing.waitCondition(new Condition() {
  28.                 @Override
  29.                 public boolean active() {
  30.                 return clickedAccept() || Interfaces.isInterfaceValid(334);
  31.             }                          
  32.                     }, General.random(2600, 3300));                            
  33.         }
  34.         else if (Interfaces.isInterfaceValid(335) && Interfaces.get(335, 18).click()) {                
  35.             Timing.waitCondition(new Condition() {
  36.             @Override
  37.             public boolean active() {
  38.                 return !values.inTrade();
  39.             }                      
  40.                     }, General.random(2600, 3300));                        
  41.         }          
  42.         break;
  43.            
  44.         case 2:
  45.         if(accept && Interfaces.isInterfaceValid(334) && Interfaces.get(334, 20).click()) {                                                                
  46.                     if (Timing.waitCondition(new Condition() {
  47.             @Override
  48.             public boolean active() {
  49.                 return clickedAccept() || values.inTrade();
  50.             }                          
  51.                     }, General.random(2200, 3500))) {
  52.                    
  53.                     typer.successfulTrade();                                               
  54.                     if (values.getStatus().equals("selling")) {
  55.                         values.nextGoldAmount = Inventory.getCount(995);
  56.                             values.profit = values.nextGoldAmount - values.initialCoins;
  57.                             values.itemsSold ++;
  58.                     }                      
  59.                     values.exchanges++;
  60.                     }
  61.         }
  62.         else if (Interfaces.isInterfaceValid(334) && Interfaces.get(334, 21).click()) {                
  63.                     if (Timing.waitCondition(new Condition(){
  64.             @Override
  65.             public boolean active() {
  66.                 return !values.inTrade();
  67.             }                      
  68.                     }, General.random(2300, 3000))) {
  69.                     typer.replyToScammer();        
  70.                     }
  71.             }        
  72.         values.totalTrades++;          
  73.         break;
  74.       }
  75.     }
  76.    
  77.     public boolean clickedAccept() {
  78.         //*
  79.         /* Reads the interface to see if it gives us
  80.          * the waiting message
  81.          */
  82.         RSInterface accepted = Interfaces.get(Interfaces.isInterfaceValid(335) ? 335 : 334,                                               Interfaces.isInterfaceValid(335) ? 56 : 33);
  83.         if (accepted != null) {
  84.             String text = accepted.getText();
  85.             return text != null
  86.                     && (text.contains(values.WAITING_MESSAGE));
  87.         }
  88.         return false;
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement