org.bukkit.scoreboard.DisplaySlot Java Examples

The following examples show how to use org.bukkit.scoreboard.DisplaySlot. 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 vote down vote up
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: SidebarMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
private Sidebar(Party party) {
  this.scoreboard = match.needModule(ScoreboardMatchModule.class).getScoreboard(party);
  this.objective = this.scoreboard.registerNewObjective(IDENTIFIER, "dummy");
  this.objective.setDisplayName(
      StringUtils.left(
          renderSidebarTitle(match.getMap().getTags(), match.getMap().getGamemode()), 32));
  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]);
  }
}
 
Example #3
Source File: Game.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #4
Source File: PacketListener.java    From ScoreboardStats with MIT License 6 votes vote down vote up
private void handleDisplayPacket(Player player, PacketContainer packet) {
    //Can be empty; if so it would just clear the slot
    String objectiveId = packet.getStrings().read(0);
    Optional<DisplaySlot> slot = SlotTransformer.fromId(packet.getIntegers().read(0));

    //Packet receiving validation
    if (!slot.isPresent() || objectiveId.length() > 16) {
        return;
    }

    PlayerScoreboard scoreboard = manager.getScoreboard(player);
    if (slot.get() == DisplaySlot.SIDEBAR) {
        scoreboard.getObjective(objectiveId).ifPresent(obj -> scoreboard.sidebarObjective = obj);
    } else {
        scoreboard.getSidebarObjective().filter(objective -> objective.getId().equals(objectiveId))
                .ifPresent(objective -> scoreboard.sidebarObjective = null);
    }
}
 
Example #5
Source File: ToggleCommand.java    From ScoreboardStats with MIT License 6 votes vote down vote up
@Override
public void onCommand(CommandSender sender, String subCommand, String... args) {
    if (!(sender instanceof Player)) {
        //the console cannot have a scoreboard
        sender.sendMessage("§4This command can only be executed by Players");
        return;
    }

    //We checked that it can only be players
    Player player = (Player) sender;
    RefreshTask refreshTask = plugin.getRefreshTask();
    if (refreshTask.contains(player)) {
        if ("hide".equals(subCommand) || "toggle".equals(subCommand)) {
            refreshTask.remove(player);
            player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
            player.sendMessage(TOGGLE_MSG);
        }
    } else if ("show".equals(subCommand) || "toggle".equals(subCommand)) {
        player.sendMessage(TOGGLE_MSG);
        refreshTask.addToQueue(player);
    }
}
 
Example #6
Source File: UHPlugin.java    From KTP with GNU General Public License v3.0 6 votes vote down vote up
public void setMatchInfo() {
	Objective obj = null;
	try {
		obj = sb.getObjective(sbobjname);
		obj.setDisplaySlot(null);
		obj.unregister();
	} catch (Exception e) {
		
	}
	Random r = new Random();
	sbobjname = "KTP"+r.nextInt(10000000);
	obj = sb.registerNewObjective(sbobjname, "dummy");
	obj = sb.getObjective(sbobjname);

	obj.setDisplayName(this.getScoreboardName());
	obj.setDisplaySlot(DisplaySlot.SIDEBAR);
	obj.getScore(Bukkit.getOfflinePlayer(ChatColor.GRAY+"Episode "+ChatColor.WHITE+episode)).setScore(5);
	obj.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE+""+Bukkit.getServer().getOnlinePlayers().size()+ChatColor.GRAY+" joueurs")).setScore(4);
	obj.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE+""+getAliveTeams().size()+ChatColor.GRAY+" teams")).setScore(3);
	obj.getScore(Bukkit.getOfflinePlayer("")).setScore(2);
	obj.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE+formatter.format(this.minutesLeft)+ChatColor.GRAY+":"+ChatColor.WHITE+formatter.format(this.secondsLeft))).setScore(1);
}
 
Example #7
Source File: FlagTeamScoreboard.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onTeamScoreboardInitialize(TeamScoreboardInitializeEvent event) {
	FlagTeam flag = (FlagTeam) getParent();
	Scoreboard board = flag.getScoreboard();
	
	if (board == null) {
		return;
	}
	
	FlagScoreboard.GetScoreboardDisplayNameEvent getDisplayNameEvent = new FlagScoreboard.GetScoreboardDisplayNameEvent();
	game.getEventBus().callEvent(getDisplayNameEvent);
	String displayName = getDisplayNameEvent.getDisplayName();
	
	objective = board.getObjective(FlagTeam.OBJECTIVE_NAME);
	objective.setDisplayName(displayName);
	objective.setDisplaySlot(DisplaySlot.SIDEBAR);
}
 
Example #8
Source File: SidebarMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
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]);
    }
}
 
Example #9
Source File: EffNameOfScore.java    From skRayFall with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void execute(Event evt) {

    for (Player p : players.getArray(evt)) {
        if (!(p.isOnline())) {
            Skript.error("The player is not online!");
            continue;
        }
        try {
            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("\"", ""));
            }
        } catch (IllegalArgumentException e){
            Skript.error(e.getLocalizedMessage());
        }
    }
}
 
Example #10
Source File: EffDeleteScore.java    From skRayFall with GNU General Public License v3.0 6 votes vote down vote up
@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!");
        }
    }
}
 
