Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ArrayList<String> Varo = new ArrayList<>();
- ArrayList<Player> noDamage = new ArrayList<Player>();
- ArrayList<Player> notMoving = new ArrayList<Player>();
- private Main plugin;
- int scheduler = 0;
- int scheduler1 = 0;
- int count = 60;
- int maxCount = 60;
- int damage = 36000;
- public StartCommand(Main main) {
- this.plugin = main;
- }
- @EventHandler
- public boolean onCommand(CommandSender CommandSender, Command Command, String Label, String[] Args) {
- if(Command.getName().equalsIgnoreCase("start")) {
- final Player p = (Player) CommandSender;
- p.sendMessage("§6Du hast den Countdown gestartet");
- onCountdown();
- return true;
- }
- return false;
- }
- @SuppressWarnings("deprecation")
- public void onCountdown() {
- for(Player p : Bukkit.getOnlinePlayers()){
- notMoving.add(p);
- noDamage.add(p);
- }
- this.scheduler = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- public void run() {
- if(count == 60 ||
- count == 50 ||
- count == 40 ||
- count == 30 ||
- count == 20 ||
- count == 15 ||
- count == 10 ||
- count == 9 ||
- count == 8 ||
- count == 7 ||
- count == 6 ||
- count == 5 ||
- count == 4 ||
- count == 3 ||
- count == 2 ||
- count == 1 ){
- Bukkit.broadcastMessage(plugin.prefix + "§3Die Spiele beginnen in §e" + count + "§3 " + (count == 1 ? "Sekunde" : "Sekunden"));
- }
- if(count <= 60){
- for(Player p : Bukkit.getOnlinePlayers()){
- p.setLevel(count);
- p.setExp((float)count / (float)maxCount);
- }
- }
- if(count <= 0){
- notMoving.clear();
- Bukkit.broadcastMessage("§aMögen die Spiele beginnen");
- onGreacePeriod();
- Bukkit.getScheduler().cancelTask(scheduler);
- for(Player p : Bukkit.getOnlinePlayers()){
- p.setLevel(0);
- p.setExp(0);
- }
- }
- count --;
- }
- }
- , 0L, 20L);
- }
- public void onGreacePeriod(){
- this.scheduler1 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- public void run() {
- if(damage == 0){
- noDamage.clear();
- Bukkit.getScheduler().cancelTask(scheduler1);
- }
- damage --;
- }
- }, 0L, 20L);
- }
- @EventHandler
- public void onDamage(EntityDamageEvent e) {
- if(noDamage.contains(e.getEntity())) {
- e.setCancelled(true);
- }
- }
- @EventHandler
- public void onPlayerJump(PlayerMoveEvent e) {
- if(notMoving.contains(e.getPlayer()))
- e.getPlayer().teleport(e.getPlayer().getLocation());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement