Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-99758

scoreboard teams leave executes for every specified entity

XMLWordPrintable

    • Confirmed

      The bug

      The command /scoreboard teams leave runs for every specified entity instead of for running once for all specified entities.

      How to reproduce

      1. Place two ArmorStands
      2. Use the following command
        /scoreboard teams add testTeam
        
      3. Use the following command
        /scoreboard teams join testTeam @e
        

        It prints "Added 3 player(s) to team testTeam: ..."

      4. Use the following command
        /scoreboard teams leave @e
        

        It prints "Removed 1 player(s) from their teams: ..." three times

      The reason

      The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

      The reason why this happens is because the method net.minecraft.command.server.CommandScoreboard.isUsernameIndex(String[], int) returns that the third (without scoreboard) argument is a player selector. This causes it to run the command for every entity affected. Instead it should only run once and then for all entities.

      /**
       * Return whether the specified command parameter index is a username parameter.
       */
      public boolean isUsernameIndex(String[] args, int index)
      {
          // Replaced this
          //return !args[0].equalsIgnoreCase("players") ? (args[0].equalsIgnoreCase("teams") ? index == 2 : false) : (args.length > 1 && args[1].equalsIgnoreCase("operation") ? index == 2 || index == 5 : index == 2);
          return args[0].equalsIgnoreCase("players") ? (args.length > 1 && args[1].equalsIgnoreCase("operation") ? index == 2 || index == 5 : index == 2) : false;
      }
      

      Note: Changing this method "fixes" MC-55592 as well

            Unassigned Unassigned
            marcono1234 Marcono1234
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: