private void sendObjective(Objective obj, ObjectiveMode mode) { try { Object objHandle = NMS.getHandle(obj); Object packetObj = NMS.PACKET_OBJ.newInstance( objHandle, mode.ordinal() ); NMS.sendPacket(packetObj, player); } catch(InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { LOGGER.error("Error while creating and sending objective packet. (Unsupported Minecraft version?)", e); } }
@Override public void enableScoreboard() { final Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); final Objective obj = board.registerNewObjective("Spigotboard", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', Main.instance.getConfig().getString("title"))); new BukkitRunnable() { @Override public void run() { for(Player p : Bukkit.getOnlinePlayers()) { int count = Main.instance.getConfig().getList("text").size(); PlaceholderUtils placeholders = new PlaceholderUtils(p); for(Object text : Main.instance.getConfig().getList("text")){ obj.getScore(ChatColor.translateAlternateColorCodes('&', placeholders.replace(text.toString()))).setScore(count); count--; } p.setScoreboard(board); } } }.runTaskTimer(Main.instance, 0, 20); }
@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); }
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); }
private void refreshScoreboard(Player player) { if (getThirstString(player).length() > 40) { Thirst.getInstance().printPluginError("Error occurred while displaying scoreboard.", "The string "+getThirstString(player)+" is longer than 40 characters." + "\nYou must have a thirst message under 40 characters to use the SCOREBOARD displaytype." + "\n " + "\nNOTE: This message will be displayed every time Thirst tries to update someones thirst (A lot!)"); return; } Scoreboard board = manager.getNewScoreboard(); Objective obj = board.registerNewObjective(player.getName().toUpperCase(), "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(ChatColor.translateAlternateColorCodes('&', Thirst.getInstance().getYAMLConfig().scoreboardName.replace("%player%", player.getName()))); obj.getScore(getThirstString(player)).setScore(-1); player.setScoreboard(board); }
/** * Show the player's health under their nameplate */ private void createPlayerHealthObjective(Match match) { Scoreboard board = boards.get(match); Objective objective = board.registerNewObjective("playerhealth", "health"); objective.setDisplaySlot(DisplaySlot.BELOW_NAME); objective.setDisplayName(ChatColor.RED + "❤"); //Force health objective to update health readout for (Team team : match.getTeams().values()) { for (Player player : team.getPlayers()) { player.setHealth(player.getHealth()); } } }
/** * Set up the sidebar score box */ private void createSidebarTeamScoreObjective(Match match) { Scoreboard board = boards.get(match); Objective objective = board.registerNewObjective("matchscore", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(String.format("Match %s(00:00)", ChatColor.AQUA)); // Create score lines for each team for (Team team : match.getTeams().values()) { if (!team.isSpectator()) { Score score = objective.getScore(team.getChatColor() + team.getName()); score.setScore(0); } } }
@Override @Nullable protected Objective[] get(Event e) { Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard(); if (scoreboard != null) { board = scoreboard.getSingle(e); } if (obj.getSingle(e).equals("BELOW_NAME")||obj.getSingle(e).equals("PLAYER_LIST")||obj.getSingle(e).equals("SIDEBAR")) { DisplaySlot slot = DisplaySlot.valueOf(obj.getSingle(e).replace("\"", "").trim().replace(" ", "_").toUpperCase()); try { slot = DisplaySlot.valueOf(slot.toString().replace("\"", "").trim().replace(" ", "_").toUpperCase()); } catch (IllegalArgumentException t) { return null; } return new Objective[]{board.getObjective(slot)}; } else { return new Objective[]{board.getObjective(obj.getSingle(e))}; } }
private void setupScoreboard() { Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); for(Team team : scoreboard.getTeams()) { team.unregister(); } for(Objective objective : scoreboard.getObjectives()) { objective.unregister(); } }
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; }
@SuppressWarnings("deprecation") public static List<String> ShowThirst(Player player) { Objective thirst = Survival.mainBoard.getObjective("Thirst"); String thirstBar = ""; for(int i = 0; i < thirst.getScore(player).getScore(); i++) { thirstBar += "|"; } for(int i = thirst.getScore(player).getScore(); i < 20; i++) { thirstBar += "."; } if(thirst.getScore(player).getScore() >= 40) thirstBar = ChatColor.GREEN + thirstBar; else if(thirst.getScore(player).getScore() <= 6) thirstBar = ChatColor.RED + thirstBar; else thirstBar = ChatColor.AQUA + thirstBar; return Arrays.asList(ChatColor.AQUA + Words.get("Thirst"), (thirstBar.length() <= 22 ? thirstBar.substring(0) : thirstBar.substring(0, 22)), thirstBar.substring(0, 2) + (thirstBar.length() > 22 ? thirstBar.substring(22) : "") + ChatColor.RESET + ChatColor.RESET); }
private void sendObjectiveDisplay(Objective obj) { try { Object objHandle = NMS.getHandle(obj); Object packet = NMS.PACKET_DISPLAY.newInstance( 1, objHandle ); NMS.sendPacket(packet, player); } catch(InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { LOGGER.error("Error while creating and sending display packet. (Unsupported Minecraft version?)", e); } }
private ScoreHelper(Player player, boolean healthName, boolean healthTab) { this.player = player; scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); sidebar = scoreboard.registerNewObjective("sidebar", "dummy"); sidebar.setDisplaySlot(DisplaySlot.SIDEBAR); player.setScoreboard(scoreboard); // Create Teams for(int i=1; i<=15; i++) { Team team = scoreboard.registerNewTeam("SLOT_" + i); team.addEntry(genEntry(i)); } if(healthName) { Objective hName = scoreboard.registerNewObjective("hname", "health"); hName.setDisplaySlot(DisplaySlot.BELOW_NAME); hName.setDisplayName(ChatColor.RED + "❤"); } if(healthTab) { Objective hTab = scoreboard.registerNewObjective("htab", "health"); hTab.setDisplaySlot(DisplaySlot.PLAYER_LIST); } players.put(player.getUniqueId(), this); }
/** * Updates the given text for the line and given objectiveName * * @param objectiveName objectiveName * @param line line * @param text text * @return scoreboard */ public SimpleScoreboard setLine(String objectiveName, int line, String text) { final Objective objective = this.getObjective(objectiveName); final Objective bufferObjective; if (objective.getName().endsWith("_buf")) { bufferObjective = this.scoreboard.registerNewObjective(objectiveName.substring(0, objective.getName().indexOf("_buf")), objective.getCriteria()); } else { bufferObjective = this.scoreboard.registerNewObjective(objectiveName + "_buf", objective.getCriteria()); } for (final String s : this.scoreboard.getEntries()) { final Score score = objective.getScore(s); if (score.getScore() != 0 && score.getScore() != line) { bufferObjective.getScore(s).setScore(score.getScore()); } } if (text != null) { bufferObjective.getScore(ChatColor.translateAlternateColorCodes('&', text)).setScore(line); } bufferObjective.setDisplayName(objective.getDisplayName()); bufferObjective.setDisplaySlot(objective.getDisplaySlot()); objective.unregister(); return this; }
public HUD(Player player, FlightHUDPlugin plugin, FHManager manager) { previousScoreboard = player.getScoreboard(); this.scoreboard = plugin.getServer().getScoreboardManager().getNewScoreboard(); this.player = player; this.manager = manager; Objective obj = scoreboard.registerNewObjective("hud", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.getScore(ChatColor.GREEN + "Airspeed b/s").setScore(0); obj.getScore(ChatColor.GREEN + "Ground speed").setScore(0); obj.getScore(ChatColor.GREEN + "Heading").setScore(0); obj.getScore(ChatColor.GREEN + "Sink rate b/s").setScore(0); player.setScoreboard(scoreboard); taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new HUDScheduler(this), 0, 2); }
public void updateProgressObjectiveScore() { int[] flagScores = getFlagManager().getScore(); OfflinePlayer[] fakePlayers = new OfflinePlayer[] { Bukkit.getOfflinePlayer(MessageType.SCOREBOARD_PROGRESS_CTF_TEAM_RED.getTranslation().getValue()), Bukkit.getOfflinePlayer(MessageType.SCOREBOARD_PROGRESS_CTF_TEAM_BLUE.getTranslation().getValue()) }; for(BPPlayer bpPlayer : players) { SBManager sbm = bpPlayer.getScoreboardManager(); Objective progressObj = sbm.getProgressObj(); for (int i = 0; i < fakePlayers.length; i++) { Score score = progressObj.getScore(fakePlayers[i]); score.setScore(flagScores[i]); } } }
public static void createScoreboard(Player p ){ Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); Objective obj = scoreboard.registerNewObjective("Info", "dummy"); int sec = (int) (Main.getES().getBorder().whenPurge()/1000); if(sec < 0){ obj.setDisplayName("Czystka Trwa!"); }else{ obj.setDisplayName("Czystka za "+Main.formatIntoHHMMSS(sec)); } obj.setDisplaySlot(DisplaySlot.SIDEBAR); Score s = obj.getScore(ChatColor.GREEN+"Serwer Purge"); s.setScore(-1); Score size = obj.getScore(ChatColor.BOLD+""+ChatColor.GREEN+Main.getES().getBorder().getSize()/2+""); size.setScore(-2); p.setScoreboard(scoreboard); }
/** * Sets a line on the scoreboard to the text specified (max 30 chars) */ private void setLine(Scoreboard board, Objective objective, int score, String text) { String teamName = DUMMY_PREFIX + score; Team team = board.getTeam(teamName); if (team == null) { team = board.registerNewTeam(teamName); String entry = ChatColor.values()[score & 0xF].toString(); // hex 16; 16 colors team.addEntry(entry); objective.getScore(entry).setScore(score); } List<String> parts = splitString(fixFormat(text)); team.setPrefix(parts.get(0)); team.setSuffix(parts.size() > 1 ? parts.get(1) : ""); }
public void setScoreboard(Player player) { if (scoreBoards.containsKey(player)) { player.setScoreboard(scoreBoards.get(player).getScoreboard()); } else { Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); Objective sideBar = board.registerNewObjective("player", "score"); sideBar.setDisplaySlot(DisplaySlot.SIDEBAR); sideBar.setDisplayName(plugin.lm.getTranslatedText("scoreboard-title")); Team team = board.registerNewTeam("dummy"); team.addPlayer(Bukkit.getOfflinePlayer(plugin.lm.getTranslatedText("scoreboard-score"))); team.addPlayer(Bukkit.getOfflinePlayer(plugin.lm.getTranslatedText("scoreboard-total-score"))); scoreBoards.put(player, sideBar); final Score playerScore = scoreBoards.get(player).getScore(Bukkit.getOfflinePlayer(plugin.lm.getTranslatedText("scoreboard-score"))); final Score playerTotalScore = scoreBoards.get(player).getScore(Bukkit.getOfflinePlayer(plugin.lm.getTranslatedText("scoreboard-total-score"))); playerScore.setScore(0); Integer total = scores.get(player.getName()); if (total != null) { playerTotalScore.setScore(total); } else { playerTotalScore.setScore(0); } player.setScoreboard(board); } }
public Scoreboard Initialize(Player p) throws IllegalStateException, IllegalArgumentException{ ScoreboardManager manager = Bukkit.getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); Objective objective = board.registerNewObjective("test", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + " _Esti" + ChatColor.DARK_AQUA + "" + ChatColor.BOLD +"Net_ "); Score score2 = objective.getScore(ChatColor.DARK_BLUE + "Online:"); //Get a fake offline player score2.setScore(12); Score score3 = objective.getScore(ChatColor.BOLD + "" + Integer.toString(Bukkit.getServer().getOnlinePlayers().size())); //Get a fake offline player score3.setScore(11); Score score7 = objective.getScore(ChatColor.GREEN + "Time left:"); //Get a fake offline player score7.setScore(10); Score score10 = objective.getScore(ChatColor.BOLD + "" + Basic.minutes + "m " + Basic.seconds + "s"); //Get a fake offline player score10.setScore(9); Score score = objective.getScore(ChatColor.AQUA + "Kills:"); //Get a fake offline player score.setScore(8); Score score5 = objective.getScore(ChatColor.BOLD + "" + Basic.kills.get(p.getUniqueId()) + " "); //Get a fake offline player score5.setScore(7); Score score8 = objective.getScore(ChatColor.GOLD + "Deaths:"); score8.setScore(6); Score score9 = objective.getScore(ChatColor.BOLD + "" + Basic.deaths.get(p.getUniqueId()) + " "); score9.setScore(5); return board; }
public Scoreboard Initialize(Player p) throws IllegalStateException, IllegalArgumentException{ ScoreboardManager manager = Bukkit.getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); Objective objective = board.registerNewObjective("test", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + " _Esti" + ChatColor.DARK_AQUA + "" + ChatColor.BOLD +"Net_ "); Score score2 = objective.getScore(ChatColor.DARK_BLUE + "Online:"); //Get a fake offline player score2.setScore(4); Score score3 = objective.getScore(ChatColor.BOLD + "" + Integer.toString(Bukkit.getServer().getOnlinePlayers().size())); //Get a fake offline player score3.setScore(3); Score score = objective.getScore(ChatColor.AQUA + "Time before game starts:"); //Get a fake offline player score.setScore(2); Score score5 = objective.getScore(ChatColor.BOLD + "" + Basic.countdown + " "); //Get a fake offline player score5.setScore(1); return board; }
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); } } }
@Override protected void execute(Event evt) { for (Player p : players.getArray(evt)) { if (!(p.isOnline())) { Skript.error("The player is not online!"); } else { if (p.getScoreboard().getObjective("sidebarHold") != null) { Objective objective = p.getScoreboard().getObjective(DisplaySlot.SIDEBAR); objective.setDisplayName(name.getSingle(evt).replace("\"", "")); } else { Objective objectiveh = p.getScoreboard().registerNewObjective("sidebarHold", "dummy"); objectiveh.setDisplaySlot(DisplaySlot.SIDEBAR); objectiveh.setDisplayName(name.getSingle(evt).replace("\"", "")); } } } }
public void setBountyBoard(Player player, Player contractor, Reward reward) { ScoreboardManager mang = Bukkit.getScoreboardManager(); Scoreboard board = mang.getNewScoreboard(); Objective objective = board.registerNewObjective("Stats", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(ChatColor.BLUE + "Bounty"); Score bounty = objective.getScore(Bukkit.getOfflinePlayer("Bounty For You")); Score cont = objective.getScore(Bukkit.getOfflinePlayer("From: " + contractor.getPlayerListName())); //might be too long Score value = objective.getScore(Bukkit.getOfflinePlayer("Reward: " + reward.getItem())); bounty.setScore(1 + reward.getAmount()); cont.setScore(1); value.setScore(reward.getAmount()); player.setScoreboard(board); scoreTimer(player); }
public void setPlayerBoard(Player player) { ScoreboardManager mang = Bukkit.getScoreboardManager(); Scoreboard board = mang.getNewScoreboard(); Objective objective = board.registerNewObjective("Stats", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(ChatColor.BLUE + "Your Stats"); Score score = objective.getScore(Bukkit.getOfflinePlayer("Score: ")); Score kills = objective.getScore(Bukkit.getOfflinePlayer("Kills: " )); Score deaths = objective.getScore(Bukkit.getOfflinePlayer("Deaths: " )); Score teamRank = objective.getScore(Bukkit.getOfflinePlayer("Team Rank: ")); PugnaPlayer play = pg.track.getPlayerData(player); PugnaScore values = play.getScore(); score.setScore(values.getTotalScore()); kills.setScore(values.getKills()); deaths.setScore(values.getDeaths()); player.setScoreboard(board); scoreTimer(player); }
public void onEnable() { if(plugin.getConfig().getInt("endPortalLocationEpisodeAnnounce") == 0) { String msg = "No value found for 'endPortalLocationEpisodeAnnounce', disabling end portal announce"; RftdLogger.log(Level.WARN, msg); endPortalLocationAnnounced = true; } Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Objective objective = scoreboard.getObjective(DisplaySlot.SIDEBAR); if(objective != null) objective.unregister(); String eggLocationString = plugin.getConfig().getString("egg"); if(eggLocationString != null) { Location eggLocation = RftdHelper.stringToBlockLocation(eggLocationString); setEggLocation(eggLocation); } for(World world : Bukkit.getWorlds()) { world.setDifficulty(Difficulty.PEACEFUL); world.setFullTime(6000); world.setGameRuleValue("doDaylightCycle", "false"); } }
/** * Gets or creates the power level objective on the main scoreboard. * <p/> * If power levels are disabled, the objective is deleted and null is * returned. * * @return the main scoreboard objective, or null if disabled */ public static Objective getPowerLevelObjective() { if (!Config.getInstance().getPowerLevelTagsEnabled()) { Objective objective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); if (objective != null) { objective.unregister(); mcMMO.p.debug("Removed leftover scoreboard objects from Power Level Tags."); } return null; } Objective powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); if (powerObjective == null) { powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy"); powerObjective.setDisplayName(TAG_POWER_LEVEL); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); } return powerObjective; }
private void createScoreboard(Player player) { player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); org.bukkit.scoreboard.Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objective = scoreboard.registerNewObjective("Global", "dummy"); objective.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&a&l" + I18N.getLocaleString("WELCOME") + ", " + player.getName())); objective.setDisplaySlot(DisplaySlot.SIDEBAR); if (player.isOnline()) { try { player.setScoreboard(scoreboard); } catch (IllegalStateException ex) { Bukkit.getLogger().log(Level.SEVERE, I18N.getLocaleString("COULD_NOT_CREATE") + " " + player.getDisplayName()); return; } updateScoreboard(player, true); } }
public static void loadScoreboard(Minigame minigame) { minigame.setBoard(manager.getNewScoreboard()); switch (Minigame.getCurrentMinigame().getMap().getType()) { case CIRCLE_OF_BOOM: Objective rondas = minigame.getBoard().registerNewObjective("Rondas", "dummy"); rondas.setDisplaySlot(DisplaySlot.SIDEBAR); break; case WATER_THE_MONUMENT: break; case KEY_QUEST: break; default: break; } }
@Override public void run() { Objective adminbar = AdminBar.adminbar; Score tps = adminbar.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Server TPS")); Score players = adminbar.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Online Players")); Score staff = adminbar.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Online Staff")); Score ram = adminbar.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Used RAM (MB)")); Score ramPercent = adminbar.getScore(Bukkit.getServer().getOfflinePlayer(ChatColor.GREEN + "Used RAM (%)")); if (lastrun != -1) { tps.setScore(AdminBar.getTPS(lastrun)); } lastrun = System.currentTimeMillis(); players.setScore(AdminBar.getOnline()); staff.setScore(AdminBar.getOnlineStaff()); ram.setScore(AdminBar.getUsedRAM()); ramPercent.setScore(AdminBar.getRAMPercent()); }
/** * Build the scoreboard. */ public final void build() { final Objective obj = scoreboard.registerNewObjective((title.length() > 16 ? title.substring(0, 15) : title), "dummy"); obj.setDisplayName(title); obj.setDisplaySlot(DisplaySlot.SIDEBAR); int index = scores.size(); for(final Entry<String, Integer> text : scores.entrySet()) { final Entry<Team, String> team = createTeam(text.getKey()); final OfflinePlayer player = Bukkit.getOfflinePlayer(team.getValue()); if(team.getKey() != null) { team.getKey().addPlayer(player); } obj.getScore(player).setScore(text.getValue() != null ? text.getValue() : index); index -= 1; } }
public ImmutableSet<Objective> getObjectivesByCriteria(String criteria) throws IllegalArgumentException { Validate.notNull(criteria, "Criteria cannot be null"); ImmutableSet.Builder<Objective> objectives = ImmutableSet.builder(); for (CraftObjective objective : this.objectives.values()) { if (objective.getCriteria().equals(criteria)) { objectives.add(objective); } } return objectives.build(); }
public Objective getObjective(DisplaySlot slot) throws IllegalArgumentException { Validate.notNull(slot, "Display slot cannot be null"); net.minecraft.scoreboard.ScoreObjective objective = board.func_96539_a(CraftScoreboardTranslations.fromBukkitSlot(slot)); if (objective == null) { return null; } return this.objectives.get(objective.getName()); }
public Party(Player p) { this.leaderName = p.getName(); this.leaderUUID = p.getUniqueId(); board = PartyManager.plugin.getServer().getScoreboardManager().getNewScoreboard(); Objective objective = board.registerNewObjective("hpdisplay", "dummy"); objective.setDisplaySlot(DisplaySlot.BELOW_NAME); objective.setDisplayName(ChatColor.DARK_RED + "\u2764"); Objective objective_side = board.registerNewObjective("partyhpside", "dummy"); objective_side.setDisplaySlot(DisplaySlot.SIDEBAR); objective_side.setDisplayName(ChatColor.YELLOW + "Party Member " + ChatColor.RED + " HP" + ChatColor.RESET); addPlayer(p); }
public static void displayScoreboard(Player player, Objective objective) { ScoreboardServer server = (ScoreboardServer) ((CraftScoreboard) objective.getScoreboard()).getHandle(); ScoreboardObjective nmsObjective = ((CraftObjective) objective).getHandle(); List<Packet<?>> packets = server.getScoreboardScorePacketsForObjective(nmsObjective); for(Packet packet : packets) { sendPacket(player, packet); } sendPacket(player, new PacketPlayOutScoreboardDisplayObjective(1, nmsObjective)); }
public static void addScore(Player player, Objective objective, String name, int value) { ScoreboardScore score = new ScoreboardScore(((CraftScoreboard)objective.getScoreboard()).getHandle(), ((CraftObjective) objective).getHandle() , name); score.setScore(value); PacketPlayOutScoreboardScore packet = new PacketPlayOutScoreboardScore(score); sendPacket(player, packet); }
public ScoreBoard(String name, KingdomFactionsPlayer owner) { this.owner = owner; Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objective = board.registerNewObjective("Scoreboard", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + name); this.name = name; this.board = board; }
private void swapBuffers() { sendObjectiveDisplay(this.buffer); Objective temp = this.buffer; this.buffer = this.objective; this.objective = temp; }