mojira.dev
MC-121452

Playsound Command Validation Bug

The Playsound command has the following syntax:
/playsound <sound> <source> <player> [x] [y] [z] [volume] [pitch] [minVolume]

However, executing:
/playsound <sound> <source> and leaving out <player> causes an internal server error to happen.

Simple fix is to improve the argument validation.

Related issues

Comments

pokechu22

Confimed. Here's the console message (17w43b):

[18:43:15] [Server thread/WARN]: Couldn't process command: playsound minecraft:ambient.cave voice
java.lang.ArrayIndexOutOfBoundsException: 2
        at cx.a(SourceFile:48) ~[minecraft_server.17w43b.jar:?]
        at bj.a(SourceFile:92) [minecraft_server.17w43b.jar:?]
        at bj.a(SourceFile:70) [minecraft_server.17w43b.jar:?]
        at pa.c(SourceFile:855) [minecraft_server.17w43b.jar:?]
        at pa.a(SourceFile:842) [minecraft_server.17w43b.jar:?]
        at la.a(SourceFile:37) [minecraft_server.17w43b.jar:?]
        at la.a(SourceFile:9) [minecraft_server.17w43b.jar:?]
        at hv$1.run(SourceFile:13) [minecraft_server.17w43b.jar:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_141]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_141]
        at h.a(SourceFile:125) [minecraft_server.17w43b.jar:?]
        at net.minecraft.server.MinecraftServer.D(SourceFile:637) [minecraft_server.17w43b.jar:?]
        at nz.D(SourceFile:349) [minecraft_server.17w43b.jar:?]
        at net.minecraft.server.MinecraftServer.C(SourceFile:593) [minecraft_server.17w43b.jar:?]
        at net.minecraft.server.MinecraftServer.run(SourceFile:497) [minecraft_server.17w43b.jar:?]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]

This'll most likely be fixed when brigadier (the new command parsing library) is implemented, but in the mean time:

The current validation is simply if (args.length < 2); changing that to if (args.length < 3) would solve it. Alternatively, they could make the player argument optional by checking the number of arguments, as is done for the rest of the optional arguments.

migrated

I have never heard of this new parsing library. Do you know where I can find more information about it?

pokechu22

There's some info on 1.13's changes in this reddit post; brigadier is mentioned here. There's also some more technical discussion of it [in this #mcdevs IRC log] between 2017-07-31 22:47:04 and 2017-07-31 23:49:05.

tryashtar

This seems very similar to your report here: MC-101113.

migrated

(Unassigned)

Confirmed

Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b

Retrieved