private List<String> getCurrentEntries() { List<String> list = new ArrayList<String>(); for (String entry : Bukkit.getScoreboardManager().getMainScoreboard().getEntries()) { list.add(entry); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; }
private List<String> getCurrentTeams() { List<String> list = new ArrayList<String>(); for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) { list.add(team.getName()); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; } }
private List<String> getCurrentObjectives() { List<String> list = new ArrayList<String>(); for (Objective objective : Bukkit.getScoreboardManager().getMainScoreboard().getObjectives()) { list.add(objective.getName()); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; }
final Scoreboard mainScoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
public static boolean isSupportedByServer() { return Bukkit.getScoreboardManager() != null; }
/** * Create a new scoreboard for the given arena. * @param arena an arena */ ScoreboardManager(Arena arena) { this.arena = arena; scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); scoreboards = new HashMap<>(); }
public SimpleScoreboard(String title) { this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); this.title = ChatColor.translateAlternateColorCodes('&', title); this.scores = new ConcurrentHashMap<>(); this.teams = Collections.synchronizedList(Lists.newArrayList()); this.removed = Lists.newArrayList(); this.updated = Collections.synchronizedSet(new HashSet<>()); }
private List<String> getCurrentEntries() { List<String> list = new ArrayList<String>(); for (String entry : Bukkit.getScoreboardManager().getMainScoreboard().getEntries()) { list.add(entry); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; }
private List<String> getCurrentTeams() { List<String> list = new ArrayList<String>(); for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) { list.add(team.getName()); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; } }
private List<String> getCurrentObjectives() { List<String> list = new ArrayList<String>(); for (Objective objective : Bukkit.getScoreboardManager().getMainScoreboard().getObjectives()) { list.add(objective.getName()); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; }
public Scoreboard getScoreboard() { if (scoreboard == null) { this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); this.player.setScoreboard(scoreboard); } return scoreboard; }
private void fill() { int required = Bukkit.getMaxPlayers() * 2; if (stack.size() < required) { ScoreboardManager sm = Bukkit.getScoreboardManager(); if (sm == null) { FunnyGuildsLogger.error("[ScoreboardStack] ScoreboardManager is null!"); return; } int loop = Bukkit.getMaxPlayers() * 2 - stack.size(); for (int i = 0; i < loop; i++) { stack.push(sm.getNewScoreboard()); } } } }
@Override public boolean isTarget(LivingEntity ent, String text) { try { if (text.startsWith("sbteam:") && ent instanceof Player) { String sbteamName = text.substring("sbteam:".length()); Team t = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(sbteamName); if (t != null) { if (t.hasEntry(((Player) ent).getName())) { return true; } } } } catch (Exception ex) { ex.printStackTrace(); } return false; } }
/** * Remove a player from the scoreboard by setting the player's scoreboard * to the main server scoreboard. * @param player a player */ void removePlayer(Player player) { try { Scoreboard scoreboard = scoreboards.remove(player); if (scoreboard != null) { player.setScoreboard(scoreboard); } else { player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); } } catch (IllegalStateException e) { // Happens if the player is logging out, just swallow it } }
/** * Get any scoreboard by world * - Note: players should use their associated-world (not current-world) */ private Scoreboard getScoreboard(UUID worldId, boolean isCreateIfNotFound) { Scoreboard scoreboard = null; if (ClimateEngine.getInstance().isClimateEngineEnabled(worldId)) { if (scoreboards.containsKey(worldId)) { //Existing scoreboard: scoreboard = scoreboards.get(worldId); } else if (isCreateIfNotFound) { //New scoreboard: scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); scoreboards.put(worldId, scoreboard); //Objective (scoreboard title / group): Objective objective = scoreboard.registerNewObjective( GLOBAL_WARMING, "dummy", "[TITLE]"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); } } return scoreboard; }
public static Scoreboard getScoreboardComputeIfAbsent(Player player) { Scoreboard scoreboard = player.getScoreboard(); if (scoreboard == null) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } return player.getScoreboard(); }
private FScoreboard(FPlayer fplayer) { this.fplayer = fplayer; if (isSupportedByServer()) { this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); this.bufferedObjective = new BufferedObjective(scoreboard); fplayer.getPlayer().setScoreboard(scoreboard); } else { this.scoreboard = null; this.bufferedObjective = null; } }
@Override public void run(String playerID) throws IllegalStateException, QuestRuntimeException { Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard(); Objective obj = board.getObjective(objective); if (obj == null) { throw new QuestRuntimeException("Scoreboard objective " + objective + " does not exist!"); } Score score = obj.getScore(PlayerConverter.getName(playerID)); if (multi) { score.setScore((int) Math.floor(score.getScore() * count.getDouble(playerID))); } else { score.setScore((int) Math.floor(score.getScore() + count.getDouble(playerID))); } }
@Override public boolean check(String playerID) throws QuestRuntimeException { Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard(); Objective obj = board.getObjective(objective); if (obj == null) { throw new QuestRuntimeException("Scoreboard objective " + objective + " does not exist!"); } Score score = obj.getScore(PlayerConverter.getName(playerID)); return score.getScore() >= count.getInt(playerID); }
protected void execute(Event event) { Player p = this.player.getSingle(event); String s = this.tag.getSingle(event); if (p == null || s == null) { return; } if (s.length() > 16) { Bukkit.getLogger().severe("String to edit tag name is too long! Max length is 16"); return; } Scoreboard sb = Bukkit.getScoreboardManager().getMainScoreboard(); Team team = sb.getPlayerTeam(p); if (team == null) { team = sb.getTeam(p.getName()); if (team == null) { team = sb.registerNewTeam(p.getName()); } team.addPlayer(p); } team.setPrefix(s); p.setScoreboard(sb); }