Add ability for player disguises to copy existing players display name

This commit is contained in:
libraryaddict
2020-09-26 12:00:44 +12:00
parent 0a3bda1a8e
commit a92c8fb55e
5 changed files with 56 additions and 11 deletions

View File

@@ -235,6 +235,38 @@ public class DisguiseUtilities {
return team.getPrefix() + team.getColor() + player.getName() + team.getSuffix();
}
public static String getDisplayName(String playerName) {
if (StringUtils.isEmpty(playerName)) {
return playerName;
}
Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(playerName);
if (team != null && (!StringUtils.isEmpty(team.getPrefix()) || !StringUtils.isEmpty(team.getSuffix()))) {
return team.getPrefix() + team.getColor() + playerName + team.getSuffix();
}
Player player = Bukkit.getPlayer(playerName);
if (player == null) {
return playerName;
}
team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getUniqueId().toString());
if (team == null || (StringUtils.isEmpty(team.getPrefix()) && StringUtils.isEmpty(team.getSuffix()))) {
String name = player.getDisplayName();
if (name.equals(playerName)) {
return player.getPlayerListName();
}
return name;
}
return team.getPrefix() + team.getColor() + player.getName() + team.getSuffix();
}
public static void saveViewPreferances() {
if (!DisguiseConfig.isSaveUserPreferences()) {
return;