Hey guys,
I am trying to add a scoreboard to the player on the PlayerJoinEvent. Since this didn’t work, I added a test command to add the scoreboard, because I thought that the player might not be ready when the PlayerJoinEvent gets fired.
Here is my CommandExecutor:
public class test implements CommandExecutor {
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Player player = (Player) src;
player.sendMessage(Text.of("Hello World!"));
Scoreboard scoreboard = Scoreboard.builder().build();
Objective objective = Objective.builder().name("Health").displayName(Text.of(TextColors.BLUE, "Health")).criterion(Criteria.DUMMY).build();
scoreboard.addObjective(objective);
scoreboard.updateDisplaySlot(objective, DisplaySlots.BELOW_NAME);
objective.getOrCreateScore(player.getTeamRepresentation()).setScore(123);
player.setScoreboard(scoreboard);
return CommandResult.success();
}
}
When I execute this command, it only sends me the message but no scoreboard appears.
Thanks in advance,
Cludch
