Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = {"Issues"}, keywords = "deve", name = "Path Maker", version = 0.1, description = ("Create paths for your script in seconds."))
- public class PathMaker extends Script {
- private String PATH;
- private PathMakerGUI GUI;
- private boolean autoAddPos;
- private RSTile lastTile = null;
- @Override
- public boolean onStart() {
- GUI = new PathMakerGUI();
- GUI.setVisible(true);
- return true;
- }
- @Override
- public int loop() {
- if (GUI.isVisible()) {
- if (autoAddPos) {
- if (lastTile == null || calc.distanceBetween(lastTile, getMyPlayer().getLocation()) >= 8) {
- GUI.nodeListModel.add(GUI.nodeList.getModel().getSize(), "" + getMyPlayer().getLocation() + "");
- lastTile = getMyPlayer().getLocation();
- GUI.nodeList.setSelectedIndex(GUI.nodeList.getModel().getSize());
- }
- }
- } else {
- stopScript();
- }
- return 1000;
- }
- @SuppressWarnings("serial")
- public class PathMakerGUI extends javax.swing.JFrame {
- public PathMakerGUI() {
- initComponents();
- }
- private void initComponents() {
- nodeListModel = new javax.swing.DefaultListModel();
- pathArea = new javax.swing.JTextArea();
- pathLabel = new javax.swing.JLabel();
- importLabel = new javax.swing.JLabel();
- importScroll = new javax.swing.JScrollPane();
- importArea = new javax.swing.JTextArea();
- nodeScroll = new javax.swing.JScrollPane();
- nodeList = new javax.swing.JList(nodeListModel);
- addPPos = new javax.swing.JButton();
- genCode = new javax.swing.JButton();
- autoAdd = new javax.swing.JCheckBox();
- autoAddS = new javax.swing.JSpinner();
- tilesLable = new javax.swing.JLabel();
- nodeLabel = new javax.swing.JLabel();
- deleteSelected = new javax.swing.JButton();
- pathArea.setColumns(20);
- pathArea.setEditable(false);
- pathArea.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- pathArea.setRows(5);
- pathLabel.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- pathLabel.setText("Path:");
- importLabel.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- importLabel.setText("Import needed:");
- importScroll.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- importScroll.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
- importArea.setColumns(1);
- importArea.setEditable(false);
- importArea.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- importArea.setRows(5);
- importArea.setText("import org.rsbot.script.wrappers.RSTile;");
- importScroll.setViewportView(importArea);
- setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
- setResizable(false);
- setTitle("Path Maker");
- nodeList.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- nodeScroll.setViewportView(nodeList);
- addPPos.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- addPPos.setText("Add Players Position");
- addPPos.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- addPPosActionPerformed(evt);
- }
- });
- genCode.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- genCode.setText("Generate Code");
- genCode.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- genCodeActionPerformed(evt);
- }
- });
- autoAdd.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- autoAdd.setText("Auto Add Every");
- autoAdd.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- autoAddActionPerformed(evt);
- }
- });
- autoAddS.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- autoAddS.setModel(new javax.swing.SpinnerNumberModel(8, 1, 40, 1));
- autoAddS.setEnabled(false);
- tilesLable.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- tilesLable.setText(" Tiles.");
- nodeLabel.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- nodeLabel.setText("Current Nodes:");
- deleteSelected.setFont(new java.awt.Font("NSimSun", 0, 11)); // NOI18N
- deleteSelected.setText("Delete Selected");
- deleteSelected.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- deleteSelectedActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(nodeScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(autoAdd) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(autoAddS, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tilesLable)) .addComponent(nodeLabel) .addGroup(layout.createSequentialGroup() .addComponent(addPPos) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(deleteSelected) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(genCode))) .addContainerGap()) );
- layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(nodeLabel) .addGap(5, 5, 5) .addComponent(nodeScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(autoAddS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tilesLable) .addComponent(autoAdd)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addPPos) .addComponent(deleteSelected) .addComponent(genCode)) .addContainerGap()) );
- pack();
- setLocationRelativeTo(getOwner());
- }
- private void addPPosActionPerformed(java.awt.event.ActionEvent evt) {
- nodeListModel.add(nodeList.getModel().getSize(), "" + getMyPlayer().getLocation() + "");
- nodeList.setSelectedIndex(nodeList.getModel().getSize());
- }
- private void deleteSelectedActionPerformed(java.awt.event.ActionEvent evt) {
- if (nodeList.getSelectedIndex() == -1)
- return;
- int lastSelected = nodeList.getSelectedIndex();
- nodeListModel.remove(nodeList.getSelectedIndex());
- nodeList.setSelectedIndex(lastSelected);
- }
- private void genCodeActionPerformed(java.awt.event.ActionEvent evt) {
- PATH = "private RSTile[] path = {";
- for(int i = 0; i < nodeList.getModel().getSize(); i++) {
- String node = (String) nodeList.getModel().getElementAt(i);
- if ( i != nodeList.getModel().getSize() - 1) {
- PATH += " new RSTile" + node + ", ";
- } else {
- PATH += " new RSTile" + node + " ";
- }
- }
- PATH += "};";
- pathArea.setText(PATH);
- pathArea.selectAll();
- pathArea.copy();
- javax.swing.JOptionPane.showMessageDialog(null, "Path has been generated and copied to clipboard.");
- }
- private void autoAddActionPerformed(java.awt.event.ActionEvent evt) {
- if (autoAdd.isSelected()) {
- addPPos.setEnabled(false);
- autoAddS.setEnabled(true);
- autoAddPos = true;
- } else {
- addPPos.setEnabled(true);
- autoAddS.setEnabled(false);
- autoAddPos = true;
- }
- }
- private javax.swing.DefaultListModel nodeListModel;
- private javax.swing.JButton addPPos;
- private javax.swing.JCheckBox autoAdd;
- private javax.swing.JSpinner autoAddS;
- private javax.swing.JButton deleteSelected;
- private javax.swing.JButton genCode;
- private javax.swing.JTextArea importArea;
- private javax.swing.JLabel importLabel;
- private javax.swing.JScrollPane importScroll;
- private javax.swing.JLabel nodeLabel;
- private javax.swing.JList nodeList;
- private javax.swing.JScrollPane nodeScroll;
- private javax.swing.JTextArea pathArea;
- private javax.swing.JLabel pathLabel;
- private javax.swing.JLabel tilesLable;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement