SHARE
TWEET

Untitled

a guest Apr 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public abstract class Timer extends BukkitRunnable {
  2.  
  3.     protected double seconds = 5;
  4.     double step = 1;
  5.     boolean infinity = false;
  6.  
  7.     public Timer(double s, double step, int tick){
  8.         runTaskTimer(MMain.inst, tick, tick);
  9.         this.step = step;
  10.         seconds = s;
  11.         if(s == -1 && step == -1){
  12.             infinity = true;
  13.             return;
  14.         }
  15.     }
  16.  
  17.     @Override
  18.     public void run() {
  19.         onTick(seconds);
  20.         if(infinity)return;
  21.         if(seconds <= 1){
  22.             onEnd();
  23.             cancel();
  24.             return;
  25.         }
  26.         seconds = seconds-step;
  27.     }
  28.  
  29.     public abstract void onTick(double sec);
  30.     public abstract void onEnd();
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top