本文整理匯總了Java中org.bukkit.scoreboard.DisplaySlot類的典型用法代碼示例。如果您正苦於以下問題:Java DisplaySlot類的具體用法?Java DisplaySlot怎麽用?Java DisplaySlot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DisplaySlot類屬於org.bukkit.scoreboard包,在下文中一共展示了DisplaySlot類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: enableScoreboard
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的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: createscrollsb
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的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
}
示例3: refreshScoreboard
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的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);
}
示例4: createPlayerHealthObjective
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的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());
}
}
}
示例5: createSidebarTeamScoreObjective
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的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);
}
}
}
示例6: execute
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的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;
}
}
示例7: get
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
@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))};
}
}
示例8: Sidebar
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
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]);
}
}
示例9: ScoreHelper
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
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);
}
示例10: SimpleScoreboard
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
public SimpleScoreboard(String id, Player holder) {
this.holder = holder;
// Initiate the Bukkit scoreboard
scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
scoreboard.registerNewObjective(id, "dummy").setDisplaySlot(DisplaySlot.SIDEBAR);
objective = scoreboard.getObjective(DisplaySlot.SIDEBAR);
}
示例11: activate
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
@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;
}
示例12: registerTeams
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
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)");
}
示例13: setDefaultSidebar
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
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);
}
}
示例14: PlayerScoreboard
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
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);
});
}
示例15: HUD
import org.bukkit.scoreboard.DisplaySlot; //導入依賴的package包/類
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);
}