Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.dreambot.hashtag.massaccounts;
- import javafx.util.Pair;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import javax.swing.*;
- import java.awt.*;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * Created by Hashtag on 18.5.2017.
- */
- @ScriptManifest(category = Category.MISC, name = "Mass Accounts Open Source", author = "Hashtag", version = 2.0)
- public class MassAccounts extends AbstractScript {
- private List<Pair<String, String>> accounts;
- private String nickname;
- private String pin;
- private int count;
- @Override
- public void onStart() {
- accounts = new ArrayList<Pair<String, String>>();
- JFrame frame = new JFrame("Mass Accounts Open Source");
- frame.setPreferredSize(new Dimension(400, 150));
- frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- frame.setLocationRelativeTo(getClient().getInstance().getCanvas());
- JPanel panel = new JPanel(new GridLayout(0, 2));
- JLabel fileLabel = new JLabel("No selected file");
- panel.add(fileLabel);
- JButton fileButton = new JButton("Select file");
- fileButton.addActionListener(l -> {
- final JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home") + File.separator + "Desktop");
- int returnValue = fileChooser.showOpenDialog(getClient().getInstance().getCanvas());
- if (returnValue == JFileChooser.APPROVE_OPTION) {
- accounts.clear();
- File newFile = fileChooser.getSelectedFile();
- try (BufferedReader reader = new BufferedReader(new FileReader(newFile))) {
- String line;
- while ((line = reader.readLine()) != null) {
- if (!line.contains(":")) continue;
- String[] detail = line.split(":");
- accounts.add(new Pair<>(detail[0], detail[1]));
- }
- fileLabel.setText(accounts.size() + " accounts");
- } catch (IOException e) {
- accounts.clear();
- fileLabel.setText("No selected file");
- e.printStackTrace();
- }
- }
- });
- panel.add(fileButton);
- JLabel label = new JLabel("Nickname");
- panel.add(label);
- JTextField nicknameText = new JTextField("");
- panel.add(nicknameText);
- label = new JLabel("PIN");
- panel.add(label);
- JTextField pinText = new JTextField("");
- panel.add(pinText);
- label = new JLabel("Ready?");
- panel.add(label);
- JButton startButton = new JButton("Start");
- startButton.addActionListener(l -> {
- if (!accounts.isEmpty()) {
- nickname = nicknameText.getText();
- pin = pinText.getText();
- frame.dispose();
- commonStart();
- }
- });
- panel.add(startButton);
- frame.getContentPane().add(panel);
- frame.pack();
- frame.setVisible(true);
- }
- @Override
- public void onStart(String... params) {
- accounts = new ArrayList<Pair<String, String>>();
- File newFile = new File(params[0]);
- try (BufferedReader reader = new BufferedReader(new FileReader(newFile))) {
- String line;
- while ((line = reader.readLine()) != null) {
- if (!line.contains(":")) continue;
- String[] detail = line.split(":");
- accounts.add(new Pair<>(detail[0], detail[1]));
- }
- System.out.println(accounts.size() + " accounts");
- } catch (IOException e) {
- e.printStackTrace();
- }
- nickname = params[1];
- pin = params[2];
- commonStart();
- }
- private void commonStart() {
- for (Pair<String, String> account : accounts) {
- String nickname = this.nickname;
- String username = account.getKey();
- String password = account.getValue();
- if (nickname == null || nickname.equals(""))
- nickname = username.substring(0, 6) + Calculations.random(10) + Calculations.random(10) + Calculations.random(10);
- else nickname += count;
- if (pin == null) pin = "";
- addAccount(nickname, username, password, pin);
- count++;
- }
- }
- @Override
- public int onLoop() {
- return 600;
- }
- private DecimalFormat df = new DecimalFormat("0.0");
- @Override
- public void onPaint(Graphics g) {
- if (accounts.isEmpty()) return;
- double percentage = ((double)count / (double)accounts.size()) * 100d;
- g.setFont(new Font("Arial", Font.BOLD, 50));
- FontMetrics fm = g.getFontMetrics();
- String s = df.format(percentage )+ "%";
- if (percentage == 100)
- g.setColor(Color.GREEN);
- else
- g.setColor(Color.YELLOW);
- g.drawString(s, 765 / 2 - fm.stringWidth(s) / 2, 230);
- }
- }
Add Comment
Please, Sign In to add comment