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

"Unknown function tag" exception isn't thrown correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.21.1
    • Unconfirmed
    • (Unassigned)

      In the code of command /function, there is a command exception:

      private static final DynamicCommandExceptionType ERROR_UNKNOWN_TAG = new DynamicCommandExceptionType((id) -> {
          return Component.translatableEscape("arguments.function.tag.unknown", new Object[]{id});
      });

      However, since this exception is only thrown by the code below:

      static Collection<CommandFunction<CommandSourceStack>> getFunctionTag(CommandContext<CommandSourceStack> context, ResourceLocation id) throws CommandSyntaxException {
          Collection<CommandFunction<CommandSourceStack>> collection = ((CommandSourceStack)context.getSource()).getServer().getFunctions().getTag(id);
          if (collection == null) {
              throw ERROR_UNKNOWN_TAG.create(id.toString());
          } else {
              return collection;
          }
      } 

      but the return value of ServerFunctionManager.getTag(ResourceLocation) is never null, this exception will never be thrown, but still occupies the localization text:

      "arguments.function.tag.unknown": "Unknown function tag '%s'"

      Instead, if a player inputs an non-existing function tag, the actual exception is "Can't find any functions for name %s", which is defined in class ScheduleCommand, incorrectly.

            Unassigned Unassigned
            BoredYukolin BoredYukolin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: