Skip to content

Dynamically Updated MultiLiteral Argument #513

@CollidaCube

Description

@CollidaCube

Description

Currently, with StringArgument, you can provide a list of suggestions dynamically for the player to chose from using .replaceSuggestions(...) but it will really accept any token. There is also MultiLiteralArgument which has a hard-coded list of accepted values and considers any other token invalid. I would like to see an in-between where you can dynamically provide a list of accepted values and the argument will mark any other token as invalid.

Expected code

// Optimally, I imagine this
// Variation 1:

new MultiLiteralArgument("messageId").replaceSuggestions(
        ArgumentSuggestions.stringCollection(info -> EconomyManager.getAllEconomyIds())
);

// Variation 2:

new MultiLiteralArgument("messageId", ArgumentSuggestions.stringCollection(info -> EconomyManager.getAllEconomyIds()));

// This could work too

new StringArgument("messageId")
        .replaceSuggestions(
                ArgumentSuggestions.stringCollection(info -> EconomyManager.getAllEconomyIds())
                        .withRequirement(args -> args.suggestions().contains(args.currentArg()))
        );

// Or a new argument altogether

new DynamicallyUpdatedLiteralArgument("messageId").replaceSuggestions(...);

Extra details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions