Search in sources :

Example 1 with Objective

use of org.bukkit.scoreboard.Objective in project GameCore by Warvale.

the class LobbyScoreboard method updatePlayerCount.

public void updatePlayerCount() {
    for (Player online : Bukkit.getOnlinePlayers()) {
        Objective objective = getScoreboards().get(online.getUniqueId()).getObjective("lobby");
        Team playerCount = getScoreboards().get(online.getUniqueId()).getTeam("LobbyCount");
        if (objective != null && playerCount != null) {
            playerCount.setSuffix(" §7" + Bukkit.getOnlinePlayers().size() + "/" + Game.getInstance().getMaxPlayer());
            objective.getScore("§8» §cPlayers:").setScore(11);
            objective.getScore("  ").setScore(10);
        }
    }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Player(org.bukkit.entity.Player) Team(org.bukkit.scoreboard.Team)

Example 2 with Objective

use of org.bukkit.scoreboard.Objective in project GameCore by Warvale.

the class LobbyScoreboard method newScoreboard.

public void newScoreboard(Player p, String display) {
    //add the user to the scoreboard
    if (!getScoreboards().containsKey(p.getUniqueId())) {
        addScoreboard(p, display);
    }
    Objective objective = getScoreboards().get(p.getUniqueId()).getObjective("lobby");
    if (objective != null) {
        objective.setDisplayName(ChatColor.DARK_GRAY + "» " + display + ChatColor.DARK_GRAY + " «");
    }
    //update the scoreboard
    updateTime();
    updatePlayerCount();
    p.setScoreboard(getScoreboards().get(p.getUniqueId()));
}
Also used : Objective(org.bukkit.scoreboard.Objective)

Example 3 with Objective

use of org.bukkit.scoreboard.Objective in project GameCore by Warvale.

the class LobbyScoreboard method updateTime.

public void updateTime() {
    for (Player online : Bukkit.getOnlinePlayers()) {
        Objective objective = getScoreboards().get(online.getUniqueId()).getObjective("lobby");
        Team time = getScoreboards().get(online.getUniqueId()).getTeam("LobbyTime");
        if (objective != null && time != null) {
            objective.getScore("    ").setScore(14);
            //objective.getScore("§8» §cTime:").setScore(7);
            Format date = new SimpleDateFormat("HH:mm:ss 'UTC'", Locale.US);
            String dateStr = date.format(new Date());
            time.setSuffix(" §7" + dateStr);
            objective.getScore("§8» §cTime:").setScore(13);
            objective.getScore("   ").setScore(12);
        }
    }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Player(org.bukkit.entity.Player) Format(java.text.Format) SimpleDateFormat(java.text.SimpleDateFormat) Team(org.bukkit.scoreboard.Team) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 4 with Objective

use of org.bukkit.scoreboard.Objective in project GameCore by Warvale.

the class LobbyScoreboard method addScoreboard.

public void addScoreboard(Player player) {
    Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    Objective objective = scoreboard.registerNewObjective("lobby", "dummy");
    objective.setDisplayName(ChatColor.DARK_GRAY + "» " + ChatColor.GREEN + "Waiting For Players..." + ChatColor.DARK_GRAY + " «");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    Team time = scoreboard.registerNewTeam("LobbyTime");
    time.addEntry("§8» §cTime:");
    time.setSuffix(" §7");
    Team lobbyCount = scoreboard.registerNewTeam("LobbyCount");
    lobbyCount.addEntry("§8» §cPlayers:");
    lobbyCount.setSuffix(" §7");
    scoreboards.put(player.getUniqueId(), scoreboard);
}
Also used : Objective(org.bukkit.scoreboard.Objective) Scoreboard(org.bukkit.scoreboard.Scoreboard) Team(org.bukkit.scoreboard.Team)

Example 5 with Objective

use of org.bukkit.scoreboard.Objective in project MassiveCore by MassiveCraft.

the class BoardUtil method clean.

// -------------------------------------------- //
// CLEAN
// -------------------------------------------- //
public static void clean(Player player) {
    // Delete scores for temporary objectives.
    for (Objective objective : getTemporaryObjectives()) {
        setObjectiveValue(objective, player, 0);
    }
    // Delete player team if temporary and sole player.
    for (Scoreboard board : getBoards()) {
        Team team = getKeyTeam(board, player);
        if (isTeamPersistent(team))
            continue;
        if (getTeamMembers(team).size() > 1)
            continue;
        deleteTeam(team);
    }
}
Also used : Objective(org.bukkit.scoreboard.Objective) Scoreboard(org.bukkit.scoreboard.Scoreboard) Team(org.bukkit.scoreboard.Team)

Aggregations

Objective (org.bukkit.scoreboard.Objective)28 Scoreboard (org.bukkit.scoreboard.Scoreboard)11 Team (org.bukkit.scoreboard.Team)8 Player (org.bukkit.entity.Player)7 Score (org.bukkit.scoreboard.Score)5 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)2 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)2 List (java.util.List)2 ScoreboardManager (org.bukkit.scoreboard.ScoreboardManager)2 Denizen (com.denizenscript.denizen.Denizen)1 BukkitScriptEvent (com.denizenscript.denizen.events.BukkitScriptEvent)1 NMSHandler (com.denizenscript.denizen.nms.NMSHandler)1 AssignmentTrait (com.denizenscript.denizen.npc.traits.AssignmentTrait)1 com.denizenscript.denizen.objects (com.denizenscript.denizen.objects)1 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)1 BossBarCommand (com.denizenscript.denizen.scripts.commands.server.BossBarCommand)1 AssignmentScriptContainer (com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer)1 CommandScriptHelper (com.denizenscript.denizen.scripts.containers.core.CommandScriptHelper)1 BukkitTagContext (com.denizenscript.denizen.tags.BukkitTagContext)1 ScoreboardHelper (com.denizenscript.denizen.utilities.ScoreboardHelper)1