Mojira Archive
MC-99758

scoreboard teams leave executes for every specified entity

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

Awaiting Response

Marcono1234

2016-03-19, 06:27 PM

2017-11-12, 11:11 AM

2017-11-12, 11:11 AM

2

3

Confirmed

command, leave, scoreboard, scoreboard-teams, teams

Minecraft 1.9.1 Pre-Release 3, Minecraft 1.10.2, Minecraft 16w33a

-