當前位置: 首頁>>代碼示例>>Java>>正文


Java Scoreboard類代碼示例

本文整理匯總了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);
}
 
開發者ID:TheIndra55,項目名稱:SpigotBoard,代碼行數:25,代碼來源:SBScoreboard.java

示例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;
    });
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:25,代碼來源:ScoreboardMatchModule.java

示例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;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:RaindropsListener.java

示例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);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:RaindropsListener.java

示例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);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:RaindropsListener.java

示例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;
    }
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:27,代碼來源:GameTeam.java

示例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
	
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:19,代碼來源:SbManager.java

示例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 + "");
    });

}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:32,代碼來源:SurvivalTeam.java

示例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);
}
 
開發者ID:GamerKing195,項目名稱:Thirst,代碼行數:21,代碼來源:ThirstManager.java

示例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);
}
 
開發者ID:gvlfm78,項目名稱:BukkitOldCombatMechanics,代碼行數:20,代碼來源:OCMMain.java

示例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());
        }
    }

}
 
開發者ID:redwallhp,項目名稱:AthenaGM,代碼行數:19,代碼來源:ScoreboardModule.java

示例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);
        }
    }

}
 
開發者ID:redwallhp,項目名稱:AthenaGM,代碼行數:20,代碼來源:ScoreboardModule.java

示例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()));
	});
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:34,代碼來源:ScoreboardPersister.java

示例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;
		}
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:20,代碼來源:CondObjectiveExists.java

示例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;
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:19,代碼來源:EffScoreboardClearSlot.java


注:本文中的org.bukkit.scoreboard.Scoreboard類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。