本文整理匯總了Java中org.bukkit.scoreboard.Scoreboard類的典型用法代碼示例。如果您正苦於以下問題:Java Scoreboard類的具體用法?Java Scoreboard怎麽用?Java Scoreboard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Scoreboard類屬於org.bukkit.scoreboard包,在下文中一共展示了Scoreboard類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enableScoreboard
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
@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);
}
示例2: getScoreboard
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
public Scoreboard getScoreboard(Party party) {
return MapUtils.computeIfAbsent(partyScoreboards, party, () -> {
// Create the new party's scoreboard
Scoreboard scoreboard = getMatch().getServer().getScoreboardManager().getNewScoreboard();
logger.fine("Created scoreboard " + toString(scoreboard) + " for party " + party);
// Add all other party scoreboards to the new party's scoreboard
for(Party oldParty : partyScoreboards.keySet()) {
createPartyScoreboardTeam(oldParty, scoreboard, !(party instanceof Competitor));
}
// Add the new party to its own scoreboard
createPartyScoreboardTeam(party, scoreboard, !(party instanceof Competitor));
// Add the new party to the hidden scoreboard
createPartyScoreboardTeam(party, hiddenScoreboard, false);
// Add the new party to all other party scoreboards
for(Map.Entry<Party, Scoreboard> entry : partyScoreboards.entrySet()) {
createPartyScoreboardTeam(party, entry.getValue(), !(entry.getKey() instanceof Competitor));
}
return scoreboard;
});
}
示例3: getOrCreateObjective
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
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;
}
示例4: displayScoreboard
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
@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);
}
示例5: setRaindropsCount
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
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);
}
示例6: removePlayer
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
public GameTeam removePlayer(Player p, boolean updateTab) {
TeamLeaveEvent event = new TeamLeaveEvent(p, this);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) return this;
if (members.contains(p.getName())) {
if (updateTab) {
if (p.getScoreboard() != null) {
Scoreboard s = p.getScoreboard();
if (s.getTeam(this.getTeamName()) != null) {
Team team = s.getTeam(this.getRawTeamName());
team.removeEntry(p.getName());
}
}
}
members.remove(p.getName());
}
return this;
}
示例7: createscrollsb
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
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
}
示例8: SurvivalTeam
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
/**
* Constructor
*
* @param game Team based game instance
* @param name Team's name
* @param color Team's color
* @param chatColor Team's color in chat
*/
public SurvivalTeam(SurvivalTeamGame game, String name, DyeColor color, ChatColor chatColor)
{
this.game = game;
this.teamName = name;
this.chatColor = chatColor;
this.icon = new ItemStack(Material.WOOL, 1, color.getData());
this.maxSize = game.getPersonsPerTeam();
this.invited = new ArrayList<>();
this.players = new HashMap<>();
SurvivalAPI.get().registerEvent(SurvivalAPI.EventType.WORLDLOADED, () ->
{
Scoreboard board = game.getScoreboard();
this.team = board.registerNewTeam("meow" + chatColor.getChar());
this.team.setDisplayName(name);
this.team.setCanSeeFriendlyInvisibles(true);
this.team.setPrefix(chatColor + "");
this.team.setSuffix(ChatColor.RESET + "");
});
}
示例9: refreshScoreboard
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
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);
}
示例10: createTeam
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
private void createTeam() {
String name = "ocmInternal";
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Team team = null;
for (Team t : scoreboard.getTeams()) {
if (t.getName().equals(name)) {
team = t;
break;
}
}
if (team == null)
team = scoreboard.registerNewTeam(name);
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.FOR_OWN_TEAM);
team.setAllowFriendlyFire(true);
}
示例11: createPlayerHealthObjective
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
/**
* 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());
}
}
}
示例12: createSidebarTeamScoreObjective
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
/**
* 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);
}
}
}
示例13: saveScoreboard
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
/**
* Saves a scoreboard to a configuration file.
*
* @param config
* The configuration file.
* @param scoreboard
* The scoreboard.
*/
public void saveScoreboard(Configuration config, Scoreboard scoreboard) {
// Save teams
ConfigurationSection teamsSection = config.createSection("teams");
scoreboard.getTeams().forEach(team -> {
ConfigurationSection teamSection = teamsSection.createSection(team.getName());
saveTeam(teamSection, team);
});
// Save objectives
ConfigurationSection objectivesSection = config.createSection("objectives");
scoreboard.getObjectives().forEach(objective -> {
ConfigurationSection objectiveSection = objectivesSection.createSection(objective.getName());
objectiveSection.set("criteria", objective.getCriteria());
objectiveSection.set("display_name", objective.getDisplayName());
objectiveSection.set("display_slot", objective.getDisplaySlot().toString().toLowerCase());
});
// Save scores
ConfigurationSection scoresSection = config.createSection("scores");
scoreboard.getEntries().forEach(playerName -> {
ConfigurationSection playerSection = scoresSection.createSection(playerName);
scoreboard.getScores(playerName)
.forEach(score -> playerSection.set(score.getObjective().getName(), score.getScore()));
});
}
示例14: check
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
public boolean check(Event e) {
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
if (scoreboard != null) {
board = scoreboard.getSingle(e);
}
if (board.getObjective(obj.getSingle(e)) != null) {
if (boo == true) {
return true;
} else {
return false;
}
} else {
if (boo == false) {
return true;
} else {
return false;
}
}
}
示例15: execute
import org.bukkit.scoreboard.Scoreboard; //導入依賴的package包/類
@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;
}
}