mojira.dev
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

Linked issues

Attachments

Comments 6

[^leave @e.png]
[^leave testTeam @e.png]

Does it do the same if you specify the team too?

scoreboard teams leave testTeam @e

No, it doesn't (see screenshots)

@@unknown this syntax is not valid. Like @unknown's screenshot shows the game tries to remove the player "testTeam" from their team as well and it prints the message seperately because "testTeam" has the index 2 which currently is treated as running for every single entity.

Actually it's a valid syntax:

scoreboard teams leave [players...]
scoreboard teams leave <team> [players...]

I noticed it mainly when I had this command:

scoreboard teams leave @a[score_Walk_min=1,team=AFK] @a[score_Run_min=1,team=AFK] @a[score_Jump_min=1,team=AFK] @a[score_Dive_min=1,team=AFK] @a[score_Fall_min=1,team=AFK] @a[score_Flying_min=1,team=AFK] @a[score_Swiming_min=1,team=AFK] @a[score_Sneaking_min=1,team=AFK] @a[score_Horse_min=1,team=AFK] @a[score_Minecart_min=1,team=AFK] @a[score_Boat_min=1,team=AFK] @a[score_Pig_min=1,team=AFK] @a[score_Medaforce_min=1,score_Medaforce=1,team=AFK] @a[score_Attack_min=1,team=AFK] @a[score_Drop_min=1,team=AFK] @a[score_Offline_min=1,team=AFK]

It only removed everybody with a Walk score from AFK, not any other one.
Only after I changed it to

scoreboard teams leave AFK @a[score_Walk_min=1,team=AFK] @a[score_Run_min=1,team=AFK] @a[score_Jump_min=1,team=AFK] @a[score_Dive_min=1,team=AFK] @a[score_Fall_min=1,team=AFK] @a[score_Flying_min=1,team=AFK] @a[score_Swiming_min=1,team=AFK] @a[score_Sneaking_min=1,team=AFK] @a[score_Horse_min=1,team=AFK] @a[score_Minecart_min=1,team=AFK] @a[score_Boat_min=1,team=AFK] @a[score_Pig_min=1,team=AFK] @a[score_Medaforce_min=1,score_Medaforce=1,team=AFK] @a[score_Attack_min=1,team=AFK] @a[score_Drop_min=1,team=AFK] @a[score_Offline_min=1,team=AFK]

It worked, so it IS a valid syntax.
(Also note that it's listed on the wiki too (http://minecraft.gamepedia.com/Scoreboard#Command_reference ))

Edit turns out it's a different issue, see MC-106681

And looking at the screenshot is does prevent it ("Removed 4 player(s) from their teams: .......")

Is this still the case in 1.13?

marcono1234

(Unassigned)

Confirmed

command, leave, scoreboard, scoreboard-teams, teams

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

Retrieved