Advertisement
Guest User

Paint Tutorial Example 5

a guest
Aug 16th, 2015
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. import java.awt.Graphics;
  2. import java.text.DecimalFormat;
  3. import java.util.concurrent.TimeUnit;
  4.  
  5. import org.dreambot.api.methods.skills.Skill;
  6. import org.dreambot.api.methods.tabs.Tab;
  7. import org.dreambot.api.script.AbstractScript;
  8. import org.dreambot.api.script.Category;
  9. import org.dreambot.api.script.ScriptManifest;
  10. import org.dreambot.api.utilities.Timer;
  11. import org.dreambot.api.wrappers.interactive.GameObject;
  12.  
  13.  
  14. @ScriptManifest(author = "Pug", name = "paint tutorial", version = 0.01, description = "0.01", category = Category.MISC)
  15. public class test extends AbstractScript
  16. {
  17.  
  18.     // PAINT VARIABLE DECLARATIONS
  19.     private long timeRan;
  20.     private long timeBegan;
  21.    
  22.     private int costOfItem;
  23.     private int itemsMade;
  24.     private double gpGained;
  25.     private double totalGpGained;
  26.    
  27.     private int gpPerHour;
  28.     private int totalGpPerHour;
  29.    
  30.     // ONSTART() METHOD
  31.     public void onStart()
  32.     {
  33.         timeBegan = System.currentTimeMillis();
  34.         costOfItem = 500;
  35.     }
  36.  
  37.     // ONLOOP() METHOD
  38.     @Override
  39.     public int onLoop()
  40.     {
  41.         itemsMade += 1;
  42.         return 0;
  43.     }
  44.    
  45.     //OUR PAINT METHOD
  46.     public void onPaint(Graphics g)
  47.     {
  48.         timeRan = System.currentTimeMillis() - timeBegan;
  49.         gpGained = itemsMade - costOfItem;
  50.         gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
  51.         totalGpPerHour = gpPerHour / 1000;
  52.         DecimalFormat df = new DecimalFormat("#");
  53.         g.drawString(ft(timeRan), 295, 349);
  54.         g.drawString("" + df.format(totalGpPerHour) + " k", 295, 417);
  55.     }
  56.    
  57.     private String ft(long duration)
  58.     {
  59.         String res = "";
  60.         long days = TimeUnit.MILLISECONDS.toDays(duration);
  61.         long hours = TimeUnit.MILLISECONDS.toHours(duration)
  62.         - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  63.         long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  64.         - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  65.         .toHours(duration));
  66.         long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  67.         - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  68.         .toMinutes(duration));
  69.         if (days == 0) {
  70.         res = (hours + ":" + minutes + ":" + seconds);
  71.         } else {
  72.         res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  73.         }
  74.         return res;
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement