Java Code Examples for org.bukkit.scoreboard.Team#setOption()
The following examples show how to use
org.bukkit.scoreboard.Team#setOption() .
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: TagDataHandler.java From TabooLib with MIT License | 6 votes |
private void updateTeamVariable(Scoreboard scoreboard, TagPlayerData playerData) { Team entryTeam = TagUtils.getTeamComputeIfAbsent(scoreboard, playerData.getTeamHash()); if (!entryTeam.getEntries().contains(playerData.getNameDisplay())) { entryTeam.addEntry(playerData.getNameDisplay()); } if (entryTeam.getPrefix() == null || !entryTeam.getPrefix().equals(playerData.getPrefix())) { entryTeam.setPrefix(playerData.getPrefix()); } if (entryTeam.getSuffix() == null || !entryTeam.getSuffix().equals(playerData.getSuffix())) { entryTeam.setSuffix(playerData.getSuffix()); } Team.OptionStatus option = entryTeam.getOption(Team.Option.NAME_TAG_VISIBILITY); if (option == Team.OptionStatus.ALWAYS && !playerData.isNameVisibility()) { entryTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER); } else if (option == Team.OptionStatus.NEVER && playerData.isNameVisibility()) { entryTeam.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS); } if (TabooLib.getConfig().getBoolean("TABLIST-AUTO-CLEAN-TEAM", true)) { TagUtils.cleanEmptyTeamInScoreboard(scoreboard); } }
Example 2
Source File: ScoreboardMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
protected void updatePartyScoreboardTeam(Party party, Team team, boolean forObservers) { logger.fine("Updating scoreboard team " + toString(team) + " for party " + party); team.setDisplayName(party.getName()); team.setPrefix(party.getColor().toString()); team.setSuffix(ChatColor.WHITE.toString()); team.setCanSeeFriendlyInvisibles(true); team.setAllowFriendlyFire(getMatch().getMapInfo().friendlyFire); team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); if(!forObservers && party instanceof Competitor) { Team.OptionStatus nameTags = ((Competitor) party).getNameTagVisibility(); // #HACK until this is fixed https://bugs.mojang.com/browse/MC-48730 we need to // ensure enemy name tags are always hidden for GS. if(getMatch().getMatchModule(GhostSquadronMatchModule.class) != null) { switch(nameTags) { case ALWAYS: nameTags = Team.OptionStatus.FOR_OWN_TEAM; break; case FOR_OTHER_TEAMS: nameTags = Team.OptionStatus.NEVER; break; } } team.setOption(Team.Option.NAME_TAG_VISIBILITY, nameTags); } else { team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS); } }
Example 3
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 4
Source File: NoPush.java From SuperVanish with Mozilla Public License 2.0 | 5 votes |
public void setCantPush(Player p) { Team team = p.getScoreboard().getTeam("Vanished"); if (team == null) { team = p.getScoreboard().registerNewTeam("Vanished"); } try { team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); team.addEntry(p.getName()); } catch (NoSuchMethodError | NoClassDefFoundError ignored) { } }
Example 5
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * Handles push protection * @param player */ public void setPush(Player player) { scoreboard = player.getScoreboard(); if (scoreboard == null) { //plugin.getLogger().info("1.9 " +"DEBUG: initializing scoreboard"); scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); } if (Settings.allowPushing) { if (scoreboard.getTeam(NO_PUSH_TEAM_NAME) != null) { //plugin.getLogger().info("1.9 " +"DEBUG: unregistering the team"); scoreboard.getTeam(NO_PUSH_TEAM_NAME).unregister(); } return; } // Try and get what team the player is on right now Team pushTeam = scoreboard.getEntryTeam(player.getName()); if (pushTeam == null) { // It doesn't exist yet, so make it pushTeam = scoreboard.getTeam(NO_PUSH_TEAM_NAME); if (pushTeam == null) { pushTeam = scoreboard.registerNewTeam(NO_PUSH_TEAM_NAME); } // Add the player to the team pushTeam.addEntry(player.getName()); } if (pushTeam.getName().equals(NO_PUSH_TEAM_NAME)) { //plugin.getLogger().info("1.9 " +"DEBUG: pushing not allowed"); pushTeam.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); } else { //plugin.getLogger().info("1.9 " +"DEBUG: player is already in another team"); } }
Example 6
Source File: ScoreboardModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onMatchStartEvent(MatchStartEvent event) { for (TeamModule team : Teams.getTeams()) { Team scoreboardTeam = scoreboard.getTeam(team.getId()); if (!team.isObserver()) scoreboardTeam.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); } }
Example 7
Source File: ScoreboardModule.java From CardinalPGM with MIT License | 5 votes |
@EventHandler public void onMatchEndEvent(MatchEndEvent event) { for (TeamModule team : Teams.getTeams()) { Team scoreboardTeam = scoreboard.getTeam(team.getId()); if (!team.isObserver()) scoreboardTeam.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); } }
Example 8
Source File: VersionUtils_1_13.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@Override public void setTeamNameTagVisibility(Team team, boolean value){ team.setOption(Team.Option.NAME_TAG_VISIBILITY, value?Team.OptionStatus.ALWAYS:Team.OptionStatus.NEVER); }
Example 9
Source File: VersionUtils_1_12.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@Override public void setTeamNameTagVisibility(Team team, boolean value){ team.setOption(Team.Option.NAME_TAG_VISIBILITY, value?Team.OptionStatus.ALWAYS:Team.OptionStatus.NEVER); }