Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. package me.nl.YourPalJake.ArcadeTag;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.plugin.Plugin;
  5. import org.bukkit.scheduler.BukkitRunnable;
  6. import org.bukkit.scheduler.BukkitScheduler;
  7.  
  8. public class Countdown{
  9.  
  10.  
  11. public boolean started = false;
  12. private int countdown = 10;
  13. private int task;
  14. private boolean was8 = false;
  15. private int online;
  16.  
  17. @SuppressWarnings("deprecation")
  18. public void startCountdown(Plugin p){
  19. BukkitScheduler scheduler = p.getServer().getScheduler();
  20. Integer id = scheduler.scheduleSyncRepeatingTask(p, new BukkitRunnable() {
  21. @Override
  22. public void run() {
  23. if(started == false) {
  24. online = Bukkit.getOnlinePlayers().size();
  25. if (online >= 8) {
  26. was8 = true;
  27. if (countdown == 10) {
  28. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §610 §7seconds!");
  29. }
  30. if (countdown == 5) {
  31. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §65 §7seconds!");
  32. }
  33.  
  34. if (countdown == 4) {
  35. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §64 §7seconds!");
  36. }
  37.  
  38. if (countdown == 3) {
  39. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §63 §7seconds!");
  40. }
  41.  
  42. if (countdown == 2) {
  43. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §62 §7seconds!");
  44. }
  45.  
  46. if (countdown == 1) {
  47. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7The game is starting in §61 §7seconds!");
  48. }
  49.  
  50. if (countdown == 0) {
  51. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7Game starting....");
  52. started = true;
  53. }
  54. countdown--;
  55. }else {
  56. if (was8 == true) {
  57. countdown = 10;
  58. p.getServer().broadcastMessage("§6§lArcadeTag §8» §7Not enough players stopping countdown!");
  59. was8 = false;
  60. }
  61.  
  62.  
  63. }
  64. }else {
  65. stopCountdown(p);
  66. //Start Tag game
  67.  
  68.  
  69. }
  70. }
  71. }, 0L, 20L);
  72. task = id;
  73. }
  74.  
  75.  
  76. private void stopCountdown(Plugin p){
  77. p.getServer().getScheduler().cancelTask(task);
  78. }
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement