Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CountDownSystem {
- private SmilekrubServerMain plugin;
- public CountDownSystem(SmilekrubServerMain instance){
- plugin = instance;
- }
- public Timer countDownTask = null;
- public int countDownRemain = 0;
- public int countDownFrom = 0;
- public boolean firstCountDown = true;
- public String message="";
- public Runnable runLater = null;
- public byte delayChangeText;
- public boolean playSoundWhenEnd = true;
- public boolean showTimeUpMessage = true;
- public boolean cancelCountDown(){
- if(countDownTask == null) return false;
- for (Player player : Bukkit.getOnlinePlayers()) {
- if(BarAPI.hasBar(player)) {
- BarAPI.removeBar(player);
- }
- }
- countDownTask.cancel();
- countDownTask = null;
- countDownFrom = 0;
- countDownRemain = 0;
- runLater = null;
- return true;
- }
- public boolean startCountdown(String countdownquerystring){
- if(countDownTask != null) return false;
- int countdownsec=0;//get CountDown time
- if(countdownquerystring.equals("")) countdownsec = 10;
- else {
- countdownsec = SmilekrubFunction.convertStringToTime(countdownquerystring);
- }
- if(countdownsec == 0) return false;
- countDownRemain = countdownsec;
- countDownFrom = countdownsec;
- firstCountDown = true;
- countDownTask = new Timer();
- countDownTask.schedule(new CountDownTask(plugin), 0,1000);
- return true;
- }
- public boolean isCounting(){
- if(countDownTask != null) return true;
- else return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement