示例#1
0
 public void updateLabel(XLabel label) {
   resetScores(label);
   if (label.isVisible()) {
     if (label.getValue().equals("")) {
       return;
     }
     if (label.getValue().equals("§a ")) {
       // Is a spacer label, no need to make a team and shit for it as teams
       // don't seem to like the name only being a space and color
       scoreboard
           .getObjective(DisplaySlot.SIDEBAR)
           .getScore(label.getValue())
           .setScore(label.getScore());
     } else {
       int split = Math.round(label.getValue().length() / 2);
       final String key = label.getValue().substring(0, split);
       if (key.equals("")) {
         return;
       }
       final String value = label.getValue().substring(split, label.getValue().length());
       scoreboard.getObjective(DisplaySlot.SIDEBAR).getScore(key).setScore(label.getScore());
       if (scoreboard.getEntries().toArray().length != 0) {
         Team team = this.scoreboard.getTeam(key);
         if (team == null) {
           team = this.scoreboard.registerNewTeam(key);
           team.addPlayer(new FakeOfflinePlayer(key));
         }
         team.setSuffix(value);
       }
     }
   }
   scores.put(label.getScore(), label);
   label.setUpdated(true);
 }
示例#2
0
 public void removeLabel(XLabel label) {
   resetScores(label);
   if (scores.containsKey(label.getScore())) {
     scores.remove(label.getScore());
   }
   int split = Math.round(label.getValue().length() / 2);
   final String key = label.getValue().substring(0, split);
   final String value = label.getValue().substring(split, label.getValue().length());
   scoreboard.resetScores(key);
   scoreboard.resetScores(value);
   Team team = scoreboard.getTeam(key);
   if (team != null) {
     team.unregister();
   }
 }
示例#3
0
 public void addLabel(XLabel label) {
   addScore(label.getScore(), label);
   label.setUpdated(false);
   label.update();
 }