I have been learning how the scoreboard system works and I wanted to create a plugin that displays a prefix over a players head using teams and scoreboards. The problem is… I use luck-perms to configure permissions and use them for prefixes in the chat.
But the scoreboard is also displaying in the chat. is there anyway to prevent it?
Here is what I have (I’m just using this code as testing and is not the way it is going to work in the future)
@Listener
public void onJoin(ClientConnectionEvent.Login e){
Player player = e.getCause().first(Player.class).get(); Scoreboard playerScoreboard = player.getScoreboard(); Optional<Team> optionalTeam = playerScoreboard.getTeam(player.getName());
if (!optionalTeam.isPresent()) { playerScoreboard.registerTeam(Sponge.getGame().getRegistry().createBuilder(Team.Builder.class) .name(player.getName()) .build()); } if(player.hasPermission("ty.trainer")){
Team team = playerScoreboard.getTeam(player.getName()).get(); team.addMember(Text.of(player.getName())); team.setPrefix(Text.of(TextColors.GRAY, "[Trainer]")); }
}