Advertisement
Guest User

>C< Prayer potion Drinker V0.3

a guest
Feb 15th, 2018
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.62 KB | None | 0 0
  1. @ScriptManifest(author = "Castro_", info = "", logo = "https://i.imgur.com/4EG1pKu.png", name = ">C< Prayer Potion Drinker", version = 0.1)
  2. public class Main extends Script {
  3.  
  4.     public int drink_at = 0;
  5.  
  6.     public String[] prayer_potions = { "Prayer potion(1)", "Prayer potion(2)", "Prayer potion(3)", "Prayer potion(4)" };
  7.     public String[] super_restores = { "Super restore(1)", "Super restore(2)", "Super restore(3)", "Super restore(4)" };
  8.  
  9.     public boolean gui_COMPLETE = false;
  10.    
  11.     public boolean drink_restores = false;
  12.  
  13.     public void onStart() {
  14.  
  15.         log("Waiting on GUI...");
  16.  
  17.         GUI gui = new GUI();
  18.  
  19.         Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  20.         int screenW = screensize.width / 2;
  21.         int screenH = screensize.height / 2;
  22.  
  23.         gui.frmc.setVisible(true);
  24.         gui.frmc.setLocation(screenW / 2, screenH / 2);
  25.  
  26.         while (!this.gui_COMPLETE) {
  27.             try {
  28.                 sleep(300L);
  29.             } catch (InterruptedException e) {
  30.                 e.printStackTrace();
  31.             }
  32.         }
  33.         gui.frmc.setVisible(false);
  34.  
  35.         log("GUI completed.");
  36.  
  37.     }
  38.  
  39.     @Override
  40.     public int onLoop() throws InterruptedException {
  41.  
  42.        
  43.         if (getSkills().getDynamic(Skill.PRAYER) <= drink_at && getSkills().getDynamic(Skill.PRAYER) != getSkills().getStatic(Skill.PRAYER)) {
  44.            
  45.             if(drink_restores == false) {
  46.            
  47.             drink_prayer_potions();
  48.            
  49.             }else {
  50.                
  51.                 if(drink_restores == true) {
  52.                    
  53.                     drink_super_restores();
  54.                 }
  55.                
  56.             }
  57.         }
  58.  
  59.         return random(20, 40);
  60.     }
  61.  
  62.     public void drink_prayer_potions() {
  63.  
  64.         if (getInventory().contains(prayer_potions)) {
  65.  
  66.             Optional<Item> prayerPotion = Arrays.stream(getInventory().getItems())
  67.                     .filter(item -> item != null && item.getName().startsWith("Prayer potion"))
  68.                     .min(Comparator.comparing(Item::getName));
  69.  
  70.             if (prayerPotion.isPresent()) {
  71.                 Item pot_to_drink = prayerPotion.get();
  72.  
  73.                 pot_to_drink.interact("Drink");
  74.  
  75.                 new ConditionalSleep(random(3000, 4000)) {
  76.  
  77.                     @Override
  78.                     public boolean condition() {
  79.                         return myPlayer().getAnimation() != 829;
  80.                     }
  81.  
  82.                 }.sleep();
  83.             }
  84.  
  85.         } else {
  86.  
  87.             if (!getInventory().contains(prayer_potions)) {
  88.  
  89.                 log("Out of prayer potions.");
  90.                 stop(false);
  91.  
  92.             }
  93.         }
  94.     }
  95.    
  96.     public void drink_super_restores() {
  97.  
  98.         if (getInventory().contains(super_restores)) {
  99.  
  100.             Optional<Item> superRestore = Arrays.stream(getInventory().getItems())
  101.                     .filter(item -> item != null && item.getName().startsWith("Super restore"))
  102.                     .min(Comparator.comparing(Item::getName));
  103.  
  104.             if (superRestore.isPresent()) {
  105.                 Item pot_to_drink = superRestore.get();
  106.  
  107.                 pot_to_drink.interact("Drink");
  108.  
  109.                 new ConditionalSleep(random(3000, 4000)) {
  110.  
  111.                     @Override
  112.                     public boolean condition() {
  113.                         return myPlayer().getAnimation() != 829;
  114.                     }
  115.  
  116.                 }.sleep();
  117.             }
  118.  
  119.         } else {
  120.  
  121.             if (!getInventory().contains(super_restores)) {
  122.  
  123.                 log("Out of super restore potions.");
  124.                 stop(false);
  125.  
  126.             }
  127.         }
  128.     }
  129.  
  130.     public class GUI {
  131.  
  132.         private JFrame frmc;
  133.         private JTextField textField;
  134.  
  135.    
  136.         public GUI() {
  137.             initialize();
  138.         }
  139.  
  140.         /**
  141.          * Initialize the contents of the frame.
  142.          */
  143.         private void initialize() {
  144.             frmc = new JFrame();
  145.             frmc.setResizable(false);
  146.             frmc.setTitle(">C< PPD");
  147.             frmc.setBounds(100, 100, 228, 142);
  148.             frmc.getContentPane().setLayout(null);
  149.            
  150.             textField = new JTextField();
  151.             textField.setBounds(55, 11, 46, 20);
  152.             frmc.getContentPane().add(textField);
  153.             textField.setColumns(10);
  154.            
  155.             JLabel lblDrinkAt = new JLabel("Drink at");
  156.             lblDrinkAt.setBounds(10, 14, 46, 14);
  157.             frmc.getContentPane().add(lblDrinkAt);
  158.            
  159.             JLabel lblPrayerPoints = new JLabel("prayer points.");
  160.             lblPrayerPoints.setBounds(111, 14, 77, 14);
  161.             frmc.getContentPane().add(lblPrayerPoints);
  162.        
  163.             JCheckBox chckbxDrinkSuperRestores = new JCheckBox("Drink super restores instead?");
  164.             chckbxDrinkSuperRestores.setBounds(6, 35, 205, 23);
  165.             frmc.getContentPane().add(chckbxDrinkSuperRestores);
  166.        
  167.             JButton btnStart = new JButton("Start");
  168.             btnStart.addActionListener(new ActionListener() {
  169.                 public void actionPerformed(ActionEvent arg0) {
  170.                    
  171.                     if(chckbxDrinkSuperRestores.isSelected()) {
  172.                        
  173.                         drink_restores = true;
  174.                        
  175.                     }
  176.                    
  177.                     drink_at = Integer.parseInt(textField.getText());
  178.                    
  179.                     gui_COMPLETE = true;
  180.                 }
  181.             });
  182.             btnStart.setBounds(10, 79, 201, 23);
  183.             frmc.getContentPane().add(btnStart);
  184.            
  185.             JLabel lblRandomizedBy = new JLabel("Priotizes lower doses first.");
  186.             lblRandomizedBy.setForeground(Color.GRAY);
  187.             lblRandomizedBy.setBounds(10, 55, 201, 23);
  188.             frmc.getContentPane().add(lblRandomizedBy);
  189.            
  190.            
  191.         }
  192.     }
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement