Advertisement
Guest User

CCSpammer.java

a guest
Nov 24th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.Toolkit;
  5.  
  6. import org.tribot.api.input.Keyboard;
  7. import org.tribot.api.input.Mouse;
  8. import org.tribot.api2007.NPCChat;
  9. import org.tribot.script.Script;
  10. import org.tribot.script.ScriptManifest;
  11.  
  12. @ScriptManifest(authors = { "Coca Cola" }, category = "Tools", name = "MessageSpammer")
  13. public class CCSpammer extends Script {
  14.  
  15. public boolean GUI_COMPLETE = false;
  16.  
  17. public String MESSAGE;
  18.  
  19. @Override
  20. public void run() {
  21.  
  22. Mouse.setSpeed(200);
  23.  
  24. GUI GUI = new GUI();
  25.  
  26. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  27. int screenW = screenSize.width;
  28. int screenH = screenSize.height;
  29.  
  30. Dimension dim = GUI.getSize();
  31.  
  32. GUI.setVisible(true);
  33. println("GUI is open. Please select desired settings.");
  34.  
  35. GUI.setLocation((screenW / 2) - (dim.width / 2), (screenH / 2) - (dim.height / 2));
  36.  
  37. while(!GUI_COMPLETE) {
  38. sleep(200);
  39. }
  40.  
  41. GUI.setVisible(false);
  42.  
  43. println("GUI Closed. Script initialized with chosen settings.");
  44.  
  45. if (onStart()) {
  46. while (true) {
  47. sleep(loop());
  48. }
  49. }
  50.  
  51. }
  52.  
  53. public class GUI extends javax.swing.JFrame {
  54.  
  55. /**
  56. * Creates new form GUI
  57. */
  58. public GUI() {
  59. initComponents();
  60. }
  61.  
  62. /**
  63. * This method is called from within the constructor to initialize the form.
  64. * WARNING: Do NOT modify this code. The content of this method is always
  65. * regenerated by the Form Editor.
  66. */
  67. @SuppressWarnings("unchecked")
  68. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  69. private void initComponents() {
  70.  
  71. START_BUTTON = new javax.swing.JButton();
  72. MESSAGE_BOX = new javax.swing.JTextField();
  73. jLabel1 = new javax.swing.JLabel();
  74.  
  75. setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  76. setAlwaysOnTop(true);
  77. setBackground(new java.awt.Color(255, 255, 255));
  78. setForeground(new java.awt.Color(0, 0, 0));
  79.  
  80. START_BUTTON.setText("Start");
  81. START_BUTTON.addActionListener(new java.awt.event.ActionListener() {
  82. public void actionPerformed(java.awt.event.ActionEvent evt) {
  83. START_BUTTONActionPerformed(evt);
  84. }
  85. });
  86.  
  87. MESSAGE_BOX.setForeground(new java.awt.Color(51, 51, 51));
  88. MESSAGE_BOX.setHorizontalAlignment(javax.swing.JTextField.LEFT);
  89.  
  90. jLabel1.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
  91. jLabel1.setForeground(new java.awt.Color(51, 51, 51));
  92. jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  93. jLabel1.setText("Enter the message you would like to spam and click start");
  94.  
  95. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  96. getContentPane().setLayout(layout);
  97. layout.setHorizontalGroup(
  98. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  100. .addGap(0, 0, Short.MAX_VALUE)
  101. .addComponent(MESSAGE_BOX, javax.swing.GroupLayout.PREFERRED_SIZE, 319, javax.swing.GroupLayout.PREFERRED_SIZE)
  102. .addGap(55, 55, 55))
  103. .addGroup(layout.createSequentialGroup()
  104. .addGap(170, 170, 170)
  105. .addComponent(START_BUTTON)
  106. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  107. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE)
  108. );
  109. layout.setVerticalGroup(
  110. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  111. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  112. .addContainerGap()
  113. .addComponent(jLabel1)
  114. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
  115. .addComponent(MESSAGE_BOX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  116. .addGap(18, 18, 18)
  117. .addComponent(START_BUTTON)
  118. .addContainerGap())
  119. );
  120.  
  121. pack();
  122. }// </editor-fold>
  123.  
  124. private void START_BUTTONActionPerformed(java.awt.event.ActionEvent evt) {
  125.  
  126. MESSAGE = MESSAGE_BOX.getText().toString();
  127.  
  128. if (MESSAGE == null) {
  129. println("You need to type a message in the GUI first!");
  130. return;
  131. } else {
  132. GUI_COMPLETE = true;
  133. }
  134.  
  135. }
  136.  
  137. // Variables declaration - do not modify
  138. private javax.swing.JTextField MESSAGE_BOX;
  139. private javax.swing.JButton START_BUTTON;
  140. private javax.swing.JLabel jLabel1;
  141. // End of variables declaration
  142. }
  143.  
  144. private boolean onStart() {
  145. println("Coca Cola's Spammer has started!");
  146. return true;
  147.  
  148. }
  149.  
  150. private int loop() {
  151.  
  152. if(NPCChat.getClickContinueInterface() != null) {
  153. NPCChat.clickContinue(true);
  154. } else {
  155. Keyboard.typeSend(""+MESSAGE);
  156. }
  157.  
  158. return 42;
  159. }
  160.  
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement