Java Code Examples for org.bukkit.scoreboard.Scoreboard#registerNewTeam()
The following examples show how to use
org.bukkit.scoreboard.Scoreboard#registerNewTeam() .
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 |
/** * Connect the player to the scoreboard * - Disconnects from any existing scoreboards * - Creates a new scoreboard for the world if required */ public void connect(GPlayer gPlayer) { if (gPlayer != null && isEnabled) { //Disconnect the player from the current scoreboard (if required): disconnect(gPlayer); //Connect online players to their associated-world scoreboards: Player onlinePlayer = gPlayer.getOnlinePlayer(); if (onlinePlayer != null) { Scoreboard scoreboard = getScoreboard(gPlayer); onlinePlayer.setScoreboard(scoreboard); Team team = scoreboard.registerNewTeam(onlinePlayer.getName()); team.addEntry(onlinePlayer.getName()); update(gPlayer); } } }
Example 2
Source File: ScoreboardMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
protected Team createPartyScoreboardTeam( Party party, Scoreboard scoreboard, boolean forObservers) { match .getLogger() .fine("Creating team for party " + party + " on scoreboard " + toString(scoreboard)); Team team = scoreboard.registerNewTeam(getScoreboardTeamName(party)); updatePartyScoreboardTeam(party, team, forObservers); for (MatchPlayer player : party.getPlayers()) { team.addPlayer(player.getBukkit()); } return team; }
Example 3
Source File: AssembleBoardEntry.java From Assemble with GNU General Public License v3.0 | 5 votes |
public void setup() { final Scoreboard scoreboard = this.board.getScoreboard(); if (scoreboard == null) { return; } String teamName = this.identifier; // This shouldn't happen, but just in case if (teamName.length() > 16) { teamName = teamName.substring(0, 16); } Team team = scoreboard.getTeam(teamName); // Register the team if it does not exist if (team == null) { team = scoreboard.registerNewTeam(teamName); } // Add the entry to the team if (team.getEntries() == null || team.getEntries().isEmpty() || !team.getEntries().contains(this.identifier)) { team.addEntry(this.identifier); } // Add the entry if it does not exist if (!this.board.getEntries().contains(this)) { this.board.getEntries().add(this); } this.team = team; }
Example 4
Source File: TagUtils.java From TabooLib with MIT License | 5 votes |
public static Team getTeamComputeIfAbsent(Scoreboard scoreboard, String teamName) { Team team = scoreboard.getTeam(teamName); if (team == null) { scoreboard.registerNewTeam(teamName); } return scoreboard.getTeam(teamName); }
Example 5
Source File: ScoreboardMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
protected Team createPartyScoreboardTeam(Party party, Scoreboard scoreboard, boolean forObservers) { logger.fine("Creating team for party " + party + " on scoreboard " + toString(scoreboard)); Team team = scoreboard.registerNewTeam(getScoreboardTeamName(party)); updatePartyScoreboardTeam(party, team, forObservers); for(MatchPlayer player : party.getPlayers()) { team.addPlayer(player.getBukkit()); } return team; }
Example 6
Source File: PlayerAppearanceChanger.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
/** * Sets a prefix for a player's overhead name by adding them to a scoreboard team. * Don't use this if scoreboard teams are being used for any other purpose. */ private static void setOverheadNamePrefix(Player player, String prefix) { final Scoreboard scoreboard = player.getServer().getScoreboardManager().getMainScoreboard(); prefix = prefix.substring(0, Math.min(prefix.length(), 14)); Team team = scoreboard.getTeam(prefix); if(team == null) { team = scoreboard.registerNewTeam(prefix); team.setPrefix(prefix); team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); } team.addPlayer(player); }
Example 7
Source File: UHTeam.java From KTP with GNU General Public License v3.0 | 5 votes |
public UHTeam(String name, String displayName, ChatColor color, UHPlugin plugin) { this.name = name; this.displayName = displayName; this.color = color; this.plugin = plugin; Scoreboard sb = this.plugin.getScoreboard(); sb.registerNewTeam(this.name); Team t = sb.getTeam(this.name); t.setDisplayName(this.displayName); t.setCanSeeFriendlyInvisibles(true); t.setPrefix(this.color+""); }
Example 8
Source File: TagUtils.java From NovaGuilds with GNU General Public License v3.0 | 4 votes |
/** * 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()); } }