Guest User

Untitled

a guest
Feb 16th, 2016
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Board {
  2.  
  3. private final Scoreboard scoreboard;
  4. private final Objective objective;
  5.  
  6. public Board() {
  7. this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
  8. this.objective = scoreboard.registerNewObjective("Board", "dummy");
  9.  
  10. this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
  11. }
  12.  
  13. public Board(Player player) {
  14. this.scoreboard = player.getScoreboard();
  15. this.objective = scoreboard.getObjective(DisplaySlot.SIDEBAR);
  16. }
  17.  
  18. public Scoreboard getScoreboard() {
  19. return scoreboard;
  20. }
  21.  
  22. public String getTitle() {
  23. return objective.getDisplayName();
  24. }
  25.  
  26. public void setTitle(String name) {
  27. this.objective.setDisplayName(name);
  28. }
  29.  
  30. public void set(int row, String text) {
  31. if(text.length() > 32) { text = text.substring(0, 32); }
  32.  
  33. for(String entry : this.scoreboard.getEntries()) {
  34. if(this.objective.getScore(entry).getScore() == row) {
  35. this.scoreboard.resetScores(entry);
  36. break;
  37. }
  38. }
  39.  
  40. this.objective.getScore(text).setScore(row);
  41. }
  42.  
  43. public void remove(int row) {
  44. for(String entry : this.scoreboard.getEntries()) {
  45. if(this.objective.getScore(entry).getScore() == row) {
  46. this.scoreboard.resetScores(entry);
  47. break;
  48. }
  49. }
  50. }
  51. }
RAW Paste Data