Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Timer extends BukkitRunnable {
- protected double seconds = 5;
- double step = 1;
- boolean infinity = false;
- public Timer(double s, double step, int tick){
- runTaskTimer(MMain.inst, tick, tick);
- this.step = step;
- seconds = s;
- if(s == -1 && step == -1){
- infinity = true;
- return;
- }
- }
- @Override
- public void run() {
- onTick(seconds);
- if(infinity)return;
- if(seconds <= 1){
- onEnd();
- cancel();
- return;
- }
- seconds = seconds-step;
- }
- public abstract void onTick(double sec);
- public abstract void onEnd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement