-
Type:
New Feature
-
Resolution: Invalid
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
1.15.2+
-
Yes
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.
[SPIGOT-5659] Rework scoreboardManager to work with multiple scoreboards
Resolution | New: Invalid [ 10100 ] | |
Status | Original: Open [ 1 ] | New: Resolved [ 5 ] |
Description |
Original:
As stated in the title, you should "work again" on scoreboardManager, which results in these errors with the following codes:
Using {code:java} player#getScoreboard{code} * 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. {code:java} 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); } } {code} _There is still a small modification to this, but it is understandable._ Using {code:java} Bukkit#getScoreboardManager#getNewScoreboard{code} * 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: * [[Animated Tab] - TabList|[https://www.spigotmc.org/resources/46229/]] ** Related github issues: [#127|https://github.com/montlikadani/TabList/issues/127], [#124|https://github.com/montlikadani/TabList/issues/124] * [AnimatedScoreboard|https://www.spigotmc.org/resources/20848/] 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. |
New:
As stated in the title, you should "work again" on scoreboardManager, which results in these errors with the following codes:
Using {code:java} player#getScoreboard{code} * 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. {code:java} 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); } } {code} _There is still a small modification to this, but it is understandable._ Using {code:java} Bukkit#getScoreboardManager#getNewScoreboard{code} * 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: * [TabList|[https://www.spigotmc.org/resources/46229/]] ** Related github issues: [#127|https://github.com/montlikadani/TabList/issues/127], [#124|https://github.com/montlikadani/TabList/issues/124] * [AnimatedScoreboard|https://www.spigotmc.org/resources/20848/] 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. |
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