예제 #1
0
 private void resetScores(XLabel label) {
   for (XRemoveLabel remove : label.getToRemove()) {
     scoreboard.resetScores(remove.getLastValue());
     scoreboard.resetScores(remove.getValue());
     if (remove.getLastValue() != null
         && remove.getValue().length() > remove.getLastValue().length()) {
       int split = Math.round(remove.getValue().length() / 2) - 1;
       final String key = remove.getValue().substring(0, split);
       final String value = remove.getValue().substring(split, remove.getValue().length());
       scoreboard.resetScores(key);
       scoreboard.resetScores(value);
     } else if (remove.getLastValue() != null
         && remove.getValue().length() < remove.getLastValue().length()) {
       int split = Math.round(remove.getValue().length() / 2) + 1;
       final String key = remove.getValue().substring(0, split);
       final String value = remove.getValue().substring(split, remove.getValue().length());
       scoreboard.resetScores(key);
       scoreboard.resetScores(value);
     } else {
       int split = Math.round(remove.getValue().length() / 2);
       final String key = remove.getValue().substring(0, split);
       final String value = remove.getValue().substring(split, remove.getValue().length());
       scoreboard.resetScores(key);
       scoreboard.resetScores(value);
     }
   }
   label.getToRemove().clear();
 }
  public static boolean unrankedSidebarDisplay(
      Collection<Player> players, String[] elements, Scoreboard board) {
    try {
      String objName = "COLLAB-SB-WINTER";

      if (board == null) board = Bukkit.getScoreboardManager().getNewScoreboard();

      elements = cutUnranked(elements);

      for (Player player : players)
        if (player.getScoreboard() != board) player.setScoreboard(board);

      if (board.getObjective(objName) == null) {
        board.registerNewObjective(objName, "dummy");
        board.getObjective(objName).setDisplaySlot(DisplaySlot.SIDEBAR);
      }

      board.getObjective(DisplaySlot.SIDEBAR).setDisplayName(elements[0]);

      for (int i = 1; i < elements.length; i++)
        if (elements[i] != null
            && board.getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).getScore() != 16 - i) {
          board.getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).setScore(16 - i);
          for (String string : board.getEntries())
            if (board.getObjective(objName).getScore(string).getScore() == 16 - i)
              if (!string.equals(elements[i])) board.resetScores(string);
        }

      for (String entry : board.getEntries()) {
        boolean toErase = true;
        for (String element : elements) {
          if (element != null
              && element.equals(entry)
              && board.getObjective(objName).getScore(entry).getScore()
                  == 16 - Arrays.asList(elements).indexOf(element)) {
            toErase = false;
            break;
          }
        }

        if (toErase) board.resetScores(entry);
      }

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
예제 #3
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();
   }
 }
  public static boolean rankedSidebarDisplay(
      Collection<Player> players,
      String title,
      HashMap<String, Integer> elements,
      Scoreboard board) {
    try {
      title = cutRankedTitle(title);
      elements = cutRanked(elements);

      String objName = "COLLAB-SB-WINTER";

      if (board == null) board = Bukkit.getScoreboardManager().getNewScoreboard();

      for (Player player : players)
        if (player.getScoreboard() != board) player.setScoreboard(board);

      if (board.getObjective(objName) == null) {
        board.registerNewObjective(objName, "dummy");
        board.getObjective(objName).setDisplaySlot(DisplaySlot.SIDEBAR);
      }

      board.getObjective(DisplaySlot.SIDEBAR).setDisplayName(title);

      for (String string : elements.keySet())
        if (board.getObjective(DisplaySlot.SIDEBAR).getScore(string).getScore()
            != elements.get(string))
          board.getObjective(DisplaySlot.SIDEBAR).getScore(string).setScore(elements.get(string));

      for (String string : new ArrayList<>(board.getEntries()))
        if (!elements.keySet().contains(string)) board.resetScores(string);

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
예제 #5
0
 public static void hideBuilderVotingScoreboard(String exBuilder) {
   votingBoard.resetScores("§a" + exBuilder);
   votingBoard.getObjective(DisplaySlot.SIDEBAR).getScore("§a*****").setScore(3);
 }