mojira.dev
MC-277063

"Unknown function tag" exception isn't thrown correctly

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.

Attachments

Comments 1

We do not have enough information to reproduce this issue.

Please include the following information to help us understand your problem:

Steps to Reproduce:
1. (Explain what needs to be done for the issue to happen)
2.
3.

Observed Results:
(Briefly describe what happens)

Expected Results:
(Briefly describe what should happen)

Please also attach any needed commands, add-ons/behavior packs, data packs, resource packs, screenshots, videos, or worlds needed to help reproduce this issue.

Refer to the Bug Tracker Guidelines for more information about how to write helpful bug reports. Bug reports with insufficient information may be closed as Incomplete.

This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

BoredYukolin

(Unassigned)

Unconfirmed

(Unassigned)

command-bug, functions

1.21.1

Retrieved