org.bukkit.scoreboard.Scoreboard Java Examples
The following examples show how to use
org.bukkit.scoreboard.Scoreboard.
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: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * Disconnect the player from the scoreboard * - Removes the player from their team (i.e., player-color) * - Removes their score from the scoreboard * - The scoreboard will still be displayed on the player's client * until a new scoreboard is assigned or the user exits */ public void disconnect(GPlayer gPlayer) { if (!isEnabled) { return; } UUID associatedWorldId = gPlayer.getAssociatedWorldId(); Scoreboard scoreboard = getScoreboard(associatedWorldId, false); if (scoreboard != null) { //Remove the team (i.e., player-color) OfflinePlayer player = Bukkit.getOfflinePlayer(gPlayer.getUuid()); Team team = scoreboard.getTeam(player.getName()); if (team != null) { team.removeEntry(player.getName()); team.unregister(); } //Remove the player's score: scoreboard.resetScores(player.getName()); //Delete unused scoreboards: if (scoreboard.getEntries().size() == 0) { scoreboards.remove(associatedWorldId); } } }
Example #2
Source File: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * Connect the player to the scoreboard * - Disconnects from any existing scoreboards * - Creates a new scoreboard for the world if required */ public void connect(GPlayer gPlayer) { if (gPlayer != null && isEnabled) { //Disconnect the player from the current scoreboard (if required): disconnect(gPlayer); //Connect online players to their associated-world scoreboards: Player onlinePlayer = gPlayer.getOnlinePlayer(); if (onlinePlayer != null) { Scoreboard scoreboard = getScoreboard(gPlayer); onlinePlayer.setScoreboard(scoreboard); Team team = scoreboard.registerNewTeam(onlinePlayer.getName()); team.addEntry(onlinePlayer.getName()); update(gPlayer); } } }
Example #3
Source File: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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, "scores", "Carbon Score"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); } } return scoreboard; }
Example #4
Source File: QAMain.java From QualityArmory with GNU General Public License v3.0 | 6 votes |
/** * GUNLIST: * <p> * 2: P30 3 PKP 4 MP5K 5 AK47 6: AK 7 M16 8 Remmington 9 FNFal 10 RPG 11 UMP 12 * SW1911 13 M40 14 Ammo 556 15 9mm 16 buckshot 17 rocketRPG 18 Enfield 19 Henry * 20 MouserC96 * <p> * 22 Grenades */ @Override public void onDisable() { for (Entry<MaterialStorage, CustomBaseObject> misc : miscRegister.entrySet()) { if (misc instanceof ThrowableItems) { for (Entry<Entity, ThrowableHolder> e : ThrowableItems.throwItems.entrySet()) { if (e.getKey() instanceof Item) e.getKey().remove(); } } } for (Scoreboard s : coloredGunScoreboard) for (Team t : s.getTeams()) t.unregister(); for (Gunner g : gunners) { g.dispose(); } }
Example #5
Source File: FlagSpectate.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Subscribe(priority = Subscribe.Priority.LOW) public void onGameEnd(GameEndEvent event) { boolean showScoreboard = config.getSpectateSection().isShowScoreboard(); if (!showScoreboard) { return; } Scoreboard scoreboard = getScoreboard(); if (scoreboard == null) { return; } scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); for (SpleefPlayer player : spectators) { player.getBukkitPlayer().setScoreboard(scoreboard); } }
Example #6
Source File: ScoreboardMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
public Scoreboard getScoreboard(Party party) { return MapUtils.computeIfAbsent(partyScoreboards, party, () -> { // Create the new party's scoreboard Scoreboard scoreboard = getMatch().getServer().getScoreboardManager().getNewScoreboard(); logger.fine("Created scoreboard " + toString(scoreboard) + " for party " + party); // Add all other party scoreboards to the new party's scoreboard for(Party oldParty : partyScoreboards.keySet()) { createPartyScoreboardTeam(oldParty, scoreboard, !(party instanceof Competitor)); } // Add the new party to its own scoreboard createPartyScoreboardTeam(party, scoreboard, !(party instanceof Competitor)); // Add the new party to the hidden scoreboard createPartyScoreboardTeam(party, hiddenScoreboard, false); // Add the new party to all other party scoreboards for(Map.Entry<Party, Scoreboard> entry : partyScoreboards.entrySet()) { createPartyScoreboardTeam(party, entry.getValue(), !(entry.getKey() instanceof Competitor)); } return scoreboard; }); }
Example #7
Source File: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * Update the global score for all worlds */ private void updateGlobalScores() { for (World world : Bukkit.getWorlds()) { //Do not update worlds with disabled climate-engines: WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID()); if (climateEngine != null && climateEngine.isEnabled()) { //Get the scoreboard for this world: Scoreboard scoreboard = getScoreboard(world.getUID(), false); //Get its objective (scoreboard title / group): Objective objective = null; if (scoreboard != null) { objective = scoreboard.getObjective(GLOBAL_WARMING); } //Update the title to show this world's temperature: if (objective != null) { double temperature = climateEngine.getTemperature(); objective.setDisplayName(climateEngine.formatTemp(temperature)); } } } }
Example #8
Source File: RaindropsListener.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
private void setRaindropsCount(Player player, int count) { if(player == null) return; final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Objective objective = scoreboard.getObjective(player.getName()); Integer oldCount = raindrops.get(player); if(oldCount != null) { Utils.removeScore(player, String.format("%,d", oldCount)); } Utils.addScore(player, objective, String.format("%,d", count), 1); raindrops.put(player, count); Utils.giveGhastTear(player, count); }
Example #9
Source File: RaindropsListener.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR) public void displayScoreboard(final PlayerJoinEvent event) { final Player player = event.getPlayer(); final User user = userStore.getUser(player); final PlayerId playerId = tc.oc.api.bukkit.users.Users.playerId(player); final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); final Objective objective = getOrCreateObjective(scoreboard, player.getName(), "dummy"); final String raindropsName = ChatColor.AQUA + "Raindrops"; objective.setDisplayName(renderer.renderLegacy(generalFormatter.brandName(), event.getPlayer())); objective.getScore(raindropsName).setScore(2); Utils.displayScoreboard(player, objective); setRaindropsCount(player, user.raindrops()); GizmoUtils.setGizmo(player, Gizmos.emptyGizmo, true); }
Example #10
Source File: GScoreboard.java From GlobalWarming with GNU Lesser General Public License v3.0 | 6 votes |
/** * Display a player's score * - Uses the player's associated-world scoreboard * - Note: the player may be in a different world, that's ok * - Player names are mapped to color warmth (based on their score) */ private void updatePlayerScore(GPlayer gPlayer) { if (gPlayer != null) { //Do not update associated-worlds with disabled climate-engines: // - Ignore offline players (e.g., someone completing an offline player's bounty) Player onlinePlayer = gPlayer.getOnlinePlayer(); if (onlinePlayer != null && ClimateEngine.getInstance().isClimateEngineEnabled(gPlayer.getAssociatedWorldId())) { //Update the player's score: Scoreboard scoreboard = getScoreboard(gPlayer); if (scoreboard != null) { Objective objective = scoreboard.getObjective(GLOBAL_WARMING); if (objective != null) { Team team = scoreboard.getPlayerTeam(onlinePlayer); if (team != null) { team.setColor(Colorizer.getScoreColor(gPlayer.getCarbonScore())); objective.getScore(onlinePlayer).setScore(gPlayer.getCarbonScore()); } } } } } }
Example #11
Source File: ScoreBoardManager.java From CombatLogX with GNU General Public License v3.0 | 6 votes |
public void removeScoreboard(Player player) { UUID uuid = player.getUniqueId(); CustomScoreBoard customScoreBoard = this.customScoreBoardMap.remove(uuid); if(customScoreBoard == null) return; customScoreBoard.disableScoreboard(); if(shouldSavePrevious() && this.previousScoreboardMap.containsKey(uuid)) { Scoreboard previousScoreboard = this.previousScoreboardMap.get(uuid); if(previousScoreboard == null) return; Objective objective = previousScoreboard.getObjective("combatlogx"); if(objective != null) return; player.setScoreboard(previousScoreboard); } }
Example #12
Source File: FlagInvisibleSpectate.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @Subscribe public void onSpectateLeave(FlagSpectate.SpectateLeaveEvent event) { SpleefPlayer player = event.getPlayer(); Player bukkitPlayer = player.getBukkitPlayer(); team.removePlayer(bukkitPlayer); bukkitPlayer.removePotionEffect(PotionEffectType.INVISIBILITY); for (SpleefPlayer ingamePlayer : game.getPlayers()) { if (ingamePlayer.getBukkitPlayer().canSee(bukkitPlayer)) { continue; } ingamePlayer.getBukkitPlayer().showPlayer(bukkitPlayer); } Scoreboard mainScoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); bukkitPlayer.setScoreboard(mainScoreboard); }
Example #13
Source File: TagDataHandler.java From TabooLib with MIT License | 5 votes |
private void cancelPlayerVariable(Player player, TagPlayerData playerData) { if (playerData == null) { return; } for (Player online : Bukkit.getOnlinePlayers()) { Scoreboard scoreboard = TagUtils.getScoreboardComputeIfAbsent(player); TagUtils.cleanEntryInScoreboard(scoreboard, playerData.getNameDisplay()); // 傻逼 BedWarsRel 我草你妈的 if (TabooLib.getConfig().getBoolean("TABLIST-AUTO-CLEAN-TEAM", true)) { TagUtils.cleanEmptyTeamInScoreboard(scoreboard); } } }
Example #14
Source File: ScoreboardMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
protected Team createPartyScoreboardTeam(Party party, Scoreboard scoreboard, boolean forObservers) { logger.fine("Creating team for party " + party + " on scoreboard " + toString(scoreboard)); Team team = scoreboard.registerNewTeam(getScoreboardTeamName(party)); updatePartyScoreboardTeam(party, team, forObservers); for(MatchPlayer player : party.getPlayers()) { team.addPlayer(player.getBukkit()); } return team; }
Example #15
Source File: ScoreboardMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public void updatePartyScoreboardTeam(Party party) { String teamName = getScoreboardTeamName(party); updatePartyScoreboardTeam(party, hiddenScoreboard.getTeam(teamName), false); for(Map.Entry<Party, Scoreboard> entry : partyScoreboards.entrySet()) { updatePartyScoreboardTeam(party, entry.getValue().getTeam(teamName), !(entry.getKey() instanceof Competitor)); } }
Example #16
Source File: IndividualPrefix.java From FunnyGuilds with Apache License 2.0 | 5 votes |
protected void addPlayer(String player) { if (player == null) { return; } User user = User.get(player); if (!user.hasGuild()) { return; } Scoreboard scoreboard = getScoreboard(); Team team = scoreboard.getEntryTeam(player); if (team != null) { team.removeEntry(player); } team = scoreboard.getTeam(user.getGuild().getTag()); if (team == null) { addGuild(user.getGuild()); team = scoreboard.getTeam(user.getGuild().getTag()); } if (this.getUser().hasGuild()) { if (this.getUser().equals(user) || this.getUser().getGuild().getMembers().contains(user)) { team.setPrefix(replace(FunnyGuilds.getInstance().getPluginConfiguration().prefixOur, "{TAG}", user.getGuild().getTag())); } } team.addEntry(player); }
Example #17
Source File: PlayerStat.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private static void getScoreboard(Player player) { Scoreboard scoreboard = scoreboards.get(player); if (scoreboard != null) { resetScoreboard(player); } ScoreboardManager manager = SkyWarsReloaded.get().getServer().getScoreboardManager(); scoreboard = manager.getNewScoreboard(); Objective objective = SkyWarsReloaded.getNMS().getNewObjective(scoreboard, "dummy", "info"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); scoreboards.put(player, scoreboard); updateScoreboard(player); }
Example #18
Source File: TagUtils.java From TabooLib with MIT License | 5 votes |
public static Team getTeamComputeIfAbsent(Scoreboard scoreboard, String teamName) { Team team = scoreboard.getTeam(teamName); if (team == null) { scoreboard.registerNewTeam(teamName); } return scoreboard.getTeam(teamName); }
Example #19
Source File: PlayerStat.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
private static void resetScoreboard(Player player) { Scoreboard scoreboard = scoreboards.get(player); for (Objective objective: scoreboard.getObjectives()) { if (objective != null) { objective.unregister(); } } }
Example #20
Source File: PlayerStat.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public static void getScoreboard(Player player) { Scoreboard scoreboard = scoreboards.get(player); if (scoreboard != null) { resetScoreboard(player); } ScoreboardManager manager = SkyWarsReloaded.get().getServer().getScoreboardManager(); scoreboard = manager.getNewScoreboard(); Objective objective = scoreboard.registerNewObjective("info", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); scoreboards.put(player, scoreboard); updateScoreboard(player); }
Example #21
Source File: ScoreboardMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
protected void updatePlayer(MatchPlayer player, Party party, boolean show) { if(show) { Scoreboard scoreboard = partyScoreboards.get(party); logger.fine("Setting player " + player + " to scoreboard " + toString(scoreboard)); player.getBukkit().setScoreboard(scoreboard); } else { logger.fine("Setting player " + player + " to hidden scoreboard"); player.getBukkit().setScoreboard(getHiddenScoreboard()); } }
Example #22
Source File: IndividualPrefixManager.java From FunnyGuilds with Apache License 2.0 | 5 votes |
public static void updatePlayer(Player player) { if (!player.isOnline()) { return; } User user = User.get(player); UserCache cache = user.getCache(); Scoreboard cachedScoreboard = cache.getScoreboard(); PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration(); if (cachedScoreboard == null) { FunnyGuilds.getInstance().getPluginLogger().debug( "We're trying to update player scoreboard, but cached scoreboard is null (server has been reloaded?)"); Bukkit.getScheduler().runTask(FunnyGuilds.getInstance(), () -> { Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); player.setScoreboard(scoreboard); cache.setScoreboard(scoreboard); if (config.guildTagEnabled) { IndividualPrefix prefix = new IndividualPrefix(user); prefix.initialize(); cache.setIndividualPrefix(prefix); } cache.getDummy().updateScore(user); }); return; } try { player.setScoreboard(cachedScoreboard); } catch (IllegalStateException e) { FunnyGuilds.getInstance().getPluginLogger().warning("[IndividualPrefix] java.lang.IllegalStateException: Cannot set scoreboard for invalid CraftPlayer (" + player.getClass() + ")"); } }
Example #23
Source File: CraftPlayer.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void setScoreboard(Scoreboard scoreboard) { Validate.notNull(scoreboard, "Scoreboard cannot be null"); net.minecraft.network.NetHandlerPlayServer playerConnection = getHandle().playerNetServerHandler; if (playerConnection == null) { throw new IllegalStateException("Cannot set scoreboard yet"); } if (playerConnection.isDisconnected()) { // throw new IllegalStateException("Cannot set scoreboard for invalid CraftPlayer"); // Spigot - remove this as Mojang's semi asynchronous Netty implementation can lead to races } this.server.getScoreboardManager().setPlayerBoard(this, scoreboard); }
Example #24
Source File: ScoreBoardManager.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private void enableScoreboard(Player player) { if(isDisabledGlobally()) return; if(isDisabled(player)) return; UUID uuid = player.getUniqueId(); if(shouldSavePrevious() && !this.previousScoreboardMap.containsKey(uuid)) { Scoreboard previousScoreboard = player.getScoreboard(); Objective objective = previousScoreboard.getObjective("combatlogx"); if(objective == null) this.previousScoreboardMap.put(uuid, previousScoreboard); } CustomScoreBoard customScoreBoard = this.customScoreBoardMap.getOrDefault(uuid, new CustomScoreBoard(this.expansion, player)); this.customScoreBoardMap.put(uuid, customScoreBoard); customScoreBoard.enableScoreboard(); }
Example #25
Source File: RaindropsListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private static Objective getOrCreateObjective(Scoreboard scoreboard, String name, String criteria) { Objective obj = scoreboard.getObjective(name); if(obj == null) { obj = scoreboard.registerNewObjective(name, criteria); } return obj; }
Example #26
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 #27
Source File: QAMain.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
public static Scoreboard registerGlowTeams(Scoreboard sb) { if (sb.getTeam("QA_RED") == null) { for (ChatColor c : ChatColor.values()) { if (sb.getTeam("QA_" + c.name() + "") == null) sb.registerNewTeam("QA_" + c.name() + "").setPrefix(c + ""); } } return sb; }
Example #28
Source File: TpsPingTask.java From NyaaUtils with MIT License | 5 votes |
public TpsPingTask(NyaaUtils plugin) { this.plugin = plugin; Scoreboard mainScoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Objective pingObj = mainScoreboard.getObjective("nyaautilsping"); if (plugin.cfg.ping_tab) { if (pingObj == null) { pingObj = mainScoreboard.registerNewObjective("nyaautilsping", "dummy", "Ping"); } pingObj.setDisplaySlot(DisplaySlot.PLAYER_LIST); } else if (pingObj != null) { pingObj.setDisplaySlot(null); } }
Example #29
Source File: Netherboard.java From Netherboard with Apache License 2.0 | 5 votes |
/** * Creates a board to a player, using a predefined scoreboard. * * @param player the player * @param scoreboard the scoreboard to use * @param name the name of the board * @return the newly created board */ public BPlayerBoard createBoard(Player player, Scoreboard scoreboard, String name) { deleteBoard(player); BPlayerBoard board = new BPlayerBoard(player, scoreboard, name); boards.put(player, board); return board; }
Example #30
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); }