Advertisement
Guest User

>C< Prayer potion Drinker V0.2

a guest
Feb 15th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.24 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.  
  8.     public boolean gui_COMPLETE = false;
  9.  
  10.     public void onStart() {
  11.  
  12.         log("Waiting on GUI...");
  13.  
  14.         GUI gui = new GUI();
  15.  
  16.         Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  17.         int screenW = screensize.width / 2;
  18.         int screenH = screensize.height / 2;
  19.  
  20.         gui.frmc.setVisible(true);
  21.         gui.frmc.setLocation(screenW / 2, screenH / 2);
  22.  
  23.         while (!this.gui_COMPLETE) {
  24.             try {
  25.                 sleep(300L);
  26.             } catch (InterruptedException e) {
  27.                 e.printStackTrace();
  28.             }
  29.         }
  30.         gui.frmc.setVisible(false);
  31.  
  32.         log("GUI completed.");
  33.  
  34.     }
  35.  
  36.     @Override
  37.     public int onLoop() throws InterruptedException {
  38.  
  39.        
  40.         if (getSkills().getDynamic(Skill.PRAYER) <= drink_at && getSkills().getDynamic(Skill.PRAYER) != getSkills().getStatic(Skill.PRAYER)) {
  41.            
  42.             drink_prayer_potions();
  43.         }
  44.  
  45.         return random(20, 40);
  46.     }
  47.  
  48.     public void drink_prayer_potions() {
  49.  
  50.         if (getInventory().contains(prayer_potions)) {
  51.  
  52.             Optional<Item> prayerPotion = Arrays.stream(getInventory().getItems())
  53.                     .filter(item -> item != null && item.getName().startsWith("Prayer potion"))
  54.                     .min(Comparator.comparing(Item::getName));
  55.  
  56.             if (prayerPotion.isPresent()) {
  57.                 Item pot_to_drink = prayerPotion.get();
  58.  
  59.                 pot_to_drink.interact("Drink");
  60.  
  61.                 new ConditionalSleep(random(3000, 4000)) {
  62.  
  63.                     @Override
  64.                     public boolean condition() {
  65.                         return myPlayer().getAnimation() != 829;
  66.                     }
  67.  
  68.                 }.sleep();
  69.             }
  70.  
  71.         } else {
  72.  
  73.             if (!getInventory().contains(prayer_potions)) {
  74.  
  75.                 log("Out of prayer potions.");
  76.                 stop(false);
  77.  
  78.             }
  79.         }
  80.     }
  81.  
  82.     public class GUI {
  83.  
  84.         private JFrame frmc;
  85.         private JTextField textField;
  86.  
  87.         public GUI() {
  88.             initialize();
  89.         }
  90.  
  91.         /**
  92.          * Initialize the contents of the frame.
  93.          */
  94.         private void initialize() {
  95.             frmc = new JFrame();
  96.             frmc.setResizable(false);
  97.             frmc.setTitle(">C< PPD");
  98.             frmc.setBounds(100, 100, 227, 120);
  99.             frmc.getContentPane().setLayout(null);
  100.  
  101.             textField = new JTextField();
  102.             textField.setBounds(55, 11, 46, 20);
  103.             frmc.getContentPane().add(textField);
  104.             textField.setColumns(10);
  105.  
  106.             JLabel lblDrinkAt = new JLabel("Drink at");
  107.             lblDrinkAt.setBounds(10, 14, 46, 14);
  108.             frmc.getContentPane().add(lblDrinkAt);
  109.  
  110.             JLabel lblPrayerPoints = new JLabel("prayer points.");
  111.             lblPrayerPoints.setBounds(111, 14, 77, 14);
  112.             frmc.getContentPane().add(lblPrayerPoints);
  113.  
  114.             JButton btnStart = new JButton("Start");
  115.             btnStart.addActionListener(new ActionListener() {
  116.                 public void actionPerformed(ActionEvent arg0) {
  117.  
  118.                     drink_at = Integer.parseInt(textField.getText());
  119.  
  120.                     gui_COMPLETE = true;
  121.  
  122.                 }
  123.             });
  124.             btnStart.setBounds(10, 57, 201, 23);
  125.             frmc.getContentPane().add(btnStart);
  126.  
  127.             JLabel lblRandomizedBy = new JLabel("Prioritises lower doses first.");
  128.             lblRandomizedBy.setForeground(Color.GRAY);
  129.             lblRandomizedBy.setBounds(10, 32, 201, 23);
  130.             frmc.getContentPane().add(lblRandomizedBy);
  131.         }
  132.     }
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement