Package org.bukkit.scoreboard

Examples of org.bukkit.scoreboard.Score


    /**
     * Add a kill to the player's score. Called when a player kills a mob.
     * @param player a player
     */
    void addKill(Player player) {
        Score score = kills.getScore(player);
        score.setScore(score.getScore() + 1);
    }
View Full Code Here


         * scoreboard unless they are first given a different score.
         * If zero kills, the score is set to 8 (which looks a bit like
         * 0), and then in the next tick, it's set to 0. Otherwise, the
         * score is just set to its current value.
         */
        final Score fake = kills.getScore(Bukkit.getOfflinePlayer(name));
        if (value == 0) {
            fake.setScore(8);
            arena.scheduleTask(new Runnable() {
                public void run() {
                    fake.setScore(0);
                }
            }, 1);
        } else {
            fake.setScore(value);
        }
    }
View Full Code Here

                if (targetSkill.getAbility() != null) {
                    boolean stopUpdating;

                    if (targetSkill == SkillType.MINING) {
                        // Special-Case: Mining has two abilities, both with cooldowns
                        Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
                        Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
                        int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.SUPER_BREAKER), 0);
                        int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING), 0);

                        cooldownSB.setScore(secondsSB);
                        cooldownBM.setScore(secondsBM);

                        stopUpdating = (secondsSB == 0 && secondsBM == 0);
                    }
                    else {
                        AbilityType ability = targetSkill.getAbility();
                        Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
                        int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);

                        cooldown.setScore(seconds);

                        stopUpdating = seconds == 0;
                    }

                    if (stopUpdating) {
View Full Code Here

                String playerName = args[2];
                if (playerName.length() > 16) {
                    sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
                    return false;
                }
                Score score = objective.getScore(playerName);
                int newScore;
                if (args[1].equalsIgnoreCase("set")) {
                    newScore = value;
                } else if (args[1].equalsIgnoreCase("add")) {
                    newScore = score.getScore() + value;
                } else {
                    newScore = score.getScore() - value;
                }
                score.setScore(newScore);
                sender.sendMessage("Set score of " + objectiveName + " for player " + playerName + " to " + newScore);
            } else if (args[1].equalsIgnoreCase("reset")) {
                if (args.length != 3) {
                    sender.sendMessage(ChatColor.RED + "/scoreboard players reset <player>");
                    return false;
                }
                String playerName = args[2];
                if (playerName.length() > 16) {
                    sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
                    return false;
                }
                mainScoreboard.resetScores(playerName);
                sender.sendMessage("Reset all scores of player " + playerName);
            } else if (args[1].equalsIgnoreCase("list")) {
                if (args.length > 3) {
                    sender.sendMessage(ChatColor.RED + "/scoreboard players list <player>");
                    return false;
                }
                if (args.length == 2) {
                    Set<String> entries = mainScoreboard.getEntries();
                    if (entries.isEmpty()) {
                        sender.sendMessage(ChatColor.RED + "There are no tracked players on the scoreboard");
                    } else {
                        sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + entries.size() + " tracked players on the scoreboard");
                        sender.sendMessage(stringCollectionToString(entries));
                    }
                } else {
                    String playerName = args[2];
                    if (playerName.length() > 16) {
                        sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
                        return false;
                    }
                    Set<Score> scores = mainScoreboard.getScores(playerName);
                    if (scores.isEmpty()) {
                        sender.sendMessage(ChatColor.RED + "Player " + playerName + " has no scores recorded");
                    } else {
                        sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + scores.size() + " tracked objective(s) for " + playerName);
                        for (Score score : scores) {
                            sender.sendMessage("- " + score.getObjective().getDisplayName() + ": " + score.getScore() + " (" + score.getObjective().getName() + ")");
                        }
                    }
                }
            }
        } else if (args[0].equalsIgnoreCase("teams")) {
View Full Code Here

        String playerName = args[2];
        if (playerName.length() > 16) {
          sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
          return false;
        }
        Score score = objective.getScore(Bukkit.getOfflinePlayer(playerName));
        int newScore;
        if (args[1].equalsIgnoreCase("set")) {
          newScore = value;
        } else if (args[1].equalsIgnoreCase("add")) {
          newScore = score.getScore() + value;
        } else {
          newScore = score.getScore() - value;
        }
        score.setScore(newScore);
        sender.sendMessage("Set score of " + objectiveName + " for player " + playerName + " to " + newScore);
      } else if (args[1].equalsIgnoreCase("reset")) {
        if (args.length != 3) {
          sender.sendMessage(ChatColor.RED + "/scoreboard players reset <player>");
          return false;
        }
        String playerName = args[2];
        if (playerName.length() > 16) {
          sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
          return false;
        }
        scoreboard.resetScores(Bukkit.getOfflinePlayer(playerName));
        sender.sendMessage("Reset all scores of player " + playerName);
      } else if (args[1].equalsIgnoreCase("list")) {
        if (args.length > 3) {
          sender.sendMessage(ChatColor.RED + "/scoreboard players list <player>");
          return false;
        }
        if (args.length == 2) {
          Set<OfflinePlayer> players = scoreboard.getPlayers();
          if (players.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "There are no tracked players on the scoreboard");
          } else {
            sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + players.size() + " tracked players on the scoreboard");
            sender.sendMessage(offlinePlayerSetToString(players));
          }
        } else {
          String playerName = args[2];
          if (playerName.length() > 16) {
            sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name");
            return false;
          }
          Set<Score> scores = scoreboard.getScores(Bukkit.getOfflinePlayer(playerName));
          if (scores.isEmpty()) {
            sender.sendMessage(ChatColor.RED + "Player " + playerName + " has no scores recorded");
          } else {
            sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + scores.size() + " tracked objective(s) for " + playerName);
            for (Score score : scores) {
              sender.sendMessage("- " + score.getObjective().getDisplayName() + ": " + score.getScore() + " (" + score.getObjective().getName() + ")");
            }
          }
        }
      }
    } else if (args[0].equalsIgnoreCase("teams")) {
View Full Code Here

TOP

Related Classes of org.bukkit.scoreboard.Score

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.