Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-59511

Tellraw has incomplete error message when key determining text to display is missing

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 14w26c, Minecraft 14w28a, Minecraft 14w29b, Minecraft 14w30c, Minecraft 14w31a, Minecraft 1.8-pre2, Minecraft 1.8.4, Minecraft 15w47c, Minecraft 16w07a, Minecraft 1.10.2, Minecraft 16w42a, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.1, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13b, Minecraft 17w15a, Minecraft 17w16b, Minecraft 17w17b, Minecraft 17w18b, Minecraft 1.12 Pre-Release 2, Minecraft 1.12.2
    • Confirmation Status:
      Confirmed

      Description

      The bug

      When no key determining the text to display is present, the game shows an error message, however this error message is incomplete.

      How to reproduce

      Perform this command:

      /tellraw @p {}
      

      The error message is:

      Invalid json: 
      

      The correct error message would be:

      Invalid json: Don't know how to turn {} into a Component
      

      The reason

      The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.

      The reason for this bug is that the public void processCommand(ICommandSender sender, String[] args) throws CommandException method of the net.minecraft.command.server.CommandMessageRaw (command /tellraw) and the net.minecraft.command.CommandTitle (command /title) class display any exception that occurs when the Json string is parsed using Throwable org.apache.commons.lang3.exception.ExceptionUtils.getRootCause(Throwable throwable). As there are however exceptions that are not thrown by the Json parser but by the net.minecraft.util.IChatComponent.Serializer class itself. The root cause is null. Instead it should just print the message of the exception.
      The following shows how this could by done for the net.minecraft.command.server.CommandMessageRaw class.

      public void processCommand(ICommandSender sender, String[] args) throws CommandException
      {
          if (args.length < 2)
          {
              throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
          }
          else
          {
              EntityPlayerMP var3 = getPlayer(sender, args[0]);
              String var4 = func_180529_a(args, 1);
      
              try
              {
                  IChatComponent var5 = IChatComponent.Serializer.jsonToComponent(var4);
                  var3.addChatMessage(ChatComponentProcessor.func_179985_a(sender, var5, var3));
              }
              catch (JsonParseException var7)
              {
                  // Changed this
                  //Throwable var6 = ExceptionUtils.getRootCause(var7);
                  //throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {var6 == null ? "" : var6.getMessage()});
                  throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {var7.getMessage()});
              }
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                searge [Mojang] Searge (Michael Stoyke)
                Reporter:
                marcono1234 [Mod] Marcono1234
              • Votes:
                6 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: