Java Code Examples for org.bukkit.scoreboard.Scoreboard#registerNewObjective()

The following examples show how to use org.bukkit.scoreboard.Scoreboard#registerNewObjective() . 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 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 2
Source File: RaindropsListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
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 3
Source File: VersionUtils_1_13.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Objective registerObjective(Scoreboard scoreboard, String name, String criteria) {
    if (criteria.equals("health")){
        return scoreboard.registerNewObjective(name, criteria, name, RenderType.HEARTS);
    }
    return scoreboard.registerNewObjective(name, criteria, name);
}
 
Example 4
Source File: AssembleBoard.java    From Assemble with GNU General Public License v3.0 5 votes vote down vote up
public Objective getObjective() {
	Scoreboard scoreboard = getScoreboard();
	if (scoreboard.getObjective("Assemble") == null) {
		Objective objective = scoreboard.registerNewObjective("Assemble", "dummy");
		objective.setDisplaySlot(DisplaySlot.SIDEBAR);
		objective.setDisplayName(getAssemble().getAdapter().getTitle(Bukkit.getPlayer(getUuid())));
		return objective;
	} else {
		return scoreboard.getObjective("Assemble");
	}
}
 
Example 5
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 6
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 7
Source File: PlayerStat.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
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 8
Source File: TagUtils.java    From NovaGuilds with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Refreshes tag of a player
 *
 * @param p target player
 */
@SuppressWarnings("deprecation")
public static void refresh(Player p) {
	if(!Config.TAGAPI_ENABLED.getBoolean()) {
		return;
	}

	Scoreboard board = p.getScoreboard();
	for(Player player : CompatibilityUtils.getOnlinePlayers()) {
		NovaPlayer nPlayerLoop = PlayerManager.getPlayer(player);

		String tName = "ng_" + player.getName();
		if(tName.length() > 16) {
			tName = tName.substring(0, 16);
		}

		Team team = board.getTeam(tName);

		if(team == null) {
			team = board.registerNewTeam(tName);
			team.addPlayer(player);
		}

		//Points
		Objective pointsObjective = board.getObjective("points");
		if(Config.POINTSBELOWNAME.getBoolean()) {
			if(pointsObjective == null) {
				pointsObjective = board.registerNewObjective("points", "dummy");
				pointsObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
				pointsObjective.setDisplayName(Message.MISC_POINTSBELOWNAME.get());
			}

			Score score = pointsObjective.getScore(player);
			score.setScore(nPlayerLoop.getPoints());
		}
		else if(pointsObjective != null) {
			pointsObjective.unregister();
		}

		//set tag
		PreparedTag tag = new PreparedTagScoreboardImpl(PlayerManager.getPlayer(player));
		tag.setTagColorFor(PlayerManager.getPlayer(p));
		team.setPrefix(tag.get());
	}
}
 
Example 9
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 10
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 11
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 12
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 13
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 14
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria, DisplayName);
}
 
Example 15
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 16
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 17
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective getNewObjective(Scoreboard scoreboard, String criteria, String DisplayName) {
	return scoreboard.registerNewObjective(DisplayName, criteria);
}
 
Example 18
Source File: VersionUtils_1_12.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective registerObjective(Scoreboard scoreboard, String name, String criteria) {
    return scoreboard.registerNewObjective(name, criteria);
}
 
Example 19
Source File: VersionUtils_1_8.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Objective registerObjective(Scoreboard scoreboard, String name, String criteria) {
    return scoreboard.registerNewObjective(name, criteria);
}