Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ScriptManifest(author = "Castro_", info = "", logo = "https://i.imgur.com/4EG1pKu.png", name = ">C< Prayer Potion Drinker", version = 0.1)
- public class Main extends Script {
- public int drink_at = 0;
- public String[] prayer_potions = { "Prayer potion(1)", "Prayer potion(2)", "Prayer potion(3)", "Prayer potion(4)" };
- public boolean gui_COMPLETE = false;
- public void onStart() {
- log("Waiting on GUI...");
- GUI gui = new GUI();
- Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
- int screenW = screensize.width / 2;
- int screenH = screensize.height / 2;
- gui.frmc.setVisible(true);
- gui.frmc.setLocation(screenW / 2, screenH / 2);
- while (!this.gui_COMPLETE) {
- try {
- sleep(300L);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- gui.frmc.setVisible(false);
- log("GUI completed.");
- }
- @Override
- public int onLoop() throws InterruptedException {
- if (getSkills().getDynamic(Skill.PRAYER) <= drink_at && getSkills().getDynamic(Skill.PRAYER) != getSkills().getStatic(Skill.PRAYER)) {
- drink_prayer_potions();
- }
- return random(20, 40);
- }
- public void drink_prayer_potions() {
- if (getInventory().contains(prayer_potions)) {
- Optional<Item> prayerPotion = Arrays.stream(getInventory().getItems())
- .filter(item -> item != null && item.getName().startsWith("Prayer potion"))
- .min(Comparator.comparing(Item::getName));
- if (prayerPotion.isPresent()) {
- Item pot_to_drink = prayerPotion.get();
- pot_to_drink.interact("Drink");
- new ConditionalSleep(random(3000, 4000)) {
- @Override
- public boolean condition() {
- return myPlayer().getAnimation() != 829;
- }
- }.sleep();
- }
- } else {
- if (!getInventory().contains(prayer_potions)) {
- log("Out of prayer potions.");
- stop(false);
- }
- }
- }
- public class GUI {
- private JFrame frmc;
- private JTextField textField;
- public GUI() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frmc = new JFrame();
- frmc.setResizable(false);
- frmc.setTitle(">C< PPD");
- frmc.setBounds(100, 100, 227, 120);
- frmc.getContentPane().setLayout(null);
- textField = new JTextField();
- textField.setBounds(55, 11, 46, 20);
- frmc.getContentPane().add(textField);
- textField.setColumns(10);
- JLabel lblDrinkAt = new JLabel("Drink at");
- lblDrinkAt.setBounds(10, 14, 46, 14);
- frmc.getContentPane().add(lblDrinkAt);
- JLabel lblPrayerPoints = new JLabel("prayer points.");
- lblPrayerPoints.setBounds(111, 14, 77, 14);
- frmc.getContentPane().add(lblPrayerPoints);
- JButton btnStart = new JButton("Start");
- btnStart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- drink_at = Integer.parseInt(textField.getText());
- gui_COMPLETE = true;
- }
- });
- btnStart.setBounds(10, 57, 201, 23);
- frmc.getContentPane().add(btnStart);
- JLabel lblRandomizedBy = new JLabel("Prioritises lower doses first.");
- lblRandomizedBy.setForeground(Color.GRAY);
- lblRandomizedBy.setBounds(10, 32, 201, 23);
- frmc.getContentPane().add(lblRandomizedBy);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement