Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.02 KB | None | 0 0
  1. package me.chicken.war;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8. import org.bukkit.scoreboard.DisplaySlot;
  9. import org.bukkit.scoreboard.Objective;
  10. import org.bukkit.scoreboard.Score;
  11.  
  12. import net.md_5.bungee.api.ChatColor;
  13.  
  14. public class Scoreboard {
  15.  
  16.     int LobbyScoreboard;
  17.     static int number = 50;
  18.     static int timer = 30;
  19.     static int PlayerNumberList;
  20.    
  21.     public static org.bukkit.scoreboard.Scoreboard scoreboardlobby = Bukkit.getScoreboardManager().getNewScoreboard();
  22.    
  23.     @SuppressWarnings("deprecation")
  24.     public static void SetLobby(Player player) {
  25.        
  26.         Bukkit.getScheduler().scheduleAsyncRepeatingTask(JavaPlugin.getPlugin(Main.class), new Runnable() {
  27.             @Override
  28.             public void run() {
  29.                 if(number == 50) {
  30.                 if(scoreboardlobby.getObjective("Lobby") == null) {
  31.                 scoreboardlobby.registerNewObjective("Lobby","dummy");
  32.                 }
  33.                 Objective lobbyobjective = scoreboardlobby.getObjective("Lobby");
  34.                 if(!lobbyobjective.getDisplayName().contains("Waiting")) {
  35.                 Score NothingD = lobbyobjective.getScore("§4");
  36.                 NothingD.setScore(15);
  37.                 lobbyobjective.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Waiting for Players");
  38.                 Score PlayerTag = lobbyobjective.getScore(ChatColor.GREEN + "" + ChatColor.BOLD + "Players:");
  39.                 PlayerTag.setScore(14);
  40.                 Score PlayerNumber = lobbyobjective.getScore(ChatColor.AQUA + "" + ChatColor.BOLD + Bukkit.getOnlinePlayers().size() + "/" + "20");
  41.                 PlayerNumber.setScore(13);
  42.                 PlayerNumberList = Bukkit.getOnlinePlayers().size();
  43.                 Score NothingA = lobbyobjective.getScore("§1");
  44.                 NothingA.setScore(12);
  45.                 Score ServerTag = lobbyobjective.getScore(ChatColor.GREEN + "" + ChatColor.BOLD + "Server:");
  46.                 ServerTag.setScore(11);
  47.                 Score ServerName = lobbyobjective.getScore(ChatColor.GOLD + "" + ChatColor.BOLD + Messages.ServerName(player));
  48.                 ServerName.setScore(10);
  49.                 Score NothingB = lobbyobjective.getScore("§2");
  50.                 NothingB.setScore(9);
  51.                 Score TeamTag = lobbyobjective.getScore(ChatColor.GREEN + "" + ChatColor.BOLD + "Team:");
  52.                 TeamTag.setScore(8);
  53.                 Score TeamName = lobbyobjective.getScore(ChatColor.GOLD + "" + ChatColor.BOLD + Bukkit.getScoreboardManager().getMainScoreboard().getPlayerTeam(player.getPlayer()).getPrefix());
  54.                 TeamName.setScore(7);
  55.                 Score NothingC = lobbyobjective.getScore("§3");
  56.                 NothingC.setScore(6);
  57.                 Score KitTag = lobbyobjective.getScore(ChatColor.GREEN + "" + ChatColor.BOLD + "Kit:");
  58.                 KitTag.setScore(5);
  59.                 Score KitName = lobbyobjective.getScore(ChatColor.BLUE + "" + ChatColor.BOLD + Kits.getKit(player));
  60.                 KitName.setScore(4);
  61.                 lobbyobjective.setDisplaySlot(DisplaySlot.SIDEBAR);
  62.                 player.setScoreboard(scoreboardlobby);
  63.                 if(PlayerNumberList > 1) {
  64.                     number--;
  65.                 }
  66.                         } else {
  67.                             if(PlayerNumberList != Bukkit.getOnlinePlayers().size()) {
  68.                             scoreboardlobby.resetScores(ChatColor.AQUA + "" + ChatColor.BOLD + PlayerNumberList + "/" + "20");
  69.                             Score PlayerNumber = lobbyobjective.getScore(ChatColor.AQUA + "" + ChatColor.BOLD + Bukkit.getOnlinePlayers().size() + "/" + "20");
  70.                             PlayerNumber.setScore(13);
  71.                             PlayerNumberList = Bukkit.getOnlinePlayers().size();
  72.                             }
  73.                         }
  74.                     } else {
  75.                         if(number == 49) {
  76.                             Objective lobbyobjective = scoreboardlobby.getObjective("Lobby");
  77.                         if(Config.getDataYaml.getInt("scoreboardtimer") == 0) {
  78.                             if(timer < 31) {
  79.                             Config.getDataYaml.set("scoreboardtimer", timer);
  80.                             try {
  81.                                 Config.getDataYaml.save(Config.getDataConfig);
  82.                             } catch (IOException e) {
  83.                                 e.printStackTrace();
  84.                             }
  85.                             if(timer > 4) {
  86.                             lobbyobjective.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + timer + " Seconds untill game starts!");
  87.                             } else {
  88.                                 lobbyobjective.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + timer + " Seconds untill game starts!");
  89.                             }
  90.                             timer--;
  91.                                 }
  92.                             }
  93.                         }
  94.                     }
  95.                 }
  96.             }, 0L, 20L);
  97.     }
  98.    
  99.    
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement