Rework scoreboardManager to work with multiple scoreboards

    • 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

          md_5 made changes -
          Resolution New: Invalid [ 10100 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          md_5 added a comment -

          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

          md_5 added a comment - 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

          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.

          montlikadani added a comment - 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.

          md_5 added a comment -

          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.

          md_5 added a comment - 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.
          montlikadani made changes -
          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.
          montlikadani created issue -

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

              Created:
              Updated:
              Resolved: