[SPIGOT-5659] Rework scoreboardManager to work with multiple scoreboards Created: 05/Apr/20  Updated: 08/Apr/20  Resolved: 08/Apr/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: montlikadani Assignee: Unassigned
Resolution: Invalid Votes: 0
Labels: scoreboard, tablist

Version: 1.15.2+
Guidelines Read: Yes

 Description   

As stated in the title, you should "work again" on scoreboardManager, which results in these errors with the following codes:

Using

player#getScoreboard
  • It causes the player to get a scoreboard, so if there is another scoreboard plugin, the scoreboard will not work properly, not all players will see the set of prefix.
  • In some cases it will breaks also the sort-priority what the user set.

To reproduce:

Create a method that has a player for-loop create a field in it, this field has the player#getScoreboard method, then set prefix/suffix settings (and those needed to create another team), finally use the player#setScoreboard method to set the scoreboard. Then install any scoreboard plugin (made with a NO reflections packet) and start the server with the plugin created. Log in to the server with two accounts and the result is here.

public void setTeam() {
    String name = "10001MyGroup"; // Group name with priority
    String name2 = "10002OtherGroup";

    for (Player player : Bukkit.getOnlinePlayers()) {
        String g = name;
        if (!player.hasPermission("perm.mygroup") &&
              player.hasPermission("perm.othergroup")) {
            g = name2;
        }
 
        Scoreboard tboard = player.getScoreboard();
	Team team = tboard.getTeam(g);
	if (team == null) {
	    team = tboard.registerNewTeam(g);
	}

        team.setPrefix(g.equals(name) ? "MyGrouppref" : "OtherGrouppref");
	team.setSuffix("anotherPrefix");

	team.setColor(ChatColor.RED);

	if (!team.hasEntry(player.getName())) {
	    team.addEntry(player.getName());
	}

	player.setScoreboard(tboard);
    }
}

There is still a small modification to this, but it is understandable.

 

Using

 

Bukkit#getScoreboardManager#getNewScoreboard
  • This causes you to create a scoreboard, but it doesn't do the right thing:
    • Other scoreboard plugins will work with the tablist prefix, but the sort priority will crash, so it will not be sorted, but by default in a-b-c order.
  • The other issue with this is that if you create a scoreboard in the class instance (to avoid a lot of scoreboard) and use it with players in a for-loop, the scoreboard will start showing both players ’scoreboard to everyone, which will become a flick.

To reproduce:

The same code that is on top, only Scoreboard is outside that method and Bukkit#getScoreboardManager#getNewScoreboard is specified.

 

And if we uses the Bukkit#getScoreboardManager#getMainScoreboard method, it will not work.

 

These issues can be tested with the following plugins:

 

There is no screenshot because it is proven and I get this kind of error almost on a daily basis.

 

With Java reflections, they work properly.



 Comments   
Comment by md_5 [ 08/Apr/20 ]

Yeah this doesn't make sense, of course two plugins setting different scoreboards won't work together because the player can only see one. This isn't something the API can fix

Comment by montlikadani [ 06/Apr/20 ]

Well, I meant it all, that if we have a scoreboard plugin and a tablist prefix set, the tablist prefix is created using Team, they take effect and break the names set on the tablist. I know this can be solved with player#setPlayerListName, but it can't sort players by priority numbers. For "multiple scoreboard" is when we use a scoreboard and a tablist prefix plugin.

Comment by md_5 [ 06/Apr/20 ]

This doesn't make sense to me, players can only see one scoreboard at a time.
In addition of course a shared scoreboard instance shares data.
It is unclear what on earth 'multiple scoreboards' would entail or how it would possibly work.

Generated at Tue Apr 22 03:30:26 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.