Example #11
Source File: EffSetScore.java    From skRayFall with GNU General Public License v3.0 6 votes vote down vote up
@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 #12
Source File: GScoreboard.java    From GlobalWarming with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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 #13
Source File: PlayerStat.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
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 #14
Source File: ExprScoreBoardTitle.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
protected String[] get(Event evt) {
    if (player != null
            && player.getSingle(evt).getScoreboard().getObjective("sidebarHold") != null) {
        Objective objective = player.getSingle(evt).getScoreboard().getObjective(DisplaySlot.SIDEBAR);
        return new String[]{objective.getDisplayName()};
    }
    return null;
}
 
Example #15
Source File: IdScoreBoardManager.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #16
Source File: SlotTransformer.java    From ScoreboardStats with MIT License 5 votes vote down vote up
/**
 * Get the enum from his id
 *
 * @param slotId the id
 * @return the representing enum or null if the id isn't valid
 */
public static Optional<DisplaySlot> fromId(int slotId) {
    switch (slotId) {
        case 0:
            return Optional.of(DisplaySlot.PLAYER_LIST);
        case 1:
            return Optional.of(DisplaySlot.SIDEBAR);
        case 2:
            return Optional.of(DisplaySlot.BELOW_NAME);
        default:
            return Optional.empty();
    }
}
 
Example #17
Source File: EffRemoveScoreTab.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    if (player.getSingle(evt) == null) {
        Skript.error("The player is not online!");
    } else {
        if (player.getSingle(evt).getScoreboard().getObjective("tabHold") != null) {
            player.getSingle(evt).getScoreboard().getObjective(DisplaySlot.PLAYER_LIST).unregister();
        } else {
            Skript.error("That player doesn't have a tab score!");
        }
    }
}
 
Example #18
Source File: EffRemoveScoreBelowName.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    if (player.getSingle(evt) == null) {
        Skript.error("The player is not online!");
    } else {
        if (player.getSingle(evt).getScoreboard().getObjective("bottomHold") != null) {
            player.getSingle(evt).getScoreboard().getObjective(DisplaySlot.BELOW_NAME).unregister();
        } else {
            Skript.error("That player doesnt have a scoreboard under their name!");
        }
    }
}
 
Example #19
Source File: EffRemoveScoreboard.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    if (player.getSingle(evt).getScoreboard().getObjective("sidebarHold") != null) {
        Core.sbManager.removeSingleScoresFromPlayer(player.getSingle(evt));
        Core.sbManager.removeGroupScoresFromPlayer(player.getSingle(evt));
        player.getSingle(evt).getScoreboard().getObjective(DisplaySlot.SIDEBAR).unregister();
    }
}
 
Example #20
Source File: IdScoreBoardManager.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #21
Source File: PacketScoreboard.java    From helper with MIT License 5 votes vote down vote up
@Override
public PacketScoreboardObjective createPlayerObjective(Player player, String id, String title, DisplaySlot displaySlot, boolean autoSubscribe) {
    Preconditions.checkArgument(id.length() <= 16, "id cannot be longer than 16 characters");
    Map<String, PacketScoreboardObjective> objectives = this.playerObjectives.computeIfAbsent(player.getUniqueId(), p -> new HashMap<>());
    Preconditions.checkState(!objectives.containsKey(id), "id already exists");

    PacketScoreboardObjective objective = new PacketScoreboardObjective(id, title, displaySlot, autoSubscribe);
    if (autoSubscribe) {
        objective.subscribe(player);
    }
    objectives.put(id, objective);

    return objective;
}
 
Example #22
Source File: SimpleScoreboard.java    From ScoreboardLib with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SimpleScoreboard(Player holder) {
    this.holder = holder;
    // Initiate the Bukkit scoreboard
    scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    scoreboard.registerNewObjective("board", "dummy").setDisplaySlot(DisplaySlot.SIDEBAR);
    objective = scoreboard.getObjective(DisplaySlot.SIDEBAR);
}
 
Example #23
Source File: Game.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
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 #24
Source File: Game.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: CraftObjective.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public DisplaySlot getDisplaySlot() throws IllegalStateException {
    CraftScoreboard scoreboard = checkState();
    net.minecraft.scoreboard.Scoreboard board = scoreboard.board;
    net.minecraft.scoreboard.ScoreObjective objective = this.objective;

    for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) {
        if (board.func_96539_a(i) == objective) {
            return CraftScoreboardTranslations.toBukkitSlot(i);
        }
    }
    return null;
}
 
Example #26
Source File: CraftObjective.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public void setDisplaySlot(DisplaySlot slot) throws IllegalStateException {
    CraftScoreboard scoreboard = checkState();
    net.minecraft.scoreboard.Scoreboard board = scoreboard.board;
    net.minecraft.scoreboard.ScoreObjective objective = this.objective;

    for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) {
        if (board.func_96539_a(i) == objective) {
            board.func_96530_a(i, null);
        }
    }
    if (slot != null) {
        int slotNumber = CraftScoreboardTranslations.fromBukkitSlot(slot);
        board.func_96530_a(slotNumber, getHandle());
    }
}
 
Example #27
Source File: CraftScoreboard.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
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());
}
 
Example #28
Source File: TpsPingTask.java    From NyaaUtils with MIT License 5 votes vote down vote up
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: Game.java    From Survival-Games with GNU General Public License v3.0 5 votes vote down vote up
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 #30
Source File: Game.java    From BedWars with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
    }
}