My question is about programming scoreboards for the game Minecraft. My problem, which is why I'm now writing this question is the following:
I would like to program a scoreboard that shows the number of online players. The only problem is that I have no idea how to update the scoreboard when a player joins or leaves the server.
Everyone who has an idea, please write to me.
Thanks in advance!
PS: This would be the current code:
Scoreboard board = Bukkit.getScoreboardManager (). GetNewScoreboard ();
Objective o = board.registerNewObjective ("abcd", "abcd");
o.setDisplaySlot (DisplaySlot.SIDEBAR);
o.setDisplayName ( "§3Sky§eBlockPvP");
o.getScore ("") .setScore (3);
o.getScore ("§2player§8: §5" + Bukkit.getOnlinePlayers ()). SetScore (2);
o.getScore ("") .setScore (1);
p.setScoreboard (board);
I have never touched the Bukkit API but I think there will be a "Player Leave" / "Player Join" event or something. And if this is done then correct the variable in which the number of players is up / down
Yes thanks, that was just my idea. I will try it.