Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1.  
  2. /**
  3.  *
  4.  * @author Vilius
  5.  *
  6.  */
  7. public class Scheduler extends TaskScriptEmulator<TaskScript> {
  8.  
  9.     private Calendar date;
  10.     static long midnight;
  11.     private int rotationTick;
  12.  
  13.     public Scheduler() {
  14.         date = new GregorianCalendar(TimeZone.getTimeZone("Etc/GMT+0"));
  15.         date.set(Calendar.HOUR_OF_DAY, 0);
  16.         date.set(Calendar.MINUTE, 0);
  17.         date.set(Calendar.SECOND, 0);
  18.         date.set(Calendar.MILLISECOND, 0);
  19.         midnight = date.getTime().getTime();
  20.     }
  21.  
  22.     public static int getCurrentTick() {
  23.         return (int) Math.floor((System.currentTimeMillis() - midnight) / 300000);
  24.     }
  25.  
  26.     public enum FarmingTick {
  27.         ALLOTMENT(2), HERB(4), TREE(8), FRUIT_TREE(32);
  28.         int tick;
  29.  
  30.         FarmingTick(int tick) {
  31.             this.tick = tick;
  32.         }
  33.  
  34.         public int getTickMultiplier() {
  35.             return tick;
  36.         }
  37.  
  38.         public int getMinutesOf(FarmingTick farmingTick) {
  39.             return farmingTick.getTickMultiplier() * 5;
  40.         }
  41.  
  42.         public int getTick() {
  43.             return (int) Math.floor(getCurrentTick() / tick);
  44.         }
  45.     }
  46.  
  47.     public void setRotation(FarmingTick tick) {
  48.         rotationTick = tick.getTick();
  49.     }
  50.  
  51.     public int getCurrentRotationTick() {
  52.         return rotationTick;
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement