Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics2D;
- import java.util.concurrent.TimeUnit;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- @ScriptManifest(name="ExampleScript", author="author", info="1.0", logo="", version=1.0D)
- public final class paintScript
- extends Script
- {
- // PAINT VARIABLE DECLARATIONS
- private long timeBegan;
- private long timeRan;
- // ONSTART() METHOD
- public final void onStart()
- {
- timeBegan = System.currentTimeMillis();
- }
- // ONLOOP() METHOD
- @Override
- public int onLoop() throws InterruptedException
- {
- return 123;
- }
- // ONPAINT() METHOD
- public void onPaint(Graphics2D g)
- {
- Graphics2D gr = g;
- timeRan = System.currentTimeMillis() - this.timeBegan;
- g.drawString(ft(timeRan), 1, 1);
- }
- // FORMAT TIME METHOD
- private String ft(long duration)
- {
- String res = "";
- long days = TimeUnit.MILLISECONDS.toDays(duration);
- long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
- long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
- if (days == 0)
- {
- res = (hours + ":" + minutes + ":" + seconds);
- }
- else
- {
- res = (days + ":" + hours + ":" + minutes + ":" + seconds);
- }
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement