Advertisement
Guest User

Tricks Clay Softener

a guest
Aug 24th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.41 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6.  
  7. import org.tribot.api.Timing;
  8. import org.tribot.api.util.abc.ABCUtil;
  9. import org.tribot.api2007.Banking;
  10. import org.tribot.api2007.Interfaces;
  11. import org.tribot.api2007.Inventory;
  12. import org.tribot.api2007.Login;
  13. import org.tribot.api2007.Login.STATE;
  14. import org.tribot.api2007.Skills;
  15. import org.tribot.api2007.Skills.SKILLS;
  16. import org.tribot.api2007.types.RSInterface;
  17. import org.tribot.api2007.types.RSInterfaceChild;
  18. import org.tribot.api2007.types.RSItem;
  19. import org.tribot.script.Script;
  20. import org.tribot.script.ScriptManifest;
  21. import org.tribot.script.interfaces.Painting;
  22.  
  23. @ScriptManifest(authors = { "fmtrick" }, category = "Money Making", name = "Trick's Clay Softener")
  24.  
  25. public class ClaySoftener extends Script implements Painting { 
  26.    
  27.     private State SCRIPT_STATE = getState();
  28.     private ABCUtil abc = new ABCUtil();
  29.    
  30.     private int CLAY_ID = 434;
  31.     private int WATER_JUG_ID = 1937;
  32.    
  33.     private static final long startTime = System.currentTimeMillis();
  34.  
  35.    
  36.    
  37.     public enum State {
  38.         OPEN_BANK, WITHDRAW, NOT_AT_BANK, NO_SUPPLIES, USE_CLAY, LOGIN;
  39.  
  40.     }
  41.  
  42.     private State getState() {
  43.         if(loggedIn()) {
  44.             if(atBank()) {
  45.                 if(hasSuppliesInventory()) {
  46.                     return State.USE_CLAY;
  47.                 } else {
  48.                     if(bankOpen()) {
  49.                         if(hasSuppliesBank()) {
  50.                             return State.WITHDRAW;
  51.                         } else {
  52.                             return State.NO_SUPPLIES;
  53.                         }
  54.                     } else {
  55.                         return State.OPEN_BANK;
  56.                     }
  57.                 }
  58.             } else {
  59.                 return State.NOT_AT_BANK;
  60.             }
  61.         } else {
  62.             return State.LOGIN;
  63.         }
  64.  
  65.     }
  66.  
  67.     private boolean loggedIn() {
  68.         if(Login.getLoginState() == STATE.LOGINSCREEN || Login.getLoginState() == STATE.WELCOMESCREEN) {
  69.             return false;
  70.         } else {
  71.             return true;
  72.         }
  73.     }
  74.  
  75.     private Font font = new Font("Verdana", Font.BOLD, 14);
  76.     @Override
  77.     public void onPaint(Graphics g) {
  78.         long timeRan = System.currentTimeMillis() - startTime;
  79.         g.setColor(new Color(157, 111, 74));
  80.         g.setFont(font);
  81.         g.drawString("Trick's Clay Softener", 7, 330);
  82.         g.drawString("Runetime: " + Timing.msToString(timeRan), 7, 315);
  83.         g.drawString("State: " + SCRIPT_STATE, 7, 300);
  84.     }
  85.    
  86.     private boolean atBank() {
  87.         return Banking.isInBank();
  88.     }
  89.    
  90.     private void doAntiBan() {
  91.         if (abc.shouldCheckTabs()) {
  92.             abc.checkTabs();
  93.         }
  94.         if (abc.shouldCheckXP()) {
  95.             abc.checkXP();
  96.         }
  97.         if (abc.shouldExamineEntity()) {
  98.             abc.examineEntity();
  99.         }
  100.  
  101.         if (abc.shouldMoveMouse()) {
  102.             abc.moveMouse();
  103.         }
  104.  
  105.         if (abc.shouldPickupMouse()) {
  106.             abc.pickupMouse();
  107.         }
  108.         if (abc.shouldRightClick()) {
  109.             abc.rightClick();
  110.         }
  111.         if (abc.shouldRotateCamera()) {
  112.             abc.rotateCamera();
  113.         }
  114.         if (abc.shouldLeaveGame()) {
  115.             abc.leaveGame();
  116.         }
  117.     }
  118.    
  119.     private boolean bankOpen() {
  120.         return Banking.isBankScreenOpen();
  121.     }
  122.    
  123.     private boolean openBank() {
  124.         return Banking.openBank();
  125.     }
  126.    
  127.     private boolean hasSuppliesBank() {
  128.         RSItem[] clay = Banking.find(CLAY_ID);
  129.         RSItem[] jug = Banking.find(WATER_JUG_ID);
  130.         if (clay.length > 0) {
  131.             if(jug.length > 0) {
  132.                 return true;
  133.             } else {
  134.                 return false;
  135.             }
  136.         } else {
  137.             return false;
  138.         }
  139.     }
  140.    
  141.     private boolean hasSuppliesInventory() {
  142.         RSItem[] clay = Inventory.find(CLAY_ID);
  143.         RSItem[] jug = Inventory.find(WATER_JUG_ID);
  144.         return(clay.length>0 && jug.length>0);
  145.     }
  146.    
  147.     private void withdrawSupplies() {
  148.         RSItem[] inventory = Inventory.getAll();
  149.         if(inventory.length>0 || inventory!=null) {
  150.             Banking.depositAll();
  151.         }
  152.         RSItem[] clay = Banking.find(CLAY_ID);
  153.         if(clay!=null && clay.length>0) {
  154.             Banking.withdraw(14, CLAY_ID);
  155.         }
  156.         RSItem[] waterJug = Banking.find(WATER_JUG_ID);
  157.         if(waterJug!=null && waterJug.length>0) {
  158.             Banking.withdraw(14, WATER_JUG_ID);
  159.         }
  160.         Banking.close();
  161.        
  162.     }
  163.  
  164.    
  165.     private void usingClay() {
  166.             while (true) {
  167.                 doAntiBan();
  168.                 RSItem[] clay = Inventory.find(CLAY_ID);
  169.                 int previousClay = clay.length;
  170.                 if(previousClay == 0) {
  171.                     break;
  172.                 } else {
  173.                     sleep(2500);
  174.                     RSItem[] clay2 = Inventory.find(CLAY_ID);
  175.                     int currentClay = clay2.length;
  176.                     if (currentClay == 0 || clay2 == null) {
  177.                         break;
  178.                     } else {
  179.                         if (currentClay == previousClay) {
  180.                             break;
  181.                         }
  182.                     }
  183.                 }
  184.                
  185.             }
  186.     }
  187.    
  188.     private void useClay() {
  189.         RSItem[] clay = Inventory.find(CLAY_ID);
  190.         RSItem[] jug = Inventory.find(WATER_JUG_ID);
  191.         if(clay!=null&&clay.length>0 && jug!=null&&jug.length>0) {
  192.             clay[0].click("Use");
  193.             jug[0].click("Use Clay -> Jug of water");
  194.         }
  195.         sleep(1000);
  196.         RSInterface makeInterface = Interfaces.get(309);
  197.         if(!makeInterface.isHidden()&&makeInterface!=null) {
  198.             RSInterfaceChild makeButton = Interfaces.get(309, 2);
  199.             if(makeButton!=null && !makeButton.isHidden()) {
  200.                 makeButton.click("Make All");
  201.             }
  202.         }
  203.         usingClay();
  204.     }
  205.    
  206.    
  207.     private void endScript() {
  208.         println("No supplies or not at a bank");
  209.         Login.logout();
  210.     }
  211.    
  212.     private void login() {
  213.         Login.login();
  214.     }
  215.    
  216.     @Override
  217.     public void run() {
  218.         loop: while(true) {
  219.             SCRIPT_STATE = getState();
  220.             switch (SCRIPT_STATE) {
  221.             case NOT_AT_BANK:
  222.                 endScript();
  223.                 break loop;
  224.             case NO_SUPPLIES:
  225.                 endScript();
  226.                 break loop;
  227.             case OPEN_BANK:
  228.                 openBank();
  229.                 break;
  230.             case WITHDRAW:
  231.                 withdrawSupplies();
  232.                 break;
  233.             case USE_CLAY:
  234.                 useClay();
  235.                 break;
  236.             case LOGIN:
  237.                 login();
  238.                 break;
  239.             }
  240.             sleep(150);
  241.         }
  242.     }
  243.  
  244.  
  245.  
  246.  
  247.  
  248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement