package net.minecraft.command.server; import com.google.gson.JsonParseException; import java.util.List; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.command.SyntaxErrorException; import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.IChatComponent; import org.apache.commons.lang3.exception.ExceptionUtils; public class CommandMessageRaw extends CommandBase { private static final String __OBFID = "CL_00000667"; public String getCommandName() { return "tellraw"; } /** * Return the required permission level for this command. */ public int getRequiredPermissionLevel() { return 2; } public String getCommandUsage(ICommandSender sender) { return "commands.tellraw.usage"; } public void processCommand(ICommandSender sender, String[] args) { if (args.length < 2) { throw new WrongUsageException("commands.tellraw.usage", new Object[0]); } else { EntityPlayerMP entityplayermp = getPlayer(sender, args[0]); String s = getStringFromNthArg(sender, args, 1); try { IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); entityplayermp.addChatMessage(ichatcomponent); } catch (JsonParseException jsonparseexception) { Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception); throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()}); } } } /** * Adds the strings available in this command to the given list of tab completion options. */ public List addTabCompletionOptions(ICommandSender sender, String[] args) { return args.length == 1 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : null; } /** * Return whether the specified command parameter index is a username parameter. */ public boolean isUsernameIndex(String[] args, int index) { return index == 0; } }