Advertisement
Guest User

Untitled

a guest
Jan 4th, 2014
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package craftedevil.plugin;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.player.PlayerJoinEvent;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9. import org.bukkit.scheduler.BukkitRunnable;
  10.  
  11. public class PlayerCountDown extends JavaPlugin implements Listener {
  12.  
  13. int countdown = 10;
  14. int id;
  15.  
  16. @EventHandler
  17. public void onJoin(PlayerJoinEvent event){
  18. switch(Bukkit.getServer().getOnlinePlayers().length){
  19. case 1: getServer().broadcastMessage(ChatColor.GREEN + "Started");
  20. id = getServer().getScheduler().scheduleSyncRepeatingTask(this, new BukkitRunnable() {
  21. @Override
  22. public void run() {
  23. getServer().broadcastMessage(ChatColor.GOLD + "Time: " + countdown);
  24. if(countdown == 0) {
  25. Bukkit.getScheduler().cancelTask(id);
  26. }
  27. countdown--;
  28. }
  29. }, 0L, 20L);
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement