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
- Place two ArmorStands
- Use the following command
/scoreboard teams add testTeam
- Use the following command
/scoreboard teams join testTeam @e
It prints "Added 3 player(s) to team testTeam: ..."
- 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
Created Issue:
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
- Place two ArmorStands
- Use the following command
/scoreboard teams add testTeam- Use the following command
/scoreboard teams join testTeam @eIt prints "Added 3 player(s) to team testTeam: ..."
- Use the following command
/scoreboard teams leave @eIt 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-55592as well
relates to
relates to
Probably the same reason as for MC-99758
The third argument is defined as being a selector. If this is the case and the selector includes multiple entities the command is executed for each entity. In this case for "@e[tag=test]", however like you said no entities which match the criterias exist. Only if no selector index is provided or the selector defines only a single entity the command is directly executed. As suggested in MC-99758 the "scoreboard teams" command should not return a selector index because when the command is executed it removes all matching entities at once and can also handle multiple selectors.


Does it do the same if you specify the team too?
No, it doesn't (see screenshots)
@user-f2760 this syntax is not valid. Like SunCat'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:I noticed it mainly when I had this command:It only removed everybody with a Walk score from AFK, not any other one.Only after I changed it toIt 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-106681And looking at the screenshot is does prevent it ("Removed 4 player(s) from their teams: .......")
Is this still the case in 1.13?