mojira.dev
MC-113967

Command /me does not resolve selectors if used by operator

The bug

Selectors in the text of the command /me (in previous versions also /tell, /msg and /w) are not resolved when an operator uses the command. They are however resolved when the command sender is not a player like for example an entity, a command block or a sign.

How to reproduce

Use the following command as operator

/me Closest player: @p

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

This feature was probably disabled as a fix for MC-43984, but for all players. This can be solved by having the methods net.minecraft.command.server.CommandEmote.execute(MinecraftServer, ICommandSender, String[]) and net.minecraft.command.server.CommandMessage.execute(MinecraftServer, ICommandSender, String[]) call a method which calls the method net.minecraft.command.CommandBase.getChatComponentFromNthArg(ICommandSender, String[], int, boolean) with the boolean parameter value being if the player can use selectors.

Example code

public static ITextComponent getChatComponentFromNthArgIfCanUseSelector(ICommandSender sender, String[] args, int index) throws PlayerNotFoundException, CommandException {
    return getChatComponentFromNthArg(sender, args, index, sender.canUseCommand(1, ""));
}

Linked issues

Attachments

Comments 5

No longer affects /msg, /tell or /w.

Can confirm in 20w51a.

Can confirm in 21w03a.

Cannot reproduce it in 1.21.1/24w38a. It displays the player's name as expected.

Thank you for your report!

However, this issue has been temporarily closed as Awaiting Response.

Is this still an issue in the latest version? If yes, can you please add it to the affected versions (or mention it if you are not the reporter)?

This ticket will automatically reopen when you reply.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

/me, /tell, command, operator, player, selector

Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, ..., Minecraft 19w09a, 20w46a, 20w49a, 20w51a, 21w03a

Retrieved