Guest User

Untitled

a guest
Sep 14th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.27 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Container;
  3. import java.awt.Dimension;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Insets;
  8. import java.awt.Rectangle;
  9.  
  10. import org.powerbot.concurrent.Task;
  11. import org.powerbot.concurrent.strategy.Strategy;
  12. import org.powerbot.game.api.ActiveScript;
  13. import org.powerbot.game.api.Manifest;
  14. import org.powerbot.game.api.methods.Tabs;
  15. import org.powerbot.game.api.methods.Widgets;
  16. import org.powerbot.game.api.methods.input.Mouse;
  17. import org.powerbot.game.api.methods.interactive.Players;
  18. import org.powerbot.game.api.methods.tab.Inventory;
  19. import org.powerbot.game.api.methods.tab.Skills;
  20. import org.powerbot.game.api.util.Time;
  21. import org.powerbot.game.api.util.Timer;
  22. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  23. import org.powerbot.game.bot.event.listener.PaintListener;
  24.  
  25. import java.awt.*;
  26. import java.awt.event.ActionEvent;
  27. import java.awt.event.ActionListener;
  28.  
  29. import javax.swing.DefaultComboBoxModel;
  30. import javax.swing.JButton;
  31. import javax.swing.JComboBox;
  32. import javax.swing.JFrame;
  33. import javax.swing.JLabel;
  34.  
  35.  
  36. @Manifest(authors = { "Syndicate" }, name = "SAlcher", description = "Alch Those Items", version = 1.0)
  37. public class SAlcher extends ActiveScript implements PaintListener{
  38.  
  39. public long startTime = 0;
  40. public long millis = 0;
  41. public long hours= 0;
  42. public long minutes = 0;
  43. public long seconds = 0;
  44. private static int startXP;
  45. public String Status;
  46.  
  47. protected void setup1() {
  48. Status = "Starting Up";
  49. startTime = System.currentTimeMillis();
  50. startXP = Skills.getExperience(Skills.MAGIC);
  51.  
  52. }
  53.  
  54. public class Alcher extends Strategy implements Task {
  55. @Override
  56. public boolean validate() {
  57. return Players.getLocal().getAnimation() == -1;
  58. }
  59.  
  60.  
  61. @Override
  62. public void run() {
  63. if(Tabs.getCurrent() != Tabs.MAGIC) {
  64. Tabs.MAGIC.open();
  65. Timer t = new Timer(2000);
  66. while(t.isRunning() && Tabs.getCurrent() !=Tabs.MAGIC){
  67. Time.sleep(50);
  68. }
  69. }else{
  70. WidgetChild Alch = Widgets.get(192,27);
  71. if(Alch !=null){
  72. Alch.click(true);
  73. Inventory.getItem(1733 , 1135 , 1123 , 230 , 1333 , 2358 , 1464 , 63 , 11070 , 892).getWidgetChild().interact("cast");
  74. Time.sleep(1500,2000);
  75. }
  76. }
  77. }
  78.  
  79. }
  80.  
  81.  
  82. private int getPerHour (final long value) {
  83. return (int) (value * 3600000D / (System.currentTimeMillis() - startTime ));
  84. }
  85.  
  86. private final Color color1 = new Color(0, 232, 255, 130);
  87. private final Color color2 = new Color(0, 0, 0);
  88. private final Color color3 = new Color(1, 1, 1);
  89.  
  90. private final BasicStroke stroke1 = new BasicStroke(1);
  91.  
  92. private final Font font1 = new Font("Bitstream Charter", 1, 15);
  93. private final Font font2 = new Font("Bitstream Charter", 1, 13);
  94. private final Font font3 = new Font("Bitstream Charter", 1, 17);
  95. private final Font font4 = new Font("Bitstream Charter", 1, 12);
  96.  
  97. private int xpGained;
  98. private String xpPH;
  99.  
  100. public void onRepaint(Graphics g1) {
  101. setXpGained(Skills.getExperience(Skills.MAGIC - startXP));
  102. long millis = System.currentTimeMillis() - startTime;
  103. long hours = millis / (1000 * 60 * 60);
  104. millis -= hours * (1000 * 60 * 60);
  105. long minutes = millis / (1000 * 60);
  106. millis -= minutes * (1000 * 60);
  107. long seconds = millis / 1000;
  108.  
  109. Graphics2D g = (Graphics2D)g1;
  110.  
  111. g.setColor(color1);
  112. g.fillRoundRect(3, 61, 185, 242, 16, 16);
  113. g.setColor(color2);
  114. g.setStroke(stroke1);
  115. g.drawRoundRect(3, 61, 185, 242, 16, 16);
  116. g.setFont(font1);
  117. g.setColor(color3);
  118. g.drawString("SAlcher", 54, 74);
  119. g.setFont(font2);
  120. g.drawString("RunTime:" + hours + ":" + minutes + ":" + seconds, 6, 99);
  121. g.drawString("Xp P/h:" + xpPH, 6, 147);
  122. g.drawString("Xp Gained:" + xpGained, 7, 197);
  123. g.setFont(font3);
  124. g.drawString("Made By Syndicate", 16, 301);
  125. g.setFont(font4);
  126.  
  127.  
  128.  
  129. g.drawLine(Mouse.getLocation().x - 6, Mouse.getLocation().y,
  130. Mouse.getLocation().x + 6, Mouse.getLocation().y);
  131. g.drawLine(Mouse.getLocation
  132.  
  133. ().x, Mouse.getLocation().y - 6,
  134.  
  135.  
  136. Mouse.getLocation().x, Mouse.getLocation().y + 6);
  137.  
  138. class SAlcherGUI extends JFrame {
  139. public SAlcherGUI() {
  140. initComponents();
  141. }
  142.  
  143. private void comboBox1ActionPerformed(ActionEvent e) {
  144. // TODO add your code here
  145. }
  146.  
  147. private void button1ActionPerformed(ActionEvent e) {
  148. // TODO add your code here
  149. }
  150.  
  151. private void initComponents() {
  152. //GEN-BEGIN:initComponents
  153.  
  154. label1 = new JLabel();
  155. label2 = new JLabel();
  156. comboBox1 = new JComboBox<>();
  157. button1 = new JButton();
  158.  
  159. //======== this ========
  160. Container contentPane = getContentPane();
  161. contentPane.setLayout(null);
  162.  
  163. //---- label1 ----
  164. label1.setText("SAlcher GUI v1");
  165. label1.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 26));
  166. contentPane.add(label1);
  167. label1.setBounds(85, 0, 180, 30);
  168.  
  169. //---- label2 ----
  170. label2.setText("Select An Item To Alch");
  171. label2.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 18));
  172. contentPane.add(label2);
  173. label2.setBounds(85, 60, 195, 30);
  174.  
  175. //---- comboBox1 ----
  176. comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
  177. "Select an item ",
  178. "needles ",
  179. "rune scim ",
  180. "Greendhidebody ",
  181. "goldbars ",
  182. "vials",
  183. "Archery tickets ",
  184. "Maple longs u ",
  185. "gold braclets ",
  186. "rune arrows "
  187. }));
  188. comboBox1.addActionListener(new ActionListener() {
  189. @Override
  190. public void actionPerformed(ActionEvent e) {
  191. comboBox1ActionPerformed(e);
  192. }
  193. });
  194. contentPane.add(comboBox1);
  195. comboBox1.setBounds(85, 135, 185, 30);
  196.  
  197. //---- button1 ----
  198. button1.setText("Start");
  199. button1.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 22));
  200. button1.addActionListener(new ActionListener() {
  201. @Override
  202. public void actionPerformed(ActionEvent e) {
  203. button1ActionPerformed(e);
  204. }
  205. });
  206. contentPane.add(button1);
  207. button1.setBounds(120, 200, 100, 45);
  208.  
  209. { // compute preferred size
  210. Dimension preferredSize = new Dimension();
  211. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  212. Rectangle bounds = contentPane.getComponent(i).getBounds();
  213. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  214. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  215. }
  216. Insets insets = contentPane.getInsets();
  217. preferredSize.width += insets.right;
  218. preferredSize.height += insets.bottom;
  219. contentPane.setMinimumSize(preferredSize);
  220. contentPane.setPreferredSize(preferredSize);
  221. }
  222. pack();
  223. setLocationRelativeTo(getOwner());
  224. //GEN-END:initComponents
  225. }
  226.  
  227. //GEN-BEGIN:variables
  228.  
  229. private JLabel label1;
  230. private JLabel label2;
  231. private JComboBox<String> comboBox1;
  232. private JButton button1;
  233. //GEN-END:variables
  234. }
  235.  
  236.  
  237. }
  238.  
  239. @Override
  240. protected void setup() {
  241. provide(new Alcher());
  242.  
  243. }
  244.  
  245.  
  246. public int getXpGained() {
  247. return xpGained;
  248. }
  249.  
  250.  
  251. public void setXpGained(int xpGained) {
  252. this.xpGained = xpGained;
  253. }
  254.  
  255. }
Add Comment
Please, Sign In to add comment