Java Code Examples for org.bukkit.scoreboard.Scoreboard#getTeam()
The following examples show how to use
org.bukkit.scoreboard.Scoreboard#getTeam() .
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 |
/** * Disconnect the player from the scoreboard * - Removes the player from their team (i.e., player-color) * - Removes their score from the scoreboard * - The scoreboard will still be displayed on the player's client * until a new scoreboard is assigned or the user exits */ public void disconnect(GPlayer gPlayer) { if (!isEnabled) { return; } UUID associatedWorldId = gPlayer.getAssociatedWorldId(); Scoreboard scoreboard = getScoreboard(associatedWorldId, false); if (scoreboard != null) { //Remove the team (i.e., player-color) OfflinePlayer player = Bukkit.getOfflinePlayer(gPlayer.getUuid()); Team team = scoreboard.getTeam(player.getName()); if (team != null) { team.removeEntry(player.getName()); team.unregister(); } //Remove the player's score: scoreboard.resetScores(player.getName()); //Delete unused scoreboards: if (scoreboard.getEntries().size() == 0) { scoreboards.remove(associatedWorldId); } } }
Example 2
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 6 votes |
public IslandGuard1_9(final ASkyBlock plugin) { this.plugin = plugin; this.thrownPotions = new HashMap<>(); if (!Settings.allowPushing) { // try to remove the team from the scoreboard try { ScoreboardManager manager = plugin.getServer().getScoreboardManager(); if (manager != null) { Scoreboard scoreboard = manager.getMainScoreboard(); if (scoreboard != null) { Team pTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME); if (pTeam != null) { pTeam.unregister(); } } } } catch (Exception e) { plugin.getLogger().warning("Problem removing no push from scoreboard."); } } }
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: 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 6
Source File: QAMain.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
public static Scoreboard registerGlowTeams(Scoreboard sb) { if (sb.getTeam("QA_RED") == null) { for (ChatColor c : ChatColor.values()) { if (sb.getTeam("QA_" + c.name() + "") == null) sb.registerNewTeam("QA_" + c.name() + "").setPrefix(c + ""); } } return sb; }
Example 7
Source File: IndividualPrefix.java From FunnyGuilds with Apache License 2.0 | 5 votes |
protected void addPlayer(String player) { if (player == null) { return; } User user = User.get(player); if (!user.hasGuild()) { return; } Scoreboard scoreboard = getScoreboard(); Team team = scoreboard.getEntryTeam(player); if (team != null) { team.removeEntry(player); } team = scoreboard.getTeam(user.getGuild().getTag()); if (team == null) { addGuild(user.getGuild()); team = scoreboard.getTeam(user.getGuild().getTag()); } if (this.getUser().hasGuild()) { if (this.getUser().equals(user) || this.getUser().getGuild().getMembers().contains(user)) { team.setPrefix(replace(FunnyGuilds.getInstance().getPluginConfiguration().prefixOur, "{TAG}", user.getGuild().getTag())); } } team.addEntry(player); }
Example 8
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 9
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()); } }