Advertisement
Guest User

Script Running Time - Pug Tutorials

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