Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.nl.YourPalJake.ArcadeTag;
- import org.bukkit.Bukkit;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitScheduler;
- public class Countdown{
- public boolean started = false;
- private int countdown = 10;
- private int task;
- private boolean was8 = false;
- private int online;
- @SuppressWarnings("deprecation")
- public void startCountdown(Plugin p){
- BukkitScheduler scheduler = p.getServer().getScheduler();
- Integer id = scheduler.scheduleSyncRepeatingTask(p, new BukkitRunnable() {
- @Override
- public void run() {
- if(started == false) {
- online = Bukkit.getOnlinePlayers().size();
- if (online >= 8) {
- was8 = true;
- if (countdown == 10) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §610 §7seconds!");
- }
- if (countdown == 5) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §65 §7seconds!");
- }
- if (countdown == 4) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §64 §7seconds!");
- }
- if (countdown == 3) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §63 §7seconds!");
- }
- if (countdown == 2) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §62 §7seconds!");
- }
- if (countdown == 1) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §61 §7seconds!");
- }
- if (countdown == 0) {
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7Game starting....");
- started = true;
- }
- countdown--;
- }else {
- if (was8 == true) {
- countdown = 10;
- p.getServer().broadcastMessage("§6§lArcadeTag §8» §7Not enough players stopping countdown!");
- was8 = false;
- }
- }
- }else {
- stopCountdown(p);
- //Start Tag game
- }
- }
- }, 0L, 20L);
- task = id;
- }
- private void stopCountdown(Plugin p){
- p.getServer().getScheduler().cancelTask(task);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement