Java Code Examples for org.bukkit.scoreboard.Objective#getScore()
The following examples show how to use
org.bukkit.scoreboard.Objective#getScore() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Game.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
public void updateScoreboard() { if (!getOriginalOrInheritedScoreaboard()) { return; } Objective obj = this.gameScoreboard.getObjective("display"); if (obj == null) { obj = this.gameScoreboard.registerNewObjective("display", "dummy"); } obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatScoreboardTitle()); for (CurrentTeam team : teamsInGame) { this.gameScoreboard.resetScores(this.formatScoreboardTeam(team, false, false)); this.gameScoreboard.resetScores(this.formatScoreboardTeam(team, false, true)); this.gameScoreboard.resetScores(this.formatScoreboardTeam(team, true, false)); Score score = obj.getScore(this.formatScoreboardTeam(team, !team.isBed, team.isBed && "RESPAWN_ANCHOR".equals(team.teamInfo.bed.getBlock().getType().name()) && Player116ListenerUtils.isAnchorEmpty(team.teamInfo.bed.getBlock()))); score.setScore(team.players.size()); } for (GamePlayer player : players) { player.player.setScoreboard(gameScoreboard); } }
Example 2
Source File: Game.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
public void updateScoreboard() { if (!getOriginalOrInheritedScoreaboard()) { return; } Objective obj = this.gameScoreboard.getObjective("display"); if (obj == null) { obj = this.gameScoreboard.registerNewObjective("display", "dummy"); } obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatScoreboardTitle()); for (CurrentTeam team : teamsInGame) { this.gameScoreboard.resetScores(this.formatScoreboardTeam(team, false, false)); this.gameScoreboard.resetScores(this.formatScoreboardTeam(team, false, true)); this.gameScoreboard.resetScores(this.formatScoreboardTeam(team, true, false)); Score score = obj.getScore(this.formatScoreboardTeam(team, !team.isBed, team.isBed && "RESPAWN_ANCHOR".equals(team.teamInfo.bed.getBlock().getType().name()) && Player116ListenerUtils.isAnchorEmpty(team.teamInfo.bed.getBlock()))); score.setScore(team.players.size()); } for (GamePlayer player : players) { player.player.setScoreboard(gameScoreboard); } }
Example 3
Source File: Arena.java From civcraft with GNU General Public License v2.0 | 6 votes |
public void decrementTimer() { if (timeleft <= 0) { if (!ended) { CivMessage.sendArena(this, "Time is up! Nobody Wins!"); ArenaManager.declareDraw(this); ended = true; } } else { this.timeleft--; for (ArenaTeam team : this.teams.values()) { Objective obj = objectives.get(team.getName()+";score"); Score score = obj.getScore("Time Left"); score.setScore(timeleft); } } }
Example 4
Source File: EffSetScore.java From skRayFall with GNU General Public License v3.0 | 6 votes |
@Override protected void execute(Event evt) { if (player == null || num == null || player.getSingle(evt).getScoreboard() == null) { Skript.error("This player is either not online or has yet to have a scoreboard set for them"); return; } Scoreboard sb = player.getSingle(evt).getScoreboard(); Objective objective = sb.getObjective(DisplaySlot.SIDEBAR); Score score; if (name.getSingle(evt) == null){ Skript.warning("First arg in \"set score %string% in sidebar of %player% to %number%\" was null. " + "Objective will now be named null."); score = objective.getScore("null"); } else { score = objective.getScore(name.getSingle(evt).replace("\"", "")); } score.setScore(num.getSingle(evt).intValue()); }
Example 5
Source File: Game.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
private void updateLobbyScoreboard() { if (status != GameStatus.WAITING || !getOriginalOrInheritedLobbyScoreaboard()) { return; } gameScoreboard.clearSlot(DisplaySlot.SIDEBAR); Objective obj = gameScoreboard.getObjective("lobby"); if (obj != null) { obj.unregister(); } obj = gameScoreboard.registerNewObjective("lobby", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatLobbyScoreboardString( Main.getConfigurator().config.getString("lobby-scoreboard.title", "§eBEDWARS"))); List<String> rows = Main.getConfigurator().config.getStringList("lobby-scoreboard.content"); int rowMax = rows.size(); if (rows == null || rows.isEmpty()) { return; } for (String row : rows) { if (row.trim().equals("")) { for (int i = 0; i <= rowMax; i++) { row = row + " "; } } Score score = obj.getScore(this.formatLobbyScoreboardString(row)); score.setScore(rowMax); rowMax--; } for (GamePlayer player : players) { player.player.setScoreboard(gameScoreboard); } }
Example 6
Source File: Game.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
private void updateLobbyScoreboard() { if (status != GameStatus.WAITING || !getOriginalOrInheritedLobbyScoreaboard()) { return; } gameScoreboard.clearSlot(DisplaySlot.SIDEBAR); Objective obj = gameScoreboard.getObjective("lobby"); if (obj != null) { obj.unregister(); } obj = gameScoreboard.registerNewObjective("lobby", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatLobbyScoreboardString( Main.getConfigurator().config.getString("lobby-scoreboard.title", "§eBEDWARS"))); List<String> rows = Main.getConfigurator().config.getStringList("lobby-scoreboard.content"); int rowMax = rows.size(); if (rows == null || rows.isEmpty()) { return; } for (String row : rows) { if (row.trim().equals("")) { for (int i = 0; i <= rowMax; i++) { row = row + " "; } } Score score = obj.getScore(this.formatLobbyScoreboardString(row)); score.setScore(rowMax); rowMax--; } for (GamePlayer player : players) { player.player.setScoreboard(gameScoreboard); } }
Example 7
Source File: Game.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public void Scoreboard(Player player) { ScoreboardManager manager = Bukkit.getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); Objective objective = board.registerNewObjective("test", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName("Scoreboard"); objective.getName(); Score score = objective.getScore(ChatColor.GREEN + "Kills:"); //Get a fake offline player score.setScore(1); }
Example 8
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
private void updateLobbyScoreboard() { this.scoreboard.clearSlot(DisplaySlot.SIDEBAR); Objective obj = this.scoreboard.getObjective("lobby"); if (obj != null) { obj.unregister(); } obj = this.scoreboard.registerNewObjective("lobby", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatLobbyScoreboardString( BedwarsRel.getInstance().getStringConfig("lobby-scoreboard.title", "&eBEDWARS"))); List<String> rows = BedwarsRel.getInstance().getConfig() .getStringList("lobby-scoreboard.content"); int rowMax = rows.size(); if (rows == null || rows.isEmpty()) { return; } for (String row : rows) { if (row.trim().equals("")) { for (int i = 0; i <= rowMax; i++) { row = row + " "; } } Score score = obj.getScore(this.formatLobbyScoreboardString(row)); score.setScore(rowMax); rowMax--; } for (Player player : this.getPlayers()) { player.setScoreboard(this.scoreboard); } }
Example 9
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public void updateScoreboard() { if (this.state == GameState.WAITING && BedwarsRel.getInstance().getBooleanConfig("lobby-scoreboard.enabled", true)) { this.updateLobbyScoreboard(); return; } Objective obj = this.scoreboard.getObjective("display"); if (obj == null) { obj = this.scoreboard.registerNewObjective("display", "dummy"); } obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(this.formatScoreboardTitle()); for (Team t : this.teams.values()) { this.scoreboard.resetScores(this.formatScoreboardTeam(t, false)); this.scoreboard.resetScores(this.formatScoreboardTeam(t, true)); boolean teamDead = (t.isDead(this) && this.getState() == GameState.RUNNING) ? true : false; Score score = obj.getScore(this.formatScoreboardTeam(t, teamDead)); score.setScore(t.getPlayers().size()); } for (Player player : this.getPlayers()) { player.setScoreboard(this.scoreboard); } }
Example 10
Source File: ScoreboardCondition.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
@Override protected Boolean execute(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); }
Example 11
Source File: ScoreboardEvent.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
@Override protected Void execute(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))); } return null; }
Example 12
Source File: Arena.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void decrementScoreForTeamID(int teamID) { ArenaTeam team = getTeamFromID(teamID); for (ArenaTeam t : this.teams.values()) { Objective obj = this.objectives.get(t.getName()+";score"); for (ArenaTeam t2 : this.teams.values()) { Score score = obj.getScore(t2.getTeamScoreboardName()); if (t2.getName().equals(team.getName())) { score.setScore(score.getScore() - 1); } } } }
Example 13
Source File: EffSetIdBasedScore.java From skRayFall with GNU General Public License v3.0 | 5 votes |
@Override protected void execute(Event evt) { if (player == null || num == null || name == null || player.getSingle(evt).getScoreboard() == null) { Skript.error("This player is either not online or has yet to have a scoreboard set for them"); } else { Scoreboard sb = player.getSingle(evt).getScoreboard(); Objective objective = sb.getObjective(DisplaySlot.SIDEBAR); Score score = objective.getScore(name.getSingle(evt).replace("\"", "")); score.setScore(num.getSingle(evt).intValue()); Core.sbManager.setScoreId(id.getSingle(evt).replace("\"", ""), score, player.getSingle(evt)); } }
Example 14
Source File: IdScoreBoardManager.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Update group scores by ID. This will replace the old scores for all players in the group. * * @param id The ID text for the group score. * @param newName New name of the score. * @param newValue New value of the score. */ void groupUpdateScore(String id, String newName, int newValue) { if (groupScoreMap.containsKey(id) && groupMap.get(id) != null) { ArrayList<Player> ls = groupMap.get(id); GroupScore old = groupScoreMap.get(id); for (Player p : ls) { Objective obj = p.getScoreboard().getObjective(DisplaySlot.SIDEBAR); obj.getScoreboard().resetScores(old.getName()); Score newScore = obj.getScore(newName); newScore.setScore(newValue); } groupScoreMap.put(id, new GroupScore(newName, newValue)); } }
Example 15
Source File: IdScoreBoardManager.java From skRayFall with GNU General Public License v3.0 | 5 votes |
/** * Update a single score by ID. This will replace the old score for the player. * * @param id The ID text for the single score. * @param newName New name of the score. * @param newValue New value of the score. */ void updateSingleScore(String id, String newName, int newValue) { if (singleScoreMap.containsKey(id)) { SingleScore old = singleScoreMap.get(id); Player player = old.getPlayer(); Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); Score newScore = obj.getScore(newName); obj.getScoreboard().resetScores(old.getScore().getEntry()); newScore.setScore(newValue); singleScoreMap.put(id, new SingleScore(newScore, player)); } }
Example 16
Source File: TagUtils.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
/** * Refreshes tag of a player * * @param p target player */ @SuppressWarnings("deprecation") public static void refresh(Player p) { if(!Config.TAGAPI_ENABLED.getBoolean()) { return; } Scoreboard board = p.getScoreboard(); for(Player player : CompatibilityUtils.getOnlinePlayers()) { NovaPlayer nPlayerLoop = PlayerManager.getPlayer(player); String tName = "ng_" + player.getName(); if(tName.length() > 16) { tName = tName.substring(0, 16); } Team team = board.getTeam(tName); if(team == null) { team = board.registerNewTeam(tName); team.addPlayer(player); } //Points Objective pointsObjective = board.getObjective("points"); if(Config.POINTSBELOWNAME.getBoolean()) { if(pointsObjective == null) { pointsObjective = board.registerNewObjective("points", "dummy"); pointsObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); pointsObjective.setDisplayName(Message.MISC_POINTSBELOWNAME.get()); } Score score = pointsObjective.getScore(player); score.setScore(nPlayerLoop.getPoints()); } else if(pointsObjective != null) { pointsObjective.unregister(); } //set tag PreparedTag tag = new PreparedTagScoreboardImpl(PlayerManager.getPlayer(player)); tag.setTagColorFor(PlayerManager.getPlayer(p)); team.setPrefix(tag.get()); } }