public void refreshScoreboard() { Team team = getScoreboardTeam(); for (String entry : team.getEntries()) { team.removeEntry(entry); } team.addEntry(getBukkitEntity().getName()); team.setPrefix(Strings.nullToEmpty(scoreboardPrefix)); team.setSuffix(Strings.nullToEmpty(scoreboardSuffix)); if (nameHidden) { // team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER); team.setNameTagVisibility(NameTagVisibility.NEVER); } else { // team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS); team.setNameTagVisibility(NameTagVisibility.ALWAYS); } }
public static void initScoreboard() { try { Vars.scoreboard.registerNewTeam("Member").setPrefix(parseColors("&7")); Vars.scoreboard.registerNewTeam("Iron").setPrefix(parseColors("&f")); Vars.scoreboard.registerNewTeam("Gold").setPrefix(parseColors("&6")); Vars.scoreboard.registerNewTeam("Emerald").setPrefix(parseColors("&a")); Vars.scoreboard.registerNewTeam("Diamond").setPrefix(parseColors("&b")); Vars.scoreboard.registerNewTeam("Admin").setPrefix(parseColors("&c")); Vars.scoreboard.registerNewTeam("Owner").setPrefix(parseColors("&4")); Team ghost = Vars.scoreboard.registerNewTeam("Ghost"); ghost.setNameTagVisibility(NameTagVisibility.NEVER); ghost.setCanSeeFriendlyInvisibles(false); } catch (Exception e) { } for (Team t : Vars.scoreboard.getTeams()) { Vars.teams.add(t); } }
public void create(){ ScoreboardManager manager = Bukkit.getScoreboardManager(); board = manager.getNewScoreboard(); teamRed = board.registerNewTeam("Red"); teamRed.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); teamRed.setAllowFriendlyFire(false); teamGreen = board.registerNewTeam("Green"); teamGreen.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); teamGreen.setAllowFriendlyFire(false); objective = board.registerNewObjective("time", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName("Time"); Score scoreRed = objective.getScore(ChatColor.RED + "Red:"); scoreRed.setScore(Game.getGame().getCurrentArena().maxPoints); Score scoreGreen = objective.getScore(ChatColor.GREEN + "Green:"); scoreGreen.setScore(Game.getGame().getCurrentArena().maxPoints); teamRed.setPrefix(ChatColor.RED.toString()); teamGreen.setPrefix(ChatColor.GREEN.toString()); teamRed.setSuffix(ChatColor.WHITE.toString()); teamGreen.setSuffix(ChatColor.WHITE.toString()); }
@Override public NameTagVisibility getNameTagVisibility() throws IllegalArgumentException { OptionStatus visibility = getOption(Option.NAME_TAG_VISIBILITY); switch (visibility) { case ALWAYS: return NameTagVisibility.ALWAYS; case FOR_OTHER_TEAMS: return NameTagVisibility.HIDE_FOR_OTHER_TEAMS; case FOR_OWN_TEAM: return NameTagVisibility.HIDE_FOR_OWN_TEAM; case NEVER: return NameTagVisibility.NEVER; default: throw new RuntimeException("Unknown visibility: " + visibility); } }
@Override public void setNameTagVisibility(NameTagVisibility visibility) throws IllegalArgumentException { Validate.notNull(visibility, "visibility"); checkScoreboard(); switch (visibility) { case ALWAYS: this.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.ALWAYS); break; case HIDE_FOR_OTHER_TEAMS: this.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OTHER_TEAMS); break; case HIDE_FOR_OWN_TEAM: this.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.FOR_OWN_TEAM); break; case NEVER: this.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER); break; default: throw new RuntimeException("Unknown name tag visibility: " + visibility); } }
public static EnumNameTagVisibility bukkitToNotch(NameTagVisibility visibility) { switch (visibility) { case ALWAYS: return EnumNameTagVisibility.ALWAYS; case NEVER: return EnumNameTagVisibility.NEVER; case HIDE_FOR_OTHER_TEAMS: return EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS; case HIDE_FOR_OWN_TEAM: return EnumNameTagVisibility.HIDE_FOR_OWN_TEAM; default: throw new IllegalArgumentException("Unknown visibility level " + visibility); } }
public static NameTagVisibility notchToBukkit(EnumNameTagVisibility visibility) { switch (visibility) { case ALWAYS: return NameTagVisibility.ALWAYS; case NEVER: return NameTagVisibility.NEVER; case HIDE_FOR_OTHER_TEAMS: return NameTagVisibility.HIDE_FOR_OTHER_TEAMS; case HIDE_FOR_OWN_TEAM: return NameTagVisibility.HIDE_FOR_OWN_TEAM; default: throw new IllegalArgumentException("Unknown visibility level " + visibility); } }
/** * Set the team name tag visibility of a team by team name. * * @param team The reference name of the team. * @param vis The NameTagVisibility object to be set. */ public void setTeamNameTagVisibility(String team, NameTagVisibility vis) { if (teamMap.containsKey(team)) { teamMap.get(team).setNameTagVisibility(vis); for (Object p : Bukkit.getServer().getOnlinePlayers().toArray()) { // Debug Bukkit.broadcastMessage("Friendly Invisibles set!"); ((Player) p).getScoreboard().getTeam(team).setNameTagVisibility(vis); } } }
@Override public NameTagVisibility getNameTagVisibility() throws IllegalArgumentException { return null; }
public NameTagVisibility getNameTagVisibility() throws IllegalArgumentException { throw new NotImplementedException("getNameTagVisibility()"); }
public void setNameTagVisibility(NameTagVisibility nameTagVisibility) throws IllegalArgumentException { throw new NotImplementedException("setNameTagVisibility(NameTagVisibility)"); }
public NameTagVisibility getNameTagVisibility() throws IllegalArgumentException { CraftScoreboard scoreboard = checkState(); return notchToBukkit(team.getNameTagVisibility()); }
public void setNameTagVisibility(NameTagVisibility visibility) throws IllegalArgumentException { CraftScoreboard scoreboard = checkState(); team.setNameTagVisibility(bukkitToNotch(visibility)); }
public static Visibility of(NameTagVisibility slot) { return CONVERTER.convert(slot); }
public static NameTagVisibility of(Visibility slot) { return CONVERTER.reverse().convert(slot); }
@Override public NameTagVisibility getNameTagVisibility() throws IllegalArgumentException { checkState(); // this is technically against documentation but the documentation is stupid for this method return NameTagVisibilityConverter.of(getHandle().getNameTagVisibility()); }
@Override public void setNameTagVisibility(NameTagVisibility visibility) throws IllegalArgumentException { checkState(); // same for this checkArgument(visibility != null, "Visibility cannot be null"); getHandle().setNameTagVisibility(NameTagVisibilityConverter.of(visibility)); }
@Override public NameTagVisibility getNameTagVisibility() { return _team.getNameTagVisibility(); }
@Override public void setNameTagVisibility(NameTagVisibility nameTagVisibility) { _team.setNameTagVisibility(nameTagVisibility); }
@Override public void setNameTagVisibility( NameTagVisibility nameTagVisibility ) throws IllegalArgumentException { }
/** * Get name tag visibility. */ NameTagVisibility getNameTagVisibility();
/** * Set the name tag visibility. */ void setNameTagVisibility(NameTagVisibility nameTagVisibility);