@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); }
public static void createscrollsb(Player p, String title) { Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); playerScoreboard = scoreboard.registerNewObjective("sklib", "dummy"); //The name of the scoreboard is the name of the player, not that it really needs to be playerScoreboard.setDisplayName("Placeholder"); //Will not show to the user, we just need to set this to make bukkit happy playerScoreboard.setDisplaySlot(DisplaySlot.SIDEBAR); p.setScoreboard(scoreboard); new BukkitRunnable() { Scroller scroller = new Scroller(p, title, 16, 4, '&'); public void run() { playerScoreboard.setDisplayName(scroller.next(p)); } }.runTaskTimer(Main.getInstance(), 0L, 3L); // runs every 3 ticks }
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 protected void execute(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; } board.clearSlot(slot); } else { return; } }
@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 Sidebar(Party party) { this.scoreboard = getMatch().needMatchModule(ScoreboardMatchModule.class).getScoreboard(party); this.objective = this.scoreboard.registerNewObjective(IDENTIFIER, "dummy"); this.objective.setDisplayName(legacyTitle); this.objective.setDisplaySlot(DisplaySlot.SIDEBAR); for(int i = 0; i < MAX_ROWS; ++i) { this.rows[i] = null; this.scores[i] = -1; this.players[i] = String.valueOf(ChatColor.COLOR_CHAR) + (char) i; this.teams[i] = this.scoreboard.registerNewTeam(IDENTIFIER + "-row-" + i); this.teams[i].setPrefix(""); this.teams[i].setSuffix(""); this.teams[i].addEntry(this.players[i]); } }
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); }
@Override public org.bukkit.scoreboard.Scoreboard activate() { if (activated) return scoreboard; if (handler == null) throw new IllegalArgumentException("Scoreboard handler not set"); activated = true; // Set to the custom scoreboard holder.setScoreboard(scoreboard); objective = scoreboard.getObjective(DisplaySlot.SIDEBAR); // And start updating on a desired interval updateTask = new BukkitRunnable() { @Override public void run() { update(); } }; updateTask.runTaskTimer(AlphaLibary.getInstance(), 0, updateInterval); return scoreboard; }
private void registerTeams() { this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); red = scoreboard.registerNewTeam("red"); blue = scoreboard.registerNewTeam("blue"); // Apparently, opacity doesn't work with friendly fire >:( red.setDisplayName("Red"); //red.setAllowFriendlyFire(false); red.setCanSeeFriendlyInvisibles(true); red.setPrefix(ChatColor.RED + ""); blue.setDisplayName("Blue"); //blue.setAllowFriendlyFire(false); blue.setCanSeeFriendlyInvisibles(true); blue.setPrefix(ChatColor.BLUE + ""); sidebar = scoreboard.registerNewObjective("test", "dummy"); sidebar.setDisplaySlot(DisplaySlot.SIDEBAR); sidebar.setDisplayName("Teams (0 means dead)"); }
public void setDefaultSidebar(final SidebarProvider provider, final long updateInterval) { if (provider != this.defaultProvider) { this.defaultProvider = provider; if (this.runnable != null) { this.runnable.cancel(); } if (provider == null) { this.scoreboard.clearSlot(DisplaySlot.SIDEBAR); return; } (this.runnable = new BukkitRunnable() { public void run() { if (PlayerBoard.this.removed.get()) { this.cancel(); return; } if (provider == PlayerBoard.this.defaultProvider) { PlayerBoard.this.updateObjective(); } } }).runTaskTimerAsynchronously((Plugin)this.plugin, updateInterval, updateInterval); } }
PlayerScoreboard(Player player) { this.player = player; this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); this.objective = scoreboard.getObjective("SidebarWrapper") == null ? scoreboard.registerNewObjective("SidebarWrapper", "dummy") : scoreboard.getObjective("SidebarWrapper"); this.objective.setDisplaySlot(DisplaySlot.SIDEBAR); this.objective.setDisplayName(""); if (player.getScoreboard() != scoreboard) { player.setScoreboard(scoreboard); } update(); this.teams = new HashMap<>(); this.red = scoreboard.registerNewTeam("Red"); this.blue = scoreboard.registerNewTeam("Blue"); this.green = scoreboard.registerNewTeam("Green"); this.yellow = scoreboard.registerNewTeam("Yellow"); Arrays.stream(TeamType.values()).filter(teamType -> teamType.isPlayerTeam()).forEach(teamType -> { Team team = scoreboard.getTeam(teamType.getName()); team.setPrefix(teamType.getColor().toString()); team.setAllowFriendlyFire(false); team.setCanSeeFriendlyInvisibles(true); this.teams.put(teamType, team); }); }
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); }
/** * Updates every server tick. Use super.update() to not to break anything. */ public void update() { OMGPlayer.link.values().forEach(OMGPlayer::update); MovingTwinkle.twinkles.forEach(MovingTwinkle::draw); if (state == GameState.DISCOVERY) OMGPlayer.link.values().forEach(p -> { p.actionbar = "Discover the map"; p.displayObjective.setDisplaySlot(null); }); else OMGPlayer.getFiltered(p -> p.displayObjective.getDisplaySlot() != DisplaySlot.SIDEBAR).forEach(p -> p.displayObjective.setDisplaySlot(DisplaySlot.SIDEBAR)); if (state == GameState.INGAME) { spectatorTeam.unpresent().forEach(p -> p.actionbar = settings.allowGameShop ? "You have " + p.gameCoins + " game coins. /shop" : "You are now playing " + name); spectatorTeam.list().forEach(p -> p.actionbar = "You are now spectating " + name); } event_afterUpdateTick(); }
public void leaveReset(Player p){ all.remove(p); VoteChest.maxVote.remove(p); VoteTime.maxVote.remove(p); Trails.data.remove(p); p.getInventory().clear(); p.getInventory().setArmorContents(null); p.getInventory().setArmorContents(a.get(p)); p.getInventory().setContents(c.get(p)); p.setGameMode(GameMode.SURVIVAL); p.setHealth(20); p.setFoodLevel(20); p.setFireTicks(0); p.setLevel(0); p.setExp(0); ingame.remove(p); out.remove(p); Skywars.giveLobbyItem(p); if(p.getScoreboard().getObjective(DisplaySlot.SIDEBAR) == null){ return; } p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).unregister(); }
ScoreboardDisplay(Match match, CompetitorContainer viewer) { this.match = match; this.viewer = viewer; scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); //TODO: proper scoreboard name objective = scoreboard.registerNewObjective(ChatColor.AQUA + "Objectives", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); ScoreModule scoreModule = Cardinal.getModule(ScoreModule.class); if (scoreModule.hasScoring(match)) { scoreModule.getScores(match).forEach(score -> this.score.getEntries().add(new ScoreScoreboardEntry(this, score))); score.getEntries().add(new EmptyScoreboardEntry(this)); } for (Team team : Team.getTeams(match)) { ScoreboardGroup group = new ScoreboardGroup(); if (Team.getTeamShownObjectives(match, team).size() > 0) { group.getEntries().add(new TeamName(this, team)); Team.getTeamShownObjectives(match, team).forEach( obj -> group.getEntries().add(getEntryForObjective(obj, team))); group.getEntries().add(new EmptyScoreboardEntry(this)); } teams.put(team, group); } defaultEntry = new EmptyScoreboardEntry(this); updatePlayerContainers(); }
public Party() { name = ""; members = new LinkedList<>(); leader = null; partyBoard = Bukkit.getScoreboardManager().getNewScoreboard(); tLeader = partyBoard.registerNewTeam("Leader"); tMembers = partyBoard.registerNewTeam("members"); tLeader.setPrefix(ChatColor.GOLD.toString()); tMembers.setPrefix(ChatColor.DARK_GREEN.toString()); board = partyBoard.registerNewObjective("side", "dummy"); board.setDisplayName("Party"); board.setDisplaySlot(DisplaySlot.SIDEBAR); id = UUID.randomUUID(); Bukkit.getPluginManager().registerEvents(this, QuestManagerPlugin.questManagerPlugin); QuestManagerPlugin.questManagerPlugin.getPlayerManager().addParty(this); }
public void create(){ ScoreboardManager manager = Bukkit.getScoreboardManager(); board = manager.getNewScoreboard(); teamRed = board.registerNewTeam("Red"); teamRed.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); teamRed.setAllowFriendlyFire(false); teamGreen = board.registerNewTeam("Green"); teamGreen.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); teamGreen.setAllowFriendlyFire(false); objective = board.registerNewObjective("time", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName("Time"); Score scoreRed = objective.getScore(ChatColor.RED + "Red:"); scoreRed.setScore(Game.getGame().getCurrentArena().maxPoints); Score scoreGreen = objective.getScore(ChatColor.GREEN + "Green:"); scoreGreen.setScore(Game.getGame().getCurrentArena().maxPoints); teamRed.setPrefix(ChatColor.RED.toString()); teamGreen.setPrefix(ChatColor.GREEN.toString()); teamRed.setSuffix(ChatColor.WHITE.toString()); teamGreen.setSuffix(ChatColor.WHITE.toString()); }
@SuppressWarnings("deprecation") private ScoreBoard(Player p, ScoreBoardType t) { if(chlist.isEmpty()) addChars(); player = p; if(p.getName().equals("luxdev")) p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1728000, 300, true, false, Color.BLACK)); type = t; boards.put(p, this); board = Bukkit.getScoreboardManager().getNewScoreboard(); score = board.registerNewObjective("score", "dummy"); score.setDisplaySlot(DisplaySlot.SIDEBAR); score.setDisplayName(replaceString(TITLE[titleindex])); int index = 15; for(String s : content.get(t)) { Team team = board.registerNewTeam("Team:" + index); OfflinePlayer op = Bukkit.getOfflinePlayer((String)chlist.get(index - 1)); team.addPlayer(op); lines.put(team, s); setContent(team, s); score.getScore(op).setScore(index--); } player.setScoreboard(board); }
@Override public void change(Event e, Object[] delta, Changer.ChangeMode mode){ if (mode == ChangeMode.SET) { String string = (String)delta[0]; if (string.equals("BELOW_NAME")||string.equals("PLAYER_LIST")||string.equals("SIDEBAR")) { DisplaySlot slot = DisplaySlot.valueOf(string.replace("\"", "").trim().replace(" ", "_").toUpperCase()); try { slot = DisplaySlot.valueOf(slot.toString().replace("\"", "").trim().replace(" ", "_").toUpperCase()); } catch (IllegalArgumentException t) { return; } obj.getSingle(e).setDisplaySlot(slot); } else { return; } } }
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); }
@Override public void run() { for(Player p : Bukkit.getOnlinePlayers()){ Scoreboard sc = p.getScoreboard(); if(sc!= null){ int sec = (int) (Main.getES().getBorder().whenPurge()/1000); if(sc.getObjective(DisplaySlot.SIDEBAR) != null){ if(!Main.getES().getBorder().isRunning()){ sc.getObjective(DisplaySlot.SIDEBAR).setDisplayName("Czystka za "+Main.formatIntoHHMMSS(sec)); }else{ sc.getObjective(DisplaySlot.SIDEBAR).setDisplayName("Czystka Trwa! Granica wynosi "+Main.getES().getBorder().getDecreasingSize()/2); } } } } }
/** * Constructs a new MainScoreboard * * @param player the player this scoreboard is meant for */ public MainScoreboard(Player player) { YamlConfiguration messages = SettingsManager.getInstance().getMessages(); this.player = player; objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName(MessageManager.translate(messages.getString("scoreboards.main.header"), player)); List<String> strings = messages.getStringList("scoreboards.main.text"); for (int i = 0; i < strings.size(); i++) { Team team = scoreboard.registerNewTeam(i + ""); team.addEntry(ChatColor.values()[i].toString()); team.setDisplayName(""); teams.add(team); this.strings.add(MessageManager.translate(strings.get(i), player)); } }
private void updateScoreboard() { if (uCb == null) { if (uCa.getObjective("uhc_w") != null) { uCa.getObjective("uhc_w").unregister(); } uCb = uCa.registerNewObjective("uhc_w", "dummy"); uCb.setDisplayName("\u00A7c\u00A7lUHC-" + uA.mC.cFc + "\u00A78\u00A7l :\u00A7e\u00A7l " + (uA.mC.cGa ? "Team" : "Solo") + " Mode"); uCb.setDisplaySlot(DisplaySlot.SIDEBAR); setScore(6, " "); setScore(5, "\u00A76\u00A7lStatus"); setScore(3, ""); setScore(2, "\u00A76\u00A7lPlayers"); } setScore(4, " " + (uD[0] ? "\u00A7a\u00A7oStarting in \u00A7e\u00A7o" + uE[0] + "\u00A7a\u00A7o secound" + (uE[0] != 1 ? "s" : "") : "\u00A77\u00A7oWaiting for players...")); setScore(1, " \u00A77" + uA.mB.getAllPlayers().size() + " / " + uA.getServer().getMaxPlayers()); }
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; }
@Override protected void execute(Event evt) { if (!(player.getSingle(evt).isOnline())) { Skript.error("The player is not online!"); } else { if (player.getSingle(evt).getScoreboard().getObjective(DisplaySlot.SIDEBAR) != null) { if (player.getSingle(evt).getScoreboard().getObjective(DisplaySlot.SIDEBAR) .getScore(name.getSingle(evt).replace("\"", "")) != null) { player.getSingle(evt).getScoreboard().resetScores(name.getSingle(evt).replace("\"", "")); } else { Skript.error("That score does not exist!"); } } else { Skript.error("No sidebar score has been set!"); } } }
@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 resetScoreboard(String objName) { sb = null; obj = null; scores.clear(); teams.clear(); for (Player p : Bukkit.getOnlinePlayers()) p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); sb = Bukkit.getScoreboardManager().getNewScoreboard(); obj = sb.registerNewObjective("anni", "dummy"); obj.setDisplaySlot(DisplaySlot.SIDEBAR); obj.setDisplayName(objName); setTeam(GameTeam.RED); setTeam(GameTeam.BLUE); setTeam(GameTeam.GREEN); setTeam(GameTeam.YELLOW); }
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"); } }
private ScoreboardWrapper(String playerName, Scoreboard scoreboard) { this.playerName = playerName; this.scoreboard = scoreboard; sidebarType = SidebarType.NONE; sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy"); powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy"); if (Config.getInstance().getPowerLevelTagsEnabled()) { powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { powerObjective.getScore(mcMMOPlayer.getProfile().getPlayerName()).setScore(mcMMOPlayer.getPowerLevel()); } } }
/** * 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; }