[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
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
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. |