mojira.dev
MC-12278

Comparing names to check that its not a player using a command block and @a or @p returns incorrect results

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)?

Linked issues

Comments 8

Feature requests should be posted on the MC forums here.

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.

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.

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.

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.

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.

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

Is this accepted/confirmed yet?

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

Starbuck Johnson

(Unassigned)

Community Consensus

block, command, command_block

Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1

Retrieved