Advertisement
Guest User

Untitled

a guest
Mar 31st, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. //id make this an instance variable, as youd want every player on the same scoreboard to see the teams.
  2. Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
  3. //use the dummy criteria
  4. Objective objective = scoreboard.registerNewObjective("Name", "dummy");
  5. // set the the sidebar, you dont need this if you dotn want to display scores on the right of their screen.
  6. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
  7.  
  8. //time to add scores
  9. //Use the scores to position your entries, makes stuff nicer, you also have a 40 char limit if you go this route
  10. //otherwise you can use Teams, and use 16 * 3 (prefix, name, suffix) to get a total of 48 chars.
  11. objective.getScore("Team A Kills: 10").setScore(7);
  12. //This here, will create a blank line. Scores must be unique so i use different chat colors.
  13. objective.getScore(ChatColor.GREEN.toString()).setScore(6);
  14. objective.getScore("Team B Kills: 5").setScore(5);
  15. objective.getScore(ChatColor.BLUE.toString()).setScore(4);
  16. objective.getScore("Team C Kills: 3").setScore(3);
  17. objective.getScore(ChatColor.RED.toString()).setScore(2);
  18. objective.getScore("Team D Kills: 1").setScore(1);
  19.  
  20. //Create a team
  21. Team teamA = scoreboard.registerNewTeam("Team_A");
  22. //here is where we can set the tags, you dont need text an empty chatcolor will work.
  23. teamA.setPrefix(ChatColor.RED + "[Sweg]" + ChatColor.RESET);
  24.  
  25. //add the player to the team, make sure to remove upon leave and re-add upon join to eliminate problems with name changes.
  26. teamA.addEntry(player.getName());
  27.  
  28. //lastly set them to the board.
  29. player.setScoreboard(scoreboard);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement