Skip to content

Conversation

@Machine-Maker
Copy link
Contributor

Closes Incendo/cloud-minecraft#8

It's a little jank putting it in minecraft-extras, cause you can't register a brig mapping for it afaik.

You can do it a plugin easily with

this.commands.brigadierManager().registerMapping(new TypeToken<ComponentArgument.Parser<CommandSender, ?>>() {}, builder -> builder
    .cloudSuggestions()
    .to(argument -> {
        return switch (argument.getStringMode()) {
            case QUOTED -> StringArgumentType.string();
            case GREEDY, GREEDY_FLAG_YIELDING -> StringArgumentType.greedyString();
            default -> StringArgumentType.word();
        };
    })
);

this also means you need a parser type, instead of just using StringArgument$StringParser#map to get a mapped parser.

@broccolai broccolai force-pushed the feature/ComponentArgument branch from 64c4145 to e240dad Compare November 2, 2023 23:42
@broccolai
Copy link
Member

Maybe we could include a static method for registering it on the ComponentArgument? Especially if users are always going to add it in the way you described

@jpenilla
Copy link
Member

This will need to be recreated for the https://github.com/Incendo/cloud-minecraft repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants