SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package AutoCooker;
  2.  
  3. import javax.swing.*;
  4.  
  5. import java.awt.event.ActionListener;
  6. import java.awt.event.ActionEvent;
  7.  
  8. import java.awt.Graphics;
  9. import java.text.DateFormat;
  10. import java.text.SimpleDateFormat;
  11. import java.util.ArrayList;
  12. import java.util.Collections;
  13. import java.util.Date;
  14. import java.util.List;
  15. import java.util.TimeZone;
  16.  
  17. import org.powerbot.core.event.listeners.MessageListener;
  18. import org.powerbot.core.event.events.MessageEvent;
  19. import org.powerbot.core.event.listeners.PaintListener;
  20. import org.powerbot.core.script.ActiveScript;
  21. import org.powerbot.core.script.job.state.Node;
  22. import org.powerbot.core.script.job.state.Tree;
  23. import org.powerbot.game.api.Manifest;
  24. import org.powerbot.game.api.methods.tab.Skills;
  25. import org.powerbot.game.api.util.Random;
  26.  
  27. import AutoCooker.Jobs.Banking;
  28. import AutoCooker.Jobs.Cons;
  29. import AutoCooker.Jobs.Cook;
  30. import AutoCooker.Utils.Food;
  31. import AutoCooker.Utils.Paint;
  32.  
  33. @Manifest(authors = ("Raedtony"), name = "RDCooker", description = "Cooking Script", version = 0.1)
  34. public class Cooker extends ActiveScript implements PaintListener, MessageListener {
  35.     public static Food cfood;
  36.     public static String sFood = "Nothing", sStatus = "Waiting",sTTL="00 hrs";
  37.     public static long lCooked = 0, lBurned =0, lCookPh =0,
  38.             lLevel=0, lXPHr=0,lTime=1, lILevel=0, lIXP=0, lXPLevel=0;
  39.  
  40.     private final List<Node> jobsCollection = Collections
  41.             .synchronizedList(new ArrayList<Node>());
  42.     private Tree jobContainer = null;
  43.  
  44.     public final void provide(final Node... jobs) {
  45.         for (final Node job : jobs) {
  46.             jobsCollection.add(job);
  47.         }
  48.         jobContainer = new Tree(jobsCollection.toArray(new Node[jobsCollection
  49.                 .size()]));
  50.     }
  51.  
  52.     public synchronized final void revoke(final Node... jobs) {
  53.         for (final Node job : jobs) {
  54.                 if (jobsCollection.contains(job)) {
  55.                         jobsCollection.remove(job);
  56.                 }
  57.         }
  58.         jobContainer = new Tree(jobsCollection.toArray(new Node[jobsCollection.size()]));
  59.     }
  60.  
  61.     @Override
  62.     public void onStart() {
  63.         sStatus = "Waiting for user...";
  64.         lILevel=Skills.getLevel(Skills.COOKING);
  65.         lLevel=Skills.getLevel(Skills.COOKING);
  66.         lTime=System.currentTimeMillis();
  67.         lIXP=Skills.getExperience(Skills.COOKING);
  68.         lXPLevel=Skills.getExperienceToLevel(Skills.COOKING, (int) (lLevel+1));
  69.         GUI gui = new GUI();
  70.         gui.setVisible(true);
  71.  
  72.     }
  73.  
  74.     @Override
  75.     public void messageReceived(MessageEvent arg0) {
  76.         if (arg0.getMessage().contains("You successfully cook") || arg0.getMessage().contains("You manage to")) {
  77.             lCooked++;
  78.         } else if (arg0.getMessage().contains("You accidentally")) {
  79.             lBurned++;
  80.         }
  81.  
  82.     }
  83.  
  84.     public static String getTime() {
  85.         DateFormat outFormat = new SimpleDateFormat("HH:mm:ss");
  86.         outFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
  87.  
  88.         Date d = new Date(System.currentTimeMillis()-lTime);
  89.         String result = outFormat.format(d);
  90.  
  91.         lXPLevel=Skills.getExperienceToLevel(Skills.COOKING, (int) (lLevel+1));
  92.         lLevel=Skills.getLevel(Skills.COOKING);
  93.         lXPHr=((Skills.getExperience(Skills.COOKING)-lIXP)*3600000)/(System.currentTimeMillis()-lTime);
  94.         lCookPh=(lCooked*3600000)/(System.currentTimeMillis()-lTime);
  95.         if (lXPHr>0) {
  96.             Date xp = new Date(Math.round(((double)lXPLevel/(double)lXPHr)*3600000));
  97.             sTTL=String.valueOf(outFormat.format(xp));
  98.         }
  99.  
  100.         return result;
  101.     }
  102.  
  103.  
  104.     public void Ready() {
  105.         sFood = cfood.name();
  106.         provide(new Cook(), new Banking());
  107.     }
  108.  
  109.     @Override
  110.     public void onRepaint(Graphics arg0) {
  111.         Paint.drawMouse(arg0);
  112.         Paint.drawPaint(arg0);
  113.  
  114.     }
  115.  
  116.     @Override
  117.     public int loop() {
  118.         if (jobContainer != null) {
  119.             final Node job = jobContainer.state();
  120.             if (job != null) {
  121.                 jobContainer.set(job);
  122.                 getContainer().submit(job);
  123.                 job.join();
  124.                 if (Cons.isDone) {
  125.                     revoke(job);
  126.                 }
  127.             } else
  128.                 shutdown();
  129.         }
  130.         return Random.nextInt(10, 50);
  131.     }
  132.  
  133.     public class GUI extends JFrame {
  134.         /**
  135.          *
  136.          */
  137.         private static final long serialVersionUID = 1L;
  138.  
  139.         public GUI() {
  140.             init();
  141.  
  142.         }
  143.  
  144.         private void init() {
  145.             setType(Type.UTILITY);
  146.             setTitle("JDCooker Settings");
  147.             setBounds(100, 100, 211, 139);
  148.             setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  149.             getContentPane().setLayout(null);
  150.  
  151.             String[] cFood = { "Shrimp", "Manta", "Herring", "Trout", "Cod",
  152.                     "Pike", "Salmon", "Tuna", "Lobster", "Crayfish",
  153.                     "Karambwajin", "Sardine", "Anchovies", "Macherel",
  154.                     "Karambwan", "RainbowFish", "CaveEel", "Bass", "Swordfish",
  155.                     "LavaEel", "Monkfish", "Shark", "SeaTurtle" };
  156.  
  157.  
  158.             @SuppressWarnings({ "rawtypes", "unchecked" })
  159.             final JComboBox cboFood = new JComboBox(cFood);
  160.             cboFood.setBounds(10, 40, 175, 20);
  161.             getContentPane().add(cboFood);
  162.  
  163.             JLabel lblType = new JLabel("Type of Food:");
  164.             lblType.setBounds(10, 11, 72, 14);
  165.             getContentPane().add(lblType);
  166.  
  167.             JButton btnStart = new JButton("Start");
  168.             btnStart.setBounds(89, 71, 96, 23);
  169.             btnStart.addActionListener(new ActionListener() {
  170.                 public void actionPerformed(ActionEvent arg0) {
  171.                     cfood = Food.valueOf((String) cboFood.getSelectedItem());
  172.                     Ready();
  173.                     setVisible(false);
  174.                 }
  175.             });
  176.             getContentPane().add(btnStart);
  177.         }
  178.     }
  179.  
  180.  
  181.  
  182. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top