[MC-12278] Comparing names to check that its not a player using a command block and @a or @p returns incorrect results Created: 18/Mar/13  Updated: 29/Dec/17  Resolved: 04/Jun/13

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1
Fix Version/s: None

Type: Bug
Reporter: Starbuck Johnson Assignee: Unassigned
Resolution: Duplicate Votes: 7
Labels: block, command, command_block

Issue Links:
Duplicate
duplicates MC-9355 Argument "team" do not work with "!" ... Resolved
CHK:
Confirmation Status: Community Consensus

 Description   

I just setup my server using vanilla because I have had endless issues making bukkit work for me. Since the advent of command blocks vanilla has become almost all I need - multiworld/world teleport command. Aside from that I decided to use the scoreboard system to be a almost permissions system with command blocks. I wanted to protect my house with a command block setup where you enter adventure mode. Except that would effect me too and I need to mine for resources. So I decided to make it exempt me. Upon trying to do that though, I ended up with a strange result of my player name (the name that was being filtered) and all the other players - a seemingly random player although it was the same person every time. Such as "myname, player3" without player2. I am positive that I am using the right format as I have tried every single format and multiple commands as well. As an aside, where am I supposed to request a feature (there are too many places where this is an option)?



 Comments   
Comment by Starbuck Johnson [ 09/May/13 ]

Is this accepted/confirmed yet?

On Wed, May 8, 2013 at 5:59 PM, Nathanael Neveux (JIRA) <

Comment by Nathanael Neveux [ 08/May/13 ]

Came looking for this exact issue - hoping it gets fixed. Soon Glad to see it looks like a simple fix - thanks UncleMion.

Comment by UncleMion [ 24/Mar/13 ]

I've noticed the problem with the target syntax

@a[name=!<username>]

myself. It only occurs when there's more than 1 person connected to a server, as you noted; it also happens with LAN sessions with additional people connected.

Checking the source for Minecraft 1.5.1 (decompiled with MCP 7.44),
the problem is in the method ServerConfigurationManager.findPlayers:

                if (par9Str != null)
                {
                    var17 = par9Str.startsWith("!");

                    if (var17)
                    {
                        par9Str = par9Str.substring(1);
                    }

                    if (var17 == par9Str.equalsIgnoreCase(var16.getEntityName()))
                    {
                        continue;
                    }
                }

This is in a loop; the first time through it's okay, but since it removes any leading ! from par9Str, it won't work any additional times - in fact, for any player after the first one, it will act as though the command target was

@a[name=<username>]

The solution? Don't change par9Str, make a local String variable and change that instead:

                if (par9Str != null)
                {
                    String tmp = par9Str;
                    var17 = tmp.startsWith("!");

                    if (var17)
                    {
                        tmp = tmp.substring(1);
                    }

                    if (var17 == tmp.equalsIgnoreCase(var16.getEntityName()))
                    {
                        continue;
                    }
                }

The same applies to the team name check on par10Str.

Comment by Starbuck Johnson [ 20/Mar/13 ]

Sorry for the incorrect last post but I did some more testing. the format is @a[name=!<testname>] and it works properly without any other players on the server, but with 2 players it acts like an @a with no name check and with 3 it removes one of the names, but not the one your trying to remove.

Comment by Starbuck Johnson [ 20/Mar/13 ]

Very simple. Make a command block that does any command such as /say or /me or /tp then use an @a[!name=<name to test>] the result will be random, and will include that name if the player is logged on and lose another player from my experience.

Comment by [Mod] CubeTheThird [ 20/Mar/13 ]

Could you provide a step by step list of instructions to demonstrate the issue? eg:
1. do this..
2 do that..
etc..

This would make the report more clear.

Comment by Starbuck Johnson [ 19/Mar/13 ]

Thanks. So long as this is known to be an issue not a feature request. In addition to information provided, teams work properly in this situation.

Comment by [Mod] CubeTheThird [ 18/Mar/13 ]

Feature requests should be posted on the MC forums here.

Generated at Sun Jan 12 12:30:23 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.