Mojira Archive
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.

Awaiting Response

BoredYukolin

2024-10-02, 05:12 AM

2024-10-04, 06:09 PM

2024-10-04, 06:09 PM

0

2

Unconfirmed

(Unassigned)

command-bug, functions

1.21.1

-