Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CountDownTask extends TimerTask{
- private SmilekrubServerMain plugin;
- public CountDownTask(SmilekrubServerMain instance){
- plugin = instance;
- }
- @Override
- public void run() {
- CountDownSystem clock = plugin.getSmilekrub().getCountDown();
- float timeleftpercent = SmilekrubFunction.GetPerCentFromTime(clock.countDownRemain, clock.countDownFrom);
- int left = clock.countDownRemain;
- if(left > 10 && clock.delayChangeText > 0 && !clock.message.equals("")){
- for (Player player : Bukkit.getOnlinePlayers()) {
- BarAPI.setMessage(player, ChatColor.AQUA+"[Countdown] : "+ChatColor.WHITE+ChatColor.BOLD+clock.message, timeleftpercent);
- }
- }
- else if(left > 0) {
- ChatColor chatcolor = null;
- if(left > 20) chatcolor = ChatColor.AQUA;
- else if(left > 10) chatcolor = ChatColor.GREEN;
- else if(left > 3) chatcolor = ChatColor.YELLOW;
- else chatcolor = ChatColor.GOLD;
- Player[] players = plugin.getServer().getOnlinePlayers();
- for (Player player : players) {
- BarAPI.setMessage(player, chatcolor+"[Countdown] : "+ChatColor.BOLD+SmilekrubFunction.getTimeAsString(left)+" left!", timeleftpercent);
- if(left <= 5){
- player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, (float) (left*0.3));
- }
- }
- }
- else if(left == 0)
- {
- if(clock.playSoundWhenEnd){
- Sound[] soundrand = {Sound.CHICKEN_HURT, Sound.ANVIL_LAND, Sound.WOLF_BARK, Sound.BURP, Sound.CAT_MEOW, Sound.EXPLODE, Sound.CREEPER_HISS, Sound.ENDERDRAGON_HIT, Sound.BLAZE_HIT, Sound.ENDERMAN_TELEPORT, Sound.GHAST_DEATH, Sound.GHAST_SCREAM, Sound.GHAST_SCREAM2,Sound.FALL_BIG, Sound.ZOMBIE_PIG_DEATH};
- Sound selectsound = soundrand[SmilekrubFunction.randInt(0, soundrand.length-1)];
- for (Player player : Bukkit.getOnlinePlayers()) {
- player.playSound(player.getLocation(), selectsound, 5, 1);
- }
- }
- if(clock.showTimeUpMessage){
- plugin.getSmilekrub().getLogblock().lbconsumer.getConsumer().queueChat("Server", "[Countdown] : Time's Up! (^^)");
- Bukkit.broadcastMessage(ChatColor.GREEN+"[Countdown] : "+ChatColor.BOLD+"Time's Up! (^^)");
- for (Player player : Bukkit.getOnlinePlayers()) {
- if(BarAPI.hasBar(player)) {
- BarAPI.setMessage(player, ChatColor.GREEN+"[Countdown] : "+ChatColor.BOLD+"Time's Up! (^^)", (float) 0.0);
- }
- }
- }
- if(clock.runLater != null){
- clock.runLater.run();
- clock.runLater = null;
- }
- }
- else if(left < 0)
- {
- for (Player player : Bukkit.getOnlinePlayers()) {
- if(BarAPI.hasBar(player)) {
- BarAPI.removeBar(player);
- }
- }
- clock.countDownTask.cancel();
- clock.countDownTask = null;
- clock.countDownFrom = 0;
- clock.countDownRemain = 0;
- clock.message = "";
- clock.playSoundWhenEnd = true;
- clock.showTimeUpMessage = true;
- return;
- }
- if(left > 1 && (((left < 10) || (left%5) == 0) && left < 60) || (left%30) == 0 || clock.firstCountDown == true){
- String havemessage="";
- if(!clock.message.equals("")) havemessage = "; "+clock.message;
- plugin.getSmilekrub().getLogblock().lbconsumer.getConsumer().queueChat("Server", "[Countdown] : "+SmilekrubFunction.getTimeAsString(left)+" left!"+ChatColor.stripColor(havemessage));
- plugin.getSmilekrub().getCountDown();
- clock.firstCountDown = false;
- }
- if(clock.delayChangeText <= -5) clock.delayChangeText = 5;
- else --clock.delayChangeText;
- --clock.countDownRemain;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement