Advertisement
Guest User

Time Till Next Level - Pug Tutorials

a guest
Aug 29th, 2014
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.02 KB | None | 0 0
  1. import java.awt.Graphics2D;
  2. import java.util.concurrent.TimeUnit;
  3.  
  4. import org.osbot.rs07.api.ui.Skill;
  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 timeBegan;
  16.     private int xpGained;
  17.     private int xpPerHour;
  18.     private int currentXp;
  19.     private int currentLevel;
  20.     private int beginningXp;
  21.     private double nextLevelXp;
  22.     private long timeTNL;
  23.     private double xpTillNextLevel;
  24.    
  25.       final int[] XP_TABLE =
  26.           {
  27.               0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154,
  28.               1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018,
  29.               5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833,
  30.               16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224,
  31.               41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721,
  32.               101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254,
  33.               224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428,
  34.               496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895,
  35.               1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068,
  36.               2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294,
  37.               4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614,
  38.               8771558, 9684577, 10692629, 11805606, 13034431, 200000000
  39.           };
  40.    
  41.     // ONSTART() METHOD
  42.     public final void onStart()
  43.     {
  44.         timeBegan = System.currentTimeMillis();
  45.         beginningXp = skills.getExperience(Skill.RUNECRAFTING);
  46.         timeTNL = 0;
  47.     }
  48.    
  49.     // ONLOOP() METHOD
  50.     @Override
  51.     public int onLoop() throws InterruptedException
  52.     {
  53.        
  54.         return 123;
  55.     }
  56.    
  57.     // ONPAINT() METHOD
  58.     public void onPaint(Graphics2D g)
  59.       {
  60.         currentXp = skills.getExperience(Skill.RUNECRAFTING);
  61.         currentLevel = skills.getStatic(Skill.RUNECRAFTING);
  62.         xpGained = currentXp - beginningXp;
  63.         xpPerHour = (int)( xpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
  64.         nextLevelXp = XP_TABLE[currentLevel + 1];
  65.         xpTillNextLevel = nextLevelXp - currentXp;
  66.         if (xpGained >= 1)
  67.         {
  68.             timeTNL = (long) ((xpTillNextLevel / xpPerHour) * 3600000);
  69.         }
  70.          
  71.         g.drawString("" + ft(timeTNL), 400, 442);  
  72.       }
  73.    
  74.     private String ft(long duration)
  75.     {
  76.         String res = "";
  77.         long days = TimeUnit.MILLISECONDS.toDays(duration);
  78.         long hours = TimeUnit.MILLISECONDS.toHours(duration)
  79.         - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  80.         long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  81.         - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  82.         .toHours(duration));
  83.         long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  84.         - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  85.         .toMinutes(duration));
  86.         if (days == 0) {
  87.         res = (hours + ":" + minutes + ":" + seconds);
  88.         } else {
  89.         res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  90.         }
  91.         return res;
  92.     }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement