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, ""));
}
No longer affects
/msg
,/tell
or/w
.