Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement