Scoreboard not being displayed and colors in team's prefix too

I’m trying to create and display a scoreboard. Here’s how I create it:

    UserStorageService userStorageService = Sponge.getServiceManager().provide(UserStorageService.class).get();
    String teamName = (userStorageService.get(leader).get().getName() + "'s party").substring(0, 16); //team name max 16 chars
    team = Team.builder().prefix(Text.of(partyColor.getTextCode(), " ")).name(teamName).build();
    Scoreboard scoreboard = Scoreboard.builder().build();
    Objective objective = Objective.builder().name("prova").displayName(Text.of("prova")).criterion(Criteria.HEALTH).build();
    scoreboard.updateDisplaySlot(objective, DisplaySlots.SIDEBAR);

and here’s how I assing it to a player:

That code compile, doesn’t trigger any error but it doesn’t display the scoreboard. What am I doing wrong?

EDIT: I’m using Sponge API 7.2.0

I remade your code within my own enviroment and tested it. Here is my code. The main differences is that the “Team” has a display name which may effect the teams, however should not effect the sidebar scoreboard. Are you sure that your “player.setScoreboard” is being called?

        Player player = (Player)src;
        Objective objective = Objective
        Team team = Team
                .members(new HashSet<>(Arrays.asList(player.getTeamRepresentation())))
        Scoreboard board = Scoreboard
        board.updateDisplaySlot(objective, DisplaySlots.SIDEBAR);

This is my result

1 Like

Thanks for replying.
Yes I’m absolutely sure that the setScoreboard method is called. I will try using your code.

Ok so I managed to get the scoreboard displayed. The new issue is the prefix color not working:

team = Team.builder().prefix(TextSerializers.FORMATTING_CODE.deserialize(partyColor.getCode())).name(leaderName).displayName(Text.of(teamName)).build();

Where partyColor.getCode() returns a color like &c, &4, etc

Is it a sponge bug?