Advertisement
Guest User

Untitled

a guest
Apr 30th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. public class CountDownSystem {
  2.        
  3.         private SmilekrubServerMain plugin;
  4.         public CountDownSystem(SmilekrubServerMain instance){
  5.                 plugin = instance;
  6.         }
  7.        
  8.         public Timer countDownTask = null;
  9.         public int countDownRemain = 0;
  10.         public int countDownFrom = 0;
  11.         public boolean firstCountDown = true;
  12.         public String message="";
  13.         public Runnable runLater = null;
  14.         public byte delayChangeText;
  15.         public boolean playSoundWhenEnd = true;
  16.         public boolean showTimeUpMessage = true;
  17.         public boolean cancelCountDown(){
  18.                 if(countDownTask == null) return false;
  19.                 for (Player player : Bukkit.getOnlinePlayers()) {
  20.                         if(BarAPI.hasBar(player)) {
  21.                                 BarAPI.removeBar(player);
  22.                         }
  23.                 }
  24.                 countDownTask.cancel();
  25.                 countDownTask = null;
  26.                 countDownFrom = 0;
  27.                 countDownRemain = 0;
  28.                 runLater = null;
  29.                 return true;
  30.         }
  31.        
  32.         public boolean startCountdown(String countdownquerystring){
  33.                 if(countDownTask != null) return false;
  34.                 int countdownsec=0;//get CountDown time
  35.                 if(countdownquerystring.equals("")) countdownsec = 10;
  36.                 else {
  37.                         countdownsec = SmilekrubFunction.convertStringToTime(countdownquerystring);
  38.                 }
  39.                 if(countdownsec == 0) return false;
  40.                
  41.                 countDownRemain = countdownsec;
  42.                 countDownFrom = countdownsec;
  43.                 firstCountDown = true;
  44.                
  45.                 countDownTask = new Timer();
  46.                 countDownTask.schedule(new CountDownTask(plugin), 0,1000);
  47.                 return true;
  48.         }
  49.        
  50.         public boolean isCounting(){
  51.                 if(countDownTask != null) return true;
  52.                 else return false;
  53.         }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement