Advertisement
Guest User

Calculations of Profits/Hr - Pug Tutorials

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