Guest User

Mass Accounts Open Source

a guest
May 18th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.33 KB | None | 0 0
  1. package org.dreambot.hashtag.massaccounts;
  2.  
  3. import javafx.util.Pair;
  4. import org.dreambot.api.methods.Calculations;
  5. import org.dreambot.api.script.AbstractScript;
  6. import org.dreambot.api.script.Category;
  7. import org.dreambot.api.script.ScriptManifest;
  8.  
  9. import javax.swing.*;
  10. import java.awt.*;
  11. import java.io.BufferedReader;
  12. import java.io.File;
  13. import java.io.FileReader;
  14. import java.io.IOException;
  15. import java.text.DecimalFormat;
  16. import java.util.ArrayList;
  17. import java.util.List;
  18.  
  19. /**
  20.  * Created by Hashtag on 18.5.2017.
  21.  */
  22. @ScriptManifest(category = Category.MISC, name = "Mass Accounts Open Source", author = "Hashtag", version = 2.0)
  23. public class MassAccounts extends AbstractScript {
  24.  
  25.     private List<Pair<String, String>> accounts;
  26.     private String nickname;
  27.     private String pin;
  28.     private int count;
  29.  
  30.     @Override
  31.     public void onStart() {
  32.         accounts = new ArrayList<Pair<String, String>>();
  33.         JFrame frame = new JFrame("Mass Accounts Open Source");
  34.         frame.setPreferredSize(new Dimension(400, 150));
  35.         frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  36.         frame.setLocationRelativeTo(getClient().getInstance().getCanvas());
  37.         JPanel panel = new JPanel(new GridLayout(0, 2));
  38.         JLabel fileLabel = new JLabel("No selected file");
  39.         panel.add(fileLabel);
  40.         JButton fileButton = new JButton("Select file");
  41.         fileButton.addActionListener(l -> {
  42.             final JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home") + File.separator + "Desktop");
  43.             int returnValue = fileChooser.showOpenDialog(getClient().getInstance().getCanvas());
  44.             if (returnValue == JFileChooser.APPROVE_OPTION) {
  45.                 accounts.clear();
  46.                 File newFile = fileChooser.getSelectedFile();
  47.                 try (BufferedReader reader = new BufferedReader(new FileReader(newFile))) {
  48.                     String line;
  49.                     while ((line = reader.readLine()) != null) {
  50.                         if (!line.contains(":")) continue;
  51.                         String[] detail = line.split(":");
  52.                         accounts.add(new Pair<>(detail[0], detail[1]));
  53.                     }
  54.                     fileLabel.setText(accounts.size() + " accounts");
  55.                 } catch (IOException e) {
  56.                     accounts.clear();
  57.                     fileLabel.setText("No selected file");
  58.                     e.printStackTrace();
  59.                 }
  60.             }
  61.         });
  62.         panel.add(fileButton);
  63.         JLabel label = new JLabel("Nickname");
  64.         panel.add(label);
  65.         JTextField nicknameText = new JTextField("");
  66.         panel.add(nicknameText);
  67.         label = new JLabel("PIN");
  68.         panel.add(label);
  69.         JTextField pinText = new JTextField("");
  70.         panel.add(pinText);
  71.         label = new JLabel("Ready?");
  72.         panel.add(label);
  73.         JButton startButton = new JButton("Start");
  74.         startButton.addActionListener(l -> {
  75.             if (!accounts.isEmpty()) {
  76.                 nickname = nicknameText.getText();
  77.                 pin = pinText.getText();
  78.                 frame.dispose();
  79.                 commonStart();
  80.             }
  81.         });
  82.         panel.add(startButton);
  83.         frame.getContentPane().add(panel);
  84.         frame.pack();
  85.         frame.setVisible(true);
  86.     }
  87.  
  88.     @Override
  89.     public void onStart(String... params) {
  90.         accounts = new ArrayList<Pair<String, String>>();
  91.         File newFile = new File(params[0]);
  92.         try (BufferedReader reader = new BufferedReader(new FileReader(newFile))) {
  93.             String line;
  94.             while ((line = reader.readLine()) != null) {
  95.                 if (!line.contains(":")) continue;
  96.                 String[] detail = line.split(":");
  97.                 accounts.add(new Pair<>(detail[0], detail[1]));
  98.             }
  99.             System.out.println(accounts.size() + " accounts");
  100.         } catch (IOException e) {
  101.             e.printStackTrace();
  102.         }
  103.         nickname = params[1];
  104.         pin = params[2];
  105.         commonStart();
  106.     }
  107.  
  108.     private void commonStart() {
  109.         for (Pair<String, String> account : accounts) {
  110.             String nickname = this.nickname;
  111.             String username = account.getKey();
  112.             String password = account.getValue();
  113.             if (nickname == null || nickname.equals(""))
  114.                 nickname = username.substring(0, 6) + Calculations.random(10) + Calculations.random(10) + Calculations.random(10);
  115.             else nickname += count;
  116.             if (pin == null) pin = "";
  117.             addAccount(nickname, username, password, pin);
  118.             count++;
  119.         }
  120.     }
  121.  
  122.     @Override
  123.     public int onLoop() {
  124.         return 600;
  125.     }
  126.  
  127.     private DecimalFormat df = new DecimalFormat("0.0");
  128.  
  129.     @Override
  130.     public void onPaint(Graphics g) {
  131.         if (accounts.isEmpty()) return;
  132.         double percentage = ((double)count / (double)accounts.size()) * 100d;
  133.         g.setFont(new Font("Arial", Font.BOLD, 50));
  134.         FontMetrics fm = g.getFontMetrics();
  135.         String s = df.format(percentage )+ "%";
  136.         if (percentage == 100)
  137.             g.setColor(Color.GREEN);
  138.         else
  139.             g.setColor(Color.YELLOW);
  140.         g.drawString(s, 765 / 2 - fm.stringWidth(s) / 2, 230);
  141.     }
  142.  
  143. }
Add Comment
Please, Sign In to add comment