Advertisement
Guest User

Paint Tutorial Example 1

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