Java Code Examples for org.bukkit.scoreboard.Team#setSuffix()
The following examples show how to use
org.bukkit.scoreboard.Team#setSuffix() .
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: ScoreboardMatchModule.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
protected void updatePartyScoreboardTeam(Party party, Team team, boolean forObservers) { match.getLogger().fine("Updating scoreboard team " + toString(team) + " for party " + party); team.setDisplayName(TextTranslations.translateLegacy(party.getName(), null)); team.setPrefix(party.getColor().toString()); team.setSuffix(ChatColor.WHITE.toString()); team.setCanSeeFriendlyInvisibles(true); team.setAllowFriendlyFire(false); if (!forObservers && party instanceof Competitor) { NameTagVisibility nameTags = ((Competitor) party).getNameTagVisibility(); team.setNameTagVisibility(nameTags); } else { team.setNameTagVisibility(NameTagVisibility.ALWAYS); } }
Example 2
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 3
Source File: Scoreboards.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Puts a player into a team of their own and sets the team suffix to be the level * @param playerUUID - the player's UUID */ public void setLevel(UUID playerUUID) { Player player = plugin.getServer().getPlayer(playerUUID); if (player == null) { // Player is offline... return; } // The default team name is their own name String teamName = player.getName(); String level = String.valueOf(plugin.getPlayers().getIslandLevel(playerUUID)); Team team = board.getTeam(teamName); if (team == null) { //Team does not exist team = board.registerNewTeam(teamName); } // Add the suffix team.setSuffix(Settings.teamSuffix.replace("[level]",String.valueOf(level))); //Adding player to team team.addPlayer(player); // Assign scoreboard to player player.setScoreboard(board); }
Example 4
Source File: Scoreboards.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * Sets the player's level explicitly * @param playerUUID - the player's UUID * @param l */ public void setLevel(UUID playerUUID, long l) { Player player = plugin.getServer().getPlayer(playerUUID); if (player == null) { // Player is offline... return; } // The default team name is their own name - must be 16 chars or less String teamName = player.getName(); Team team = board.getTeam(teamName); if (team == null) { //Team does not exist team = board.registerNewTeam(teamName); } // Add the suffix team.setSuffix(Settings.teamSuffix.replace("[level]",String.valueOf(l))); //Adding player to team team.addPlayer(player); // Assign scoreboard to player player.setScoreboard(board); }
Example 5
Source File: ScoreboardModule.java From CardinalPGM with MIT License | 6 votes |
public void renderTeamTitle(TeamModule teamModule) { Team team = scoreboard.getTeam(teamModule.getId() + "-t"); team.setPrefix(teamModule.getColor() + Strings.trimTo(teamModule.getName(), 0, 14)); team.setSuffix(Strings.trimTo(teamModule.getName(), 14, 30)); if (team.getEntries().size() > 0) { setScore(objective, new ArrayList<>(team.getEntries()).get(0), currentScore); } else { String name = teamModule.getColor() + ""; while (used.contains(name)) { name = teamModule.getColor() + name; } team.addEntry(name); setScore(objective, name, currentScore); used.add(name); } currentScore++; }
Example 6
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 7
Source File: ScoreboardModule.java From CardinalPGM with MIT License | 5 votes |
public void renderCompactObjectives(ModuleCollection<GameObjective> objectives) { int score = currentScore; Team team = scoreboard.getTeam(objectives.get(0).getScoreboardHandler().getNumber() + "-o"); if (team != null) { String compact = ""; for (GameObjective obj : objectives) { compact += obj.getScoreboardHandler().getCompactPrefix(this.team) + " "; } while (compact.length() > 32) { compact = Strings.removeLastWord(compact); } if (compact.length() < 16){ team.setPrefix(Strings.trimTo(compact, 0, 16)); team.setSuffix("r"); } else if (compact.charAt(15) == '\u00A7') { team.setPrefix(Strings.trimTo(compact, 0, 15)); team.setSuffix(Strings.trimTo(compact, 15, 31)); } else { team.setPrefix(Strings.trimTo(compact, 0, 16)); team.setSuffix(Strings.getCurrentChatColor(compact, 16).charAt(1) + Strings.trimTo(compact, 16, 31)); } if (team.getEntries().size() > 0) { setScore(objective, new ArrayList<>(team.getEntries()).get(0), currentScore); } else { String name = "\u00A7"; while (used.contains(name)) { name = ChatColor.RESET + name; } team.addEntry(name); setScore(objective, name, score); used.add(name); } currentScore++; } }
Example 8
Source File: ScoreboardModule.java From CardinalPGM with MIT License | 5 votes |
public void renderTeamScore() { if (minTdmScore == -1){ minTdmScore = currentScore; } List<String> fullNames = new ArrayList<>(); for (ScoreModule score : GameHandler.getGameHandler().getMatch().getModules().getModules(ScoreModule.class)){ if (score.getMax() != 0){ fullNames.add(score.getScore() + "" + ChatColor.DARK_GRAY + "/" + ChatColor.GRAY + score.getMax() + " " + score.getTeam().getCompleteName()); } else { fullNames.add(score.getScore() + " " + score.getTeam().getCompleteName()); } } java.util.Collections.sort(fullNames, new Comparator<String>(){ public int compare(String str1, String str2){ int int1 = Integer.parseInt((str1.contains("/") ? str1.split("\u00a7",2) : str1.split(" ",2))[0]); int int2 = Integer.parseInt((str2.contains("/") ? str2.split("\u00a7",2) : str2.split(" ",2))[0]); return int1 - int2; } }); for (int i = 0; i < fullNames.size(); i++) { String teamCompleteName = fullNames.get(i).split(" ",2)[1]; Team team = scoreboard.getTeam(Teams.getTeamByName(teamCompleteName.substring(2)).get().getId() + "-s"); team.setPrefix(Strings.trimTo(fullNames.get(i), 0, 16)); team.setSuffix(Strings.trimTo(fullNames.get(i), 16, 32)); if (team.getEntries().size() > 0) { if (objective.getScore(new ArrayList<>(team.getEntries()).get(0)).getScore() != minTdmScore + i) setScore(objective, new ArrayList<>(team.getEntries()).get(0), minTdmScore + i); } else { String color = teamCompleteName.substring(0, 2); String name = color + ""; while (used.contains(name)) { name = color + name; } team.addEntry(name); setScore(objective, name, minTdmScore + i); used.add(name); } currentScore++; } }
Example 9
Source File: Scoreboards.java From CardinalPGM with MIT License | 5 votes |
public static String convertToScoreboard(Team team, String string, String insertColor, boolean doNotInterruptColorCodes) { int max1 = 16 - insertColor.length(); int max2 = 32 - (insertColor.length() * 2); int max3 = 48 - (insertColor.length() * 2); if (string.length() > max1) { if (string.substring(max1 - 1, max1).equals("§") && doNotInterruptColorCodes && !insertColor.equals("")) { max1--; max2--; max3--; } } if (string.length() > max3) { string = string.substring(0, max3); } if (string.length() <= max1) { team.setPrefix(""); team.addEntry(insertColor + string); team.setSuffix(""); return insertColor + string; } else if (string.length() <= max2) { team.setPrefix(insertColor + string.substring(0, max1)); team.addEntry(insertColor + string.substring(max1)); team.setSuffix(""); return insertColor + string.substring(max1); } else if (string.length() <= max3) { team.setPrefix(insertColor + string.substring(0, max1)); team.addEntry(insertColor + string.substring(max1, max2)); team.setSuffix(string.substring(max2)); return insertColor + string.substring(max1, max2); } return null; }
Example 10
Source File: CloudServer.java From CloudNet with Apache License 2.0 | 4 votes |
private void addTeamEntry(Player target, Player all, PermissionGroup permissionGroup) { String teamName = permissionGroup.getTagId() + permissionGroup.getName(); if (teamName.length() > 16) { teamName = teamName.substring(0, 16); CloudAPI.getInstance() .dispatchConsoleMessage("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!"); CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the name of the group in your perms.yml"); Bukkit.broadcast("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!", "cloudnet.notify"); Bukkit.broadcast("Please fix this issue by changing the name of the group in your perms.yml", "cloudnet.notify"); } Team team = all.getScoreboard().getTeam(teamName); if (team == null) { team = all.getScoreboard().registerNewTeam(teamName); } if (permissionGroup.getPrefix().length() > 16) { permissionGroup.setPrefix(permissionGroup.getPrefix().substring(0, 16)); CloudAPI.getInstance() .dispatchConsoleMessage("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!"); CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the prefix in your perms.yml"); Bukkit.broadcast("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!", "cloudnet.notify"); Bukkit.broadcast("Please fix this issue by changing the prefix in your perms.yml", "cloudnet.notify"); } if (permissionGroup.getSuffix().length() > 16) { permissionGroup.setSuffix(permissionGroup.getSuffix().substring(0, 16)); CloudAPI.getInstance() .dispatchConsoleMessage("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!"); CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the suffix in your perms.yml"); Bukkit.broadcast("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!", "cloudnet.notify"); Bukkit.broadcast("Please fix this issue by changing the suffix in your perms.yml", "cloudnet.notify"); } try { Method setColor = team.getClass().getDeclaredMethod("setColor", ChatColor.class); setColor.setAccessible(true); if (permissionGroup.getColor().length() != 0) { setColor.invoke(team, ChatColor.getByChar(permissionGroup.getColor().replaceAll("&", "").replaceAll("§", ""))); } else { setColor.invoke(team, ChatColor.getByChar(ChatColor.getLastColors(permissionGroup.getPrefix().replace('&', '§')) .replaceAll("&", "") .replaceAll("§", ""))); } } catch (NoSuchMethodException ignored) { } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } team.setPrefix(ChatColor.translateAlternateColorCodes('&', permissionGroup.getPrefix())); team.setSuffix(ChatColor.translateAlternateColorCodes('&', permissionGroup.getSuffix())); team.addEntry(target.getName()); target.setDisplayName(ChatColor.translateAlternateColorCodes('&', permissionGroup.getDisplay() + target.getName())); }
Example 11
Source File: SimpleScoreboard.java From ScoreboardLib with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") private FakePlayer getFakePlayer(String text, int offset) { Team team = null; String name; // If the text has a length less than 16, teams need not to be be created if (text.length() <= 16) { name = text + Strings.repeat(" ", offset); } else { String prefix; String suffix = ""; offset++; // Otherwise, iterate through the string and cut off prefix and suffix prefix = text.substring(0, 16 - offset); name = text.substring(16 - offset); if (name.length() > 16) name = name.substring(0, 16); if (text.length() > 32) suffix = text.substring(32 - offset); // If teams already exist, use them for (Team other : teamCache.rowKeySet()) { if (other.getPrefix().equals(prefix) && other.getSuffix().equals(suffix)) { team = other; } } // Otherwise create them if (team == null) { team = scoreboard.registerNewTeam(TEAM_PREFIX + TEAM_COUNTER++); team.setPrefix(prefix); team.setSuffix(suffix); teamCache.put(team, prefix, suffix); } } FakePlayer faker; if (!playerCache.contains(name, offset)) { faker = new FakePlayer(name, team, offset); playerCache.put(name, offset, faker); if (faker.getTeam() != null) { faker.getTeam().addPlayer(faker); } } else { faker = playerCache.get(name, offset); if (team != null && faker.getTeam() != null) { faker.getTeam().removePlayer(faker); } faker.setTeam(team); if (faker.getTeam() != null) { faker.getTeam().addPlayer(faker); } } return faker; }
Example 12
Source File: ScoreboardModule.java From CardinalPGM with MIT License | 4 votes |
public void updateTeamTitle(TeamModule teamModule) { Team team = scoreboard.getTeam(teamModule.getId() + "-t"); team.setPrefix(teamModule.getColor() + Strings.trimTo(teamModule.getName(), 0, 14)); team.setSuffix(Strings.trimTo(teamModule.getName(), 14, 30)); }