Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5659

Rework scoreboardManager to work with multiple scoreboards

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • 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.

            Unassigned Unassigned
            montlikadani montlikadani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